vmstat command helps us to determine if a server is running short of CPU resources.
First, let us determine the number of CPUs available
Linux:
$ grep -i processor /proc/cpuinfo | wc -l
FreeBSD:
$ sysctl -a ‘hw.ncpu’
Run vmstat command 10 times with an interval of 5 seconds
$ vmstat 5 10
procs ———–memory———- —swap– —–io—- –system– —–cpu—–
r b  swpd  free  buff cache  si  so   bi   bo  in  cs us sy id wa st
1Â 0Â Â Â Â Â 0 186044 123220 1006872Â Â Â 0Â Â Â 0Â Â 182Â Â 103Â 509 1194 13Â 5 78Â 4Â 0
2Â 0Â Â Â Â Â 0 185812 123236 1006728Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 26Â 350 1046Â 6Â 2 83Â 9Â 0
2Â 0Â Â Â Â Â 0 185812 123244 1006788Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 13Â 410 1111Â 9Â 2 87Â 2Â 0
1Â 0Â Â Â Â Â 0 185508 123252 1007452Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 12Â 358Â 909Â 6Â 2 91Â 2Â 0
1Â 0Â Â Â Â Â 0 185656 123260 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 27Â 340Â 784Â 5Â 1 92Â 2Â 0
0Â 0Â Â Â Â Â 0 185656 123276 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 28Â 323Â 660Â 4Â 2 93Â 2Â 0
1Â 0Â Â Â Â Â 0 185656 123284 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 11Â 289Â 610Â 3Â 1 95Â 2Â 0
1Â 0Â Â Â Â Â 0 185656 123284 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â Â 0Â 296Â 629Â 3Â 1 96Â 0Â 0
2Â 0Â Â Â Â Â 0 185688 123292 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â Â 5Â 371Â 905Â 5Â 2 84Â 9Â 0
1Â 0Â Â Â Â Â 0 185532 123308 1006784Â Â Â 0Â Â Â 0Â Â Â Â 0Â Â Â 16Â 403Â 870Â 8Â 2 88Â 3Â 0
In the above command, under the heading procs, there is a column named r, which stands for runqueue
As per the man page of vmstat, “r” stands for the number of processes waiting for run time. If the value of the runqueue, r, exceeds the number of CPUs on the server, then the tasks are forced to wait for execution.
So, in this case we need to figure out the process hogging the CPU time and either suspend it or limit it’s access to CPU by changing it’s “nice” value.
-
Previous Post
Extract the contents of an RPM
-
Next Post
Linux – Tweaks