Operations 4 min read

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.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Mastering pidstat: Monitor CPU, Memory, and I/O of Linux 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 -u

Displays the same result as the default output.

2. Memory usage statistics

# pidstat -r

Field 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 -d

Field 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 -h

Shows 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 -h

The -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 mysql

The -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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Memory UsageLinux monitoringprocess monitoringCPU usagepidstatI/O statistics
Java High-Performance Architecture
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.