Identifying a resource hog with pidstat
The -top-io
and -top-cpu
flags will identify a top resource user, but might not provide enough information to identify the problem if there are multiple instances of a resource hog.
The pidstat
program will report per-process statistics, which can be sorted to provide more insight.
Getting ready
The pidstat
application may not be installed by default. It can be installed with this command:
# apt-get install sysstat
How to do it...
The pidstat application has several options for generating different reports:
-d
: This reports IO statistics-r
: This reports page faults and memory utilization-u
: This reports CPU utilization-w
: This reports task switches
Report Context Switch activity:
$ pidstat -w | head -5 Linux 2.6.32-642.11.1.el6.x86_64 (rtdaserver.cflynt.com) 02/15/2017 _x86_64_ (12 CPU) 11:18:35 AM PID cswch/s nvcswch/s Command 11:18:35 AM 1 0.00 0.00 init 11:18:35 AM 2 0.00 0.00 kthreadd...