[Reprint] pidstat command Detailed

pidstat command Detailed

HTTPS: // www.jianshu.com/p/3991c0dba094 

pidstat   -r -u -d -p various parameters very easy to use.

 

pidstat Overview

pidstat sysstat command is a tool for monitoring the occupancy of all or a specified process system resources cpu, memory, threads, and other IO device. pidstat display system starts from the statistics start of the first run, run after pidstat displays statistics since the last time the command is run later. Users can obtain the necessary statistical information by specifying the number and timing statistics.

pidstat installation

pidstat is part of the sysstat software suite, sysstat contains many linux system status monitoring tool that can be obtained from most linux distributions of the software source.

  • Can use the following commands in Debian / Ubuntu system to install:
    APT-GET the install the sysstat
  • CentOS / Fedora / RHEL versions of the linux use the following command:
    yum install sysstat

pidstat example

pidstat usage:

pidstat [ 选项 ] [ <时间间隔> ] [ <次数> ]

As shown below:

 

 

Commonly used parameters:

  • -u: the default parameters, displays cpu usage statistics for each process
  • -r: displays the memory usage of each process statistics
  • -d: display IO usage of each process
  • -p: Specifies the process ID
  • -w: display cases for each process context switch
  • -t: display additional information outside the statistical information to select the task thread
  • -T {TASK | CHILD | ALL}
    This option specifies the pidstat monitored. TASK the report of an independent task, CHILD keyword indicates the reporting process under all threads statistics. ALL indicates that all of the report of the independent task and the task of following the thread.
    Note: Non-global task and sub-thread statistics and pidstat options. These statistics do not correspond to the current statistical interval, these statistics will only be collected when the child thread kill or completed.
  • -V: version number
  • -h: displays all activities on one line, so other programs can be easily resolved.
  • -I: in an SMP environment, indicates that the task CPU utilization / number of cores
  • -l: displays the command name and all parameters

Example one: Check the CPU usage of all processes (-u -p ALL)

pidstat
pidstat -u -p ALL

pidstat and pidstat -u -p ALL are equivalent.
pidstat default show cpu usage for all processes.

 

Detailed description

  • PID: Process ID
  • % Usr: the process in user space occupied by the percentage of cpu
  • % System: the process in kernel space occupied by the percentage of cpu
  • % Guest: the process takes a percentage of cpu in a virtual machine
  • % CPU: the process takes a percentage of the cpu
  • CPU: cpu number of treatment processes
  • Command: command corresponding to the current process

Example Two: cpu usage statistics (-u)

pidstat -u

-U option, pidstat displays cpu usage statistics for each active process, the implementation of "pidstat -u" and the implementation of the results "pidstat" separate the same.

Example Three: Memory usage statistics (-r)

pidstat -r

-R option, pidstat will display the memory usage of each active process statistics:

 
  • PID: the process identifier
  • Minflt / s: minor error occurs per second task, no need to load pages from disk
  • Majflt / s: The main task of the occurrence of errors per second, requires the page is loaded from disk
  • VSZ: virtual address size, virtual memory usage KB
  • RSS: resident set size, the non-swap memory usage KB Wuli
  • Command: task command name

Example Four: Show IO usage of each process (-d)

pidstat -d
 

 

IO statistics report shows the following information:

  • PID: process id
  • kB_rd / s: KB read from the disk per second
  • kB_wr/s:每秒写入磁盘KB
  • kB_ccwr/s:任务取消的写入磁盘的KB。当任务截断脏的pagecache的时候会发生。
  • COMMAND:task的命令名

示例五:显示每个进程的上下文切换情况(-w)

pidstat -w -p 2831
 
  • PID:进程id
  • Cswch/s:每秒主动任务上下文切换数量
  • Nvcswch/s:每秒被动任务上下文切换数量
  • Command:命令名

示例六:显示选择任务的线程的统计信息外的额外信息 (-t)

pidstat -t -p 2831
 
  • TGID:主线程的表示
  • TID:线程id
  • %usr:进程在用户空间占用cpu的百分比
  • %system:进程在内核空间占用cpu的百分比
  • %guest:进程在虚拟机占用cpu的百分比
  • %CPU:进程占用cpu的百分比
  • CPU:处理进程的cpu编号
  • Command:当前进程对应的命令

示例七:pidstat -T

pidstat -T TASK
pidstat -T CHILD
pidstat -T ALL

TASK表示报告独立的task。
CHILD关键字表示报告进程下所有线程统计信息。
ALL表示报告独立的task和task下面的所有线程。

注意:task和子线程的全局的统计信息和pidstat选项无关。这些统计信息不会对应到当前的统计间隔,这些统计信息只有在子线程kill或者完成的时候才会被收集。

 
  • PID:进程id
  • Usr-ms:任务和子线程在用户级别使用的毫秒数。
  • System-ms:任务和子线程在系统级别使用的毫秒数。
  • Guest-ms:任务和子线程在虚拟机(running a virtual processor)使用的毫秒数。
  • Command:命令名

想了解更多精彩内容请关注我的公众号

 

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12022034.html
Recommended