Running mpstat -P ALL
on one of our servers returns the following:
06:48:02 AM CPU %user %nice %sys %iowait %irq %soft %steal %idle intr/s
06:48:02 AM all 15.61 0.08 84.09 7.20 0.56 0.01 0.00 13.97 763.27
06:48:02 AM 0 12.40 0.07 82.12 8.26 0.41 0.01 0.00 13.21 341.40
06:48:02 AM 1 18.82 0.04 86.06 6.15 0.72 0.01 0.00 14.73 421.87
So total CPU usage is;
all – 122.52%
CPU1 – 116.48%
CPU2 – 126.53%
Have I miss-understood how mpstat works? I thought the totals should always add up to 100%?
If it's relevant, the server is RHEL 5.5. CPU is Intel Xeon Dual Core L3406 2.26Ghz
Best Answer
From the mpstat manpage:
Running mpstat once only gives you a log-term estimate of usage. Running mpstat with an interval argument will give you more precise numbers.
This discrepancy is an accumulation of rounding errors, which grows with system activity and uptime. The actual statistics dispayed are collected from
/proc/stat
and/proc/uptime
. The statistics are counted in USER_HZ (usually 100Hz,getconf CLK_TCK
will confirm this), so your resolution is only 1/100th of a second; and a CPU does a lot in .01 seconds.As an example:
On my workstation, which has only been up for a few days, we get the above numbers. If we calculate the percentage of the total time for the cpu stats compared to uptime, we get
There's a (not very helpful) note about process statistics in the
ps
man page as well.