Skip to Content
Linux Shell Scripting Cookbook - Third Edition
book

Linux Shell Scripting Cookbook - Third Edition

by Clif Flynt, Sarath Lakshman, Shantanu Tushar
May 2017
Beginner
552 pages
28h 47m
English
Packt Publishing
Content preview from Linux Shell Scripting Cookbook - Third Edition

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

The pidstat application sorts its report by the PID number. The data can be re-organized with the sort utility. The following command displays the five applications that generate the most context switches per second (Field 4 in the -w output):

 $ pidstat ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Linux Shell Scripting - Second Edition

Mastering Linux Shell Scripting - Second Edition

Mokhtar Ebrahim, Andrew Mallett

Publisher Resources

ISBN: 9781785881985