Skip to content

Commit 9744d36

Browse files
committed
[BREAKING CHANGES] update default sleep for check-cpu.rb
The goal behind this is to provide overall more accurate CPU utilization results. The way we calculate this is to pull the current utilization sleep `n` seconds, poll again, and then take a difference between the two numbers. From my tests at my last organization I found that increasing the sleep time gave more accurate overall results. There are several reasons for this but the main reason is that by the very act of calling up the ruby interpreter you are incuring additional cpu utilization. By increasing the poll interval you allow its utilization to even out from the initial load of the interpreter. `5` is by no means a magic number but I found at my previous employer that `5` was a very reasonable compromise for accuracy and still being able to schedule it to see very granular results. The more resource contrained the machine is the more value you will get out of higher sleep/poll values. This is a breaking change as it updates the defaults and if you are scheduling this more frequently than 10 seconds (and do not set your own sleep value) you could very easily end up with multiple instances of the same check running which would only increase the problem. From my tests locally I did not notice much difference (about 2-3% inflated) between the data returned from this check and `top -d 5` values Signed-off-by: Ben Abrams <[email protected]>
1 parent 59de115 commit 9744d36

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
55

66
## [Unreleased]
77

8+
### Breaking Changes
9+
- changing the default of `--sleep` from `1` to `5` this argument controls the time between initial poll and the followup poll which will get more overall accurate measurement of cpu utilization especially on systems that have less resources available (@majormoses)
10+
811
## [2.1.0] - 2018-04-2018
912
### Added
1013
- Added metrics-cpu-interrupts.rb (@yuri-zubov sponsored by Actility, https://www.actility.com)

bin/check-cpu.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ class CheckCPU < Sensu::Plugin::Check::CLI
5353

5454
option :sleep,
5555
long: '--sleep SLEEP',
56+
description: 'This sleep controls the interval between the initial poll for cpu utilization and the next data point, the longer the interval is the more accurate your data will be', # rubocop:disable Metrics/LineLength
5657
proc: proc(&:to_f),
57-
default: 1
58+
default: 5
5859

5960
option :cache_file,
6061
long: '--cache-file CACHEFILE',

0 commit comments

Comments
 (0)