Mastering pidstat: Monitor CPU, Memory, and I/O of Linux Processes
This guide explains how to use the Linux pidstat command to monitor process-level CPU, memory, and I/O statistics, covering column meanings, various command options, and examples for specific processes and child processes.
pidstat command monitors all processes' status, such as CPU, memory, and I/O usage.
It can specify a particular process ID, monitoring interval, and other options.
Running pidstat without arguments displays CPU-related statistics for all processes.
Column meanings
PID : Process ID
%usr : Percentage of CPU time spent in user mode
%system : Percentage of CPU time spent in kernel mode
%CPU : Overall CPU usage of the process
CPU : CPU number on which the process is running
Command : Command name of the task
Usage examples
1. CPU usage statistics
# pidstat -uDisplays the same result as the default output.
2. Memory usage statistics
# pidstat -rField meanings:
minflt/s, majflt/s : Number of page faults per second when virtual memory is mapped to physical memory
VSZ : Virtual memory size of the process (kB)
RSS : Resident set size (physical memory) of the process (kB)
%MEM : Percentage of memory used by the process
3. I/O usage statistics
# pidstat -dField meanings:
kB_rd/s : Kilobytes read from disk per second by the process
kB_wr/s : Kilobytes written to disk per second by the process
4. Combined statistics
# pidstat -urd -hShows CPU, memory, and I/O data for each process; the -h option displays all information in a single line.
5. Statistics for a specific process
# pidstat -urd -p 1 -hThe -p 1 option specifies that data for the process with ID 1 should be reported.
6. Statistics for all child processes of a command
# pidstat -T CHILD -C mysqlThe -T option selects the type of statistics, and -C specifies the command name. This command reports information for all child processes of the mysql command.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
