Linux
banshee/linux-collection/linux/ssh/
cpu
CPU usage of a Linux by SSH: each core, the whole, iowait and steal, from /proc/stat.
by banshee1 installation2 versions
CPU of a Linux, by SSH
Returns the usage of each core and of the whole CPU, the share of time spent waiting for disks (iowait) and the time stolen by the hypervisor (steal), and the number of cores. Seven watches are offered, each one set on the probe.
What changed since version 1
- iowait and steal are new outputs, with their watches
iowait-highandsteal-high, checked. - New defaults, closer to a production server:
cpu-highwarns at 85 and is critical at 95 for 3 runs (version 1: critical at 60);core-hotwarns at 95 and is no longer checked (version 1: 70, checked);core-idleandcore-neglectedare no longer checked, as an idle core is normal on most servers. - A run where iowait went backwards is skipped, and a kernel without the steal column stops the collector
misconfiguredwith its reason, where version 1 stopped on a missing field. - Every watch keeps its id and kind: a probe upgraded from version 1 keeps its checks and settings.
How it works
The collector runs grep ^cpu /proc/stat and reads the cpu line (the whole) and the cpuN lines (each core): user, nice, system, idle, iowait, irq, softirq and steal times since boot.
- Usage is
1 − (idle + iowait) / totalover the interval, total being the sum of the eight times; iowait and steal are their own share of the total. - On the first run there is no interval yet: the run is skipped. So is a run where a counter went backwards (iowait may on some kernels).
- Portable:
/proc/statis written by the kernel the same way on Alpine, Debian and Fedora, andgrepwithout options is the same in BusyBox and GNU grep. Nothing is written on the target.
Prerequisites
- an SSH account for monitoring, without write rights; reading
/procneeds no privilege; - the fingerprint of the server's host key, set in
protocol:ssh:fingerprint(not needed when the Security settings trust the first SSH fingerprint presented).
Outputs
| Output | Unit | Per | Meaning |
|---|---|---|---|
cpu-busy | % | — | usage of the whole CPU |
iowait | % | — | time spent waiting for I/O |
steal | % | — | time stolen by the hypervisor |
core-busy | % | core (cpu0, cpu1…) | usage of each core |
cores | — | — | number of cores |
Watches
| Watch | Kind | Defaults | Checked |
|---|---|---|---|
cpu-high CPU busy | above, on cpu-busy | warning 85, critical 95, for 3 runs | yes |
iowait-high Waiting for disks | above, on iowait | warning 20, for 5 min | yes |
steal-high Stolen by the hypervisor | above, on steal | warning 10, for 5 min | yes |
core-hot A core saturated | above, on core-busy | warning 95, for 3 runs | no |
core-idle A core underused | below, on core-busy | warning 20 | no |
core-neglected A core left idle | deviate, on core-busy | warning 30 below the median of the other cores | no |
core-count Unexpected number of cores | expect, on cores | no expected value | yes, raises once a value is set |
Limits
- Values arrive from the second run on; a probe whose interval is long averages over it.
stealis only meaningful on a virtual machine; it stays at 0 on bare metal.- A kernel older than 2.6.11, without the steal column, stops the collector
misconfigured.