pidstat
pidstat helps monitoring processes on their CPU, memory, and disk activityInstallation
When pidstat is not installed by default, it can be added to the system using the relevant software package.
Package information for pidstat
Operating system | Package name | Installation |
---|---|---|
AlmaLinux | sysstat |
|
Arch Linux | sysstat |
|
Debian | sysstat |
|
Fedora | sysstat |
|
Red Hat Enterprise Linux | sysstat |
|
Rocky Linux | sysstat |
|
Ubuntu | sysstat |
|
Your Linux distribution using a different package? Share your feedback.
Usage
Available options
Option | Description |
---|---|
-C NAME | Define task(s) to monitor, may be using regular expression |
-d | Show disk activity |
--dec=0|1|2 | Set number of decimals, with 2 being the default |
-e COMMAND ARGS | Execute a COMMAND (with arguments ARGS) and monitor it with pidstat |
-G NAME | Define process name(s) to monitor, may be using regular expression, can be used with -t |
-H | Include timestamp (seconds since epoch) |
-h | Do not include summary, all output on one line, making it easier to parse by external tools |
--human | Human-readable formats |
-I | Divide CPU usage by total number of processors, for SMP environments |
-l | Include full command and arguments |
-p { pid[,pid2,pid3] | SELF | ALL} | Monitor only one process, multiple processes, pidstat itself, or all |
-R | Show information about realtime priority and scheduling |
-r | Show page faults and memory usage |
-s | Show stack usage |
-T { TASK, CHILD, ALL} | Define what should be included for tasks. |
-t | Include threads with selected tasks, can be used with -G |
-U | Show username instead of UID |
-u | Show CPU usage statistics |
-V | Show version number |
-v | Show information about some kernel tables |
-w | Show task switching activities |
Missing an option in this overview? Share your feedback.
Examples using pidstat
CPU usage monitoring with interval
Run pidstat with interval of 3 seconds
pidstat 3
Limit number of reports
Run pidstat with interval of 5 seconds, repeat 12 times (=60 seconds), then stop
pidstat 5 12
Disk activity
Show disk activity per process
pidstat -d 3
Single process monitoring
Start Chrome and monitor it, show details every 3 seconds, until Chrome is closed
pidstat 3 -e /opt/google/chrome/chrome
Relevant articles using the pidstat command
The following articles include an example on how to use pidstat and might be worth further exploring.