displaying total CPU usage

Eugene Grosbein eugen at grosbein.net
Sat Oct 24 11:31:39 UTC 2020


24.10.2020 14:57, Wojciech Puchar wrote:

>>> be the denominator for each state.  Multiply each fraction by 100 if you
>>> want percentages.
>>
>> `vmstat 1' readily provides the measurements.

Please note that for multi-core CPU averaging might yield misleading results
indicating lots of available/under-loaded CPU power when one of cores it already 100% bound.

You can see real picture with per-core counters obtained with sysctl kern.cp_times
that shows 5 values for each CPU core: user/nice/system/interrupts/idle.
For each core, exactly one of counters is incremented every "tick" at "stathz" frequency,
see sysctl kern.clockrate.

I use these counters to compute diffs between samples then normalize diffs to sampling interval and stathz
to obtain resulting percents. They are useful for graphs. For example, mrtg performs such computations
and normalization all by itself.


More information about the freebsd-hackers mailing list