开源是一种精神,分享是一种美德!

pidstat

相关命令:暂无相关命令
pidstat主要用于监控全部或指定进程占用系统资源的情况,如CPU,内存、设备IO、任务切换、线程等。pidstat首次运行时显示自系统启动开始的各项统计信息,之后运行pidstat将显示自上次运行该命令以后的统计信息。用户可以通过指定统计的次数和时间来获得所需的统计信息。

常用参数:

-C comm #只显示那些包含字符串(可是正则表达式)comm的命令的名字
 -d #显示I/O统计信息(须内核2.6.20及以后)
    PID        #进程号
    kB_rd/s #每秒此进程从磁盘读取的千字节数
    kB_wr/s #此进程已经或者将要写入磁盘的每秒千字节数
    kB_ccwr/s #由任务取消的写入磁盘的千字节数
    Command #命令的名字
 -h #显示所有的活动的任务
 -I #在SMP环境,指出任务的CPU使用(等同于选项-u)应该被除于cpu的总数
 -l #显示进程的命令名和它的参数
 -p { pid [,...] | SELF | ALL } #指定线程显示其报告
 -r #显示分页错误的内存利用率
    When reporting statistics for individual tasks, the following values are displayed:
    PID        #进程号
    minflt/s #每秒次缺页错误次数(minor page faults),次缺页错误次数意即虚拟内存地址映射成物理内存地址产生的page fault次数
    majflt/s #每秒主缺页错误次数(major page faults),当虚拟内存地址映射成物理内存地址时,相应的page在swap中,这样的page fault为major page fault,一般在内存使用紧张时产生
    VSZ        #该进程使用的虚拟内存(以kB为单位)
    RSS        #该进程使用的物理内存(以kB为单位)
    %MEM #当前任务使用的有效内存的百分比
    Command #任务的命令名             
    When reporting global statistics for tasks and all their children, the following values are displayed:
    PID        #PID号
    minflt-nr #在指定的时间间隔内收集的进程和其子进程的次缺页错误次数
    majflt-nr #在指定的时间间隔内收集的进程和其子进程的主缺页错误次数
    Command #命令名
 -s #堆栈的使用
 -t #显示与所选任务相关的线程的统计数据
 -T { TASK | CHILD | ALL } #指定必须监测的内容:TASK是默认的,单个任务的报告;CHILD:指定的进程和他们的子进程的全局报告,ALL:相当于TASK和CHILD
 -u #报告CPU使用
    When reporting statistics for individual tasks, the following values are displayed: 
    PID
    %usr #用户层任务正在使用的CPU百分比(with or without nice priority ,NOT include time spent running a virtual processor)
    %system #系统层正在执行的任务的CPU使用百分比
    %guest #运行虚拟机的CPU占用百分比
    %CPU #所有的使用的CPU的时间百分比
    CPU        #处理器数量
    Command #命令
    When reporting global statistics for tasks and all their children, the following values are displayed:
    PID        #PID号
    usr-ms #在指定时间内收集的在用户层执行的进程和它的子进程占用的CPU时间(毫秒){with or without nice priority,NOT include time spent running a virtual processor)
    system-ms #在指定时间内收集的在系统层执行的进程和它的子进程占用的CPU时间(毫秒)
    guest-ms #花在虚拟机上的时间
    Command #命令
 -V #版本号
 -w #报告任务切换情况
    PID        #PID号
    cswch/s #每秒自动上下文切换
    nvcswch/s #每秒非自愿的上下文切换
    Command #命令
 

1,查看系统启动后所有活动进程的cpu统计信息

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


2,pidstat命令指定采样周期和采样次数,命令形式为”pidstat [option] interval [count]”,以下pidstat输出以2秒为采样周期,输出10次cpu使用统计信息:

linux:~ # pidstat 2 10

3,pidstat将显示某活动进程的内存使用统计:

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

4,查看进程IO的统计信息:

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

评论(0)

暂无评论

评论

名字:
验证码:
获取验证码
内容: