brief introduction

 pidstat It is mainly used to monitor the system resources occupied by all or specified processes , Such as CPU, Memory 、 equipment IO、 Task switching 、 Threads, etc .pidstat Display statistics since system startup when running for the first time , And then run pidstat Statistics since the last time the command was run will be displayed . Users can get the required statistics by specifying the number and time of statistics .

 

Instance to explain

Default parameters

perform pidstat, The output of all active processes after system startup cpu Statistics :

 

 

linux:~ # pidstat
Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_
11:37:19          PID    %usr %system  %guest    %CPU   CPU  Command
……
11:37:19        11452    0.00    0.00    0.00    0.00     2  bash
11:37:19        11509    0.00    0.00    0.00    0.00     3  dd

 

Specify the sampling period and sampling times

pidstat Command to specify the sampling period and sampling times , The order form is ”pidstat [option] interval [count]”, following pidstat Output to 2 Second is the sampling period , Output 10 Time cpu Use statistics :

pidstat 2 10

 

 

cpu Usage statistics (-u)

Use -u Options ,pidstat The... Of each activity process will be displayed cpu Use statistics , perform ”pidstat -u” With the execution alone ”pidstat” The effect is the same .

 

Memory usage statistics (-r)

Use -r Options ,pidstat The memory usage statistics of each active process will be displayed :

 

linux:~ # pidstat -r -p 13084 1
Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_
15:08:18          PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
15:08:19        13084 133835.00      0.00 15720284 15716896  96.26  mmmm
15:08:20        13084  35807.00      0.00 15863504 15849756  97.07  mmmm
15:08:21        13084  19273.87      0.00 15949040 15792944  96.72  mmmm

 

The meaning of the above column output is as follows :

 

minflt/s:  Page faults per second (minor page faults), The number of page missing errors means that the virtual memory address is mapped to the physical memory address page fault frequency
majflt/s:  Number of main page missing errors per second (major page faults), When the virtual memory address is mapped to the physical memory address , Corresponding page stay swap in , In this way page fault by major page fault, It is usually generated when memory usage is tight
VSZ:       Virtual memory used by this process ( With kB In units of )
RSS:       The physical memory used by the process ( With kB In units of )
%MEM:      Percentage of memory used by the process
Command:   Pull up the command corresponding to the process 

 

 

IO Statistics (-d)


Use -d Options , We can see the progress IO Statistical information :

 

linux:~ # pidstat -d 1 2
Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_
17:11:36          PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
17:11:37        14579 124988.24      0.00      0.00  dd
17:11:37          PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
17:11:38        14579 105441.58      0.00      0.00  dd

 

Meaning of output information

kB_rd/s:  The amount of data the process reads from disk per second ( With kB In units of )
kB_wr/s:  The amount of data the process writes to disk per second ( With kB In units of )
Command:  Pull up the command corresponding to the process 

 

For specific statistical processes (-p)

Use -p Options , We can see the system resource usage of a specific process :

 

linux:~ # pidstat -r -p 1 1
Linux 2.6.32.12-0.7-default (linux)             06/18/12        _x86_64_
18:26:17          PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
18:26:18            1      0.00      0.00   10380    640   0.00  init
18:26:19            1      0.00      0.00   10380    640   0.00  init
……

 

 

pidstat Common commands

Use pidstat When positioning problems , The following commands are often used :

pidstat -u 1
pidstat -r 1
pidstat -d 1

The above orders are subject to 1 Second is the information collection cycle , Get separately cpu、 Memory and disk IO Statistical information .

 

from  http://www.cnblogs.com/bangerlee/articles/2555307.html