sensu-plugins / sensu-plugins-cpu-checks

This plugin provides native CPU instrumentation for monitoring and metrics collection, including: CPU usage and metrics for user, nice, system, idle, iowait, irq, softirq, steal, and guest.
http://sensu-plugins.io
MIT License
13 stars 34 forks source link

metrics-cpu.rb much faster than other scripts #9

Open Gillingham opened 8 years ago

Gillingham commented 8 years ago

sensu-plugins-cpu-checks (0.0.4)

# time /opt/sensu/embedded/bin/metrics-cpu-pcnt-usage.rb | grep real

real    0m1.123s
user    0m0.116s
sys 0m0.006s
# time /opt/sensu/embedded/bin/metrics-cpu-mpstat.rb | grep real

real    0m1.125s
user    0m0.117s
sys 0m0.007s
# time /opt/sensu/embedded/bin/metrics-cpu.rb | grep real

real    0m0.124s
user    0m0.116s
sys 0m0.008s

Ran multiple iterations and the two additional versions seem to always take a second or longer to execute, is the a reason behind this?

dalesit commented 8 years ago

The two additional versions sleep for a second to generate their stats - they get an initial value, sleep for a second, and then get an additional value and compare the delta. However, I have a problem on one of my systems which is showing (according to metrics-cpu-mpstat) nearly 100% cpu utilisation, but according to sar, 75% idle time. The act of measuring the CPU over a second seems to be incorrectly putting up the CPU stats, although not on other identical servers which are 88% idle (according to sar).

Looks like I'm going to have to go back to using metrics-cpu.rb and doing the conversion in grafana

nikhilo commented 6 years ago

@dalesit We are seeing the same problem. The CPU usage is sometimes reported incorrectly by the cpu-pcnt-usage-metrics script. Sometimes restarting sensu-client fixes the problem. But not every time. This makes the metric unreliable and completely useless.