LinuxCommandLibrary

pidstat

Report processes' resource usage statistics

TLDR

Show CPU statistics at a 2 second interval for 10 times

$ pidstat [2] [10]
copy

Show page faults and memory utilization
$ pidstat -r
copy

Show input/output usage per process ID
$ pidstat -d
copy

Show information on a specific PID
$ pidstat -p [PID]
copy

Show memory statistics for all processes whose command name include "fox" or "bird"
$ pidstat -C "[fox|bird]" -r -p ALL
copy

SYNOPSIS


pidstat [ options ] [ interval [ count ] ]

Example: pidstat -u 1 5 (CPU stats every second for 5 reports)
Example: pidstat -d -p 1234 (I/O stats for PID 1234)
Example: pidstat -H -t -p 5678 2 (Thread stats for PID 5678 every 2 seconds continuously)

PARAMETERS

-d
    Report I/O statistics, including kilobytes read/written per second (kB_rd/s, kB_wr/s) and canceled write bytes (kB_ccwr/s).

-H
    Report statistics for individual threads of a process. When used with -p, it implies -t, showing thread-level data.

-h
    Display a short help message and exit.

-l
    Display the full command line arguments of the tasks being monitored, not just the command name.

-p PID[,...] | ALL
    Report statistics only for the specified process IDs. Use ALL to report for all currently active tasks.

-r
    Report memory statistics, such as minor/major page faults per second (minflt/s, majflt/s), virtual memory size (VSZ), and resident set size (RSS).

-s
    Report stack usage statistics, including stack size (StkSize) and stack segment references (StkRef).

-t
    Report statistics for individual threads. This option is implicitly set when -H and -p are used together.

-u
    Report CPU utilization statistics. This is the default behavior if no specific report option is given.

-V
    Display the version number of the pidstat command and exit.

-w
    Report context switch statistics, showing voluntary (cswch/s) and non-voluntary (nvcswch/s) context switches per second.

interval
    The time interval in seconds between each report. If omitted, pidstat prints a single report.

count
    The number of reports to display. If specified with interval, pidstat will exit after count reports. Otherwise, it runs continuously.

DESCRIPTION

pidstat is a command-line tool used to monitor and report detailed statistics for individual Linux tasks, including processes and threads. It provides insights into CPU utilization, memory consumption, I/O activity, context switches, and stack usage for specific PIDs or all active processes. This tool is invaluable for performance tuning, troubleshooting, and understanding process behavior on a system. As part of the sysstat utility collection, pidstat helps pinpoint resource bottlenecks at a granular process level, making it essential for system administrators and developers alike.

CAVEATS

pidstat relies on data from the /proc filesystem, so its accuracy and available metrics depend on the kernel version and configuration.
It requires the sysstat package to be installed on the system.
High monitoring frequencies with many processes can impose minor system overhead.
Some advanced metrics might require specific kernel capabilities or root privileges.

<B>DEFAULT BEHAVIOR</B>

If no specific options are provided, pidstat defaults to reporting CPU utilization statistics (as if -u was specified) for all active processes, presenting a single snapshot.

<B>CONTINUOUS MONITORING</B>

When interval is specified without count, pidstat provides continuous reports until interrupted (e.g., by Ctrl+C). This is useful for real-time monitoring of process activity.

<B>INTERPRETING OUTPUT</B>

The output columns of pidstat vary based on the options used. Common columns include PID, %usr, %system, %CPU (CPU utilization), minflt/s, majflt/s (memory faults), kB_rd/s, kB_wr/s (I/O), cswch/s, nvcswch/s (context switches). Refer to the man page for full column descriptions.

HISTORY

pidstat is part of the sysstat utilities, a suite of performance monitoring tools for Linux. It was introduced to provide detailed, per-process statistics, complementing the system-wide reports offered by tools like sar and iostat. The sysstat project, maintained by Sébastien Godard, has been under continuous development since 1999, with pidstat evolving to offer increasingly granular insights into process behavior.

SEE ALSO

iostat(1), mpstat(1), sar(1), vmstat(8), ps(1), top(1)

Copied to clipboard