pidstat

So this week is the pidstat command which I've used when trying to debug problems. I use pidstat to see what's going on with different processes in intervals like iostat. You'll need a 2.6 kernel or later to use this command the way I do. Here's the command I use:

 pidstat -d -p ALL 30 5

This means:

  • -d = report I/O stats "PID, KB_rd/s, KB_rw/s, KB_ccwr/s, Command"
  • -p All = show all processes owned by the system
  • 30 = 30 second intervals
  • 5 = display 5 reports

Here's a portion of the output using the above command except with 5 seconds vs 30:

06:57:03 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command

06:57:08 PM         1      0.00      0.00      0.00  init

06:57:08 PM         2      0.00      0.00      0.00  kthreadd

06:57:08 PM         3      0.00      0.00      0.00  migration/0

06:57:08 PM         4      0.00      0.00      0.00  ksoftirqd/0

06:57:08 PM         5      0.00      0.00      0.00  watchdog/0

06:57:08 PM         6      0.00      0.00      0.00  events/0

06:57:08 PM         7      0.00      0.00      0.00  khelper

06:57:08 PM        41      0.00      0.00      0.00  kblockd/0

06:57:08 PM        44      0.00      0.00      0.00  kacpid

06:57:08 PM        45      0.00      0.00      0.00  kacpi_notify

06:57:08 PM       113      0.00      0.00      0.00  kseriod

06:57:08 PM       150      0.00      0.00      0.00  pdflush

06:57:08 PM       151      0.00      0.00      0.00  pdflush

06:57:08 PM       152      0.00      0.00      0.00  kswapd0

06:57:08 PM       193      0.00      0.00      0.00  aio/0

06:57:08 PM      1434      0.00      0.00      0.00  ksuspend_usbd

06:57:08 PM      1437      0.00      0.00      0.00  khubd

06:57:08 PM      2262      0.00      0.00      0.00  ata/0

06:57:08 PM      2264      0.00      0.00      0.00  ata_aux

06:57:08 PM      2500      0.00      0.00      0.00  kjournald

06:57:08 PM      2702      0.00      0.00      0.00  udevd

06:57:08 PM      2922      0.00   2829.42      0.00  dd

 You'll notice some activity with dd which shows that it was writing back to the hard drive during my 5 seconds of capturing activity. If you were running in a multuser environment and the hard drive was filling up, you can run the above and be able to find out that the user with process ID 2922 needs to be quieted down!

 

This entry was posted in software and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *