naarad
naarad copied to clipboard
Support mpstat to print per CPU utilization
The current SAR command prints the system's average CPU utilization. mpstat breaks down CPU utilization per CPU. With this data, we can find out if a particular CPU is more heavily used than others. A sample output is here:
mpstat -P ALL 2 11:30:49 AM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle 11:30:51 AM all 6.88 0.00 1.79 0.71 0.00 0.00 0.00 0.00 90.61 11:30:51 AM 0 8.04 0.00 3.52 0.00 0.00 0.00 0.00 0.00 88.44 11:30:51 AM 1 2.48 0.00 1.49 0.00 0.00 0.00 0.00 0.00 96.04 11:30:51 AM 2 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00 11:30:51 AM 3 0.50 0.00 0.50 6.53 0.00 0.00 0.00 0.00 92.46 11:30:51 AM 4 0.50 0.00 0.50 0.00 0.00 0.00 0.00 0.00 99.00 11:30:51 AM 5 0.50 0.00 0.00 0.00 0.00 0.00 0.00 0.00 99.50 11:30:51 AM 6 7.00 0.00 2.50 0.00 0.00 0.00 0.00 0.00 90.50 11:30:51 AM 7 58.00 0.00 4.50 0.00 0.00 0.00 0.00 0.00 37.50 11:30:51 AM 8 3.02 0.00 5.03 0.00 0.00 0.00 0.00 0.00 91.96 11:30:51 AM 9 0.50 0.00 2.00 2.00 0.00 0.00 0.00 0.00 95.50 11:30:51 AM 10 1.00 0.00 0.50 0.00 0.00 0.00 0.00 0.00 98.51 11:30:51 AM 11 0.00 0.00 1.00 0.00 0.00 0.00 0.00 0.00 99.00
Joy, can you look into sar a little more and find out if using some other options in sar can give per-CPU usage?
Ritesh, The command sar -u -P ALL 2 can print the per CPU utilization with 2-fewer breakdown columns, %irq and %soft per CPU. A sample output from sar is as below: 12:46:46 PM CPU %user %nice %system %iowait %steal %idle 12:46:48 PM all 6.97 0.00 1.67 0.83 0.00 90.53 12:46:48 PM 0 11.50 0.00 3.50 0.00 0.00 85.00 12:46:48 PM 1 3.02 0.00 1.51 7.54 0.00 87.94 12:46:48 PM 2 2.50 0.00 0.50 0.00 0.00 97.00 12:46:48 PM 3 0.50 0.00 0.50 0.00 0.00 99.00 12:46:48 PM 4 0.50 0.00 0.50 0.00 0.00 99.00 12:46:48 PM 5 0.50 0.00 0.50 0.00 0.00 98.99 12:46:48 PM 6 4.50 0.00 2.00 0.00 0.00 93.50 12:46:48 PM 7 57.21 0.00 5.47 2.49 0.00 34.83 12:46:48 PM 8 3.00 0.00 4.00 0.00 0.00 93.00 12:46:48 PM 9 0.50 0.00 1.00 0.00 0.00 98.50 12:46:48 PM 10 0.50 0.00 1.00 0.00 0.00 98.50 12:46:48 PM 11 0.00 0.00 0.50 0.00 0.00 99.50
We can do sar -u ALL -P ALL
will actually give us all the columns.
Just update we have sar -u -P ALL
now to get per cpuusage.