I am using Topbeat with ELK to monitor CentOS 6.8 server performance. I am trying to recreate the % idle value reported from the top command:
Cpu(s): 2.7%us, 1.0%sy, 2.8%ni, 90.5%id, 2.5%wa, 0.0%hi, 0.2%si, 0.3%st
In logstash I have this filter:
ruby {
code => "event['cpu']['total'] = event['cpu']['user'] + event['cpu']['nice'] + event['cpu']['system'] + event['cpu']['idle'] + event['cpu']['iowait'] + event['cpu']['irq'] + event['cpu']['softirq'] + event['cpu']['steal']"
code => "event['cpu']['idle_p'] = 100.0 * event['cpu']['idle'] / event['cpu']['total']"
}
When I compare the top command line output to my calculated idle_p value over time I see that the calculated value is far more stable relative to what I see on the command line. On the command line I see swings of +/-10% over the a few seconds, while the calculated value swings +/-0.1% over the course of an hour. It seems that cpu.idle hardly changes.
I am wondering why the swings I see from the command line are not seen in the cpu.idle value. Is there some kind of averaging taking place when Topbeat samples? I confirmed using Topbeat logs that the cpu.idle values are what's being reported by Topbeat and not due to some post processing by Logstash.