[20141203]学习使用pidstat.txt

简介: [20141203]学习使用pidstat.txt #  rpm -qif `which pidstat` Name        : sysstat                      Relocations: (not relocatable) Version     : 9.

[20141203]学习使用pidstat.txt

#  rpm -qif `which pidstat`
Name        : sysstat                      Relocations: (not relocatable)
Version     : 9.0.4                             Vendor: CentOS
Release     : 18.el6                        Build Date: Tue 19 Jul 2011 08:43:17 PM CST
Install Date: Sun 17 Jun 2012 12:32:32 PM CST      Build Host: c6b5.bsys.dev.centos.org
Group       : Applications/System           Source RPM: sysstat-9.0.4-18.el6.src.rpm
Size        : 825089                           License: GPLv2+
Signature   : RSA/SHA1, Mon 26 Sep 2011 12:25:37 PM CST, Key ID 0946fca2c105b9de
Packager    : CentOS BuildSystem http://bugs.centos.org>
URL         : http://perso.orange.fr/sebastien.godard/
Summary     : The sar and iostat system monitoring commands
Description :
This package provides the sar and iostat commands for Linux. Sar and
iostat enable system monitoring of disk, network, and other IO
activity.

--竟然和前几天看sar命令在同一个包里面,比对才知道好像rh 4.X版本没有这个命令,仅仅在centos 6.X才存在。顺便学习看看。
--能使用它来检测进程以及生成报表,也能检测特定的进程号或者系统的全部进程。并且也是sysstat软件包的一部分,自己很少使用它。

1.查看特定的命令相关进程:

#  pidstat -C oracle
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:10:12 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:10:12 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:10:12 PM      4323    0.00    0.00    0.00    0.00    21  oracle
04:10:12 PM      4325    0.00    0.00    0.00    0.00    13  oracle
04:10:12 PM      4327    0.00    0.00    0.00    0.00    17  oracle
04:10:12 PM      4329    0.00    0.00    0.00    0.00    13  oracle
04:10:12 PM      4331    0.00    0.00    0.00    0.00    13  oracle
04:10:12 PM      4333    0.00    0.00    0.00    0.00    13  oracle
...


2.检测特定进程号。
#  pidstat -p  4321 1
64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:12:33 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:12:34 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:35 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:36 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:37 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:38 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:39 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:40 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:41 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:42 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:43 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:44 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:45 PM      4321    0.00    0.00    0.00    0.00     0  oracle
04:12:46 PM      4321    0.00    0.00    0.00    0.00     0  oracle

--后面的参数表示间隔事件(单位秒),实现连续检测。

3.显示I/O Statistics,使用-d选项,后面的参数表示间隔时间。
#  pidstat -p  4335 -d 1
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:17:48 PM       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
04:17:49 PM      4335      0.00      0.00      0.00  oracle
04:17:50 PM      4335      0.00      0.00      0.00  oracle
04:17:51 PM      4335      0.00     32.00      0.00  oracle
04:17:52 PM      4335      0.00      0.00      0.00  oracle
04:17:53 PM      4335      0.00      0.00      0.00  oracle
04:17:54 PM      4335      0.00     32.00      0.00  oracle
04:17:55 PM      4335      0.00      0.00      0.00  oracle
04:17:56 PM      4335      0.00      0.00      0.00  oracle
04:17:57 PM      4335      0.00     32.00      0.00  oracle
04:17:58 PM      4335      0.00      0.00      0.00  oracle
04:17:59 PM      4335      0.00      0.00      0.00  oracle
04:18:00 PM      4335      0.00     32.00      0.00  oracle
04:18:01 PM      4335      0.00      0.00      0.00  oracle
04:18:02 PM      4335      0.00      0.00      0.00  oracle
04:18:03 PM      4335      0.00     32.00      0.00  oracle
04:18:04 PM      4335      0.00      0.00      0.00  oracle
04:18:05 PM      4335      0.00      0.00      0.00  oracle

#  ps -ef | grep 4335 | grep -v grep
oracle    4335     1  0 Nov21 ?        00:01:24 ora_ckpt_xxxxxx

--可以发现oracle的ckpt进程每3秒写1次。应该是控制文件。必须按ctrl+c退出。
--可以在后面再增加一个参数,限制执行的次数,然后退出。其他以下的命令具有相似的作用。

4.显示Paging Activity,使用-r参数,后面的参数表示间隔时间。

#  pidstat -p  4335 -r 1
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:20:34 PM       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
04:20:35 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:36 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:37 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:38 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:39 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:40 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:41 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:42 PM      4335      0.00      0.00 3296996  15608   0.05  oracle
04:20:43 PM      4335      0.00      0.00 3296996  15608   0.05  oracle


5.显示执行命令的完成参数,使用-l参数。
#  pidstat   -p   3930  -l
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:23:37 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:23:37 PM      3930    0.00    0.00    0.00    0.00     1  /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit

#  pidstat   -p   3930
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:23:45 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:23:45 PM      3930    0.00    0.00    0.00    0.00     1  tnslsnr

#  pidstat -C  tnslsnr -l
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:24:27 PM       PID    %usr %system  %guest    %CPU   CPU  Command
04:24:27 PM      3930    0.00    0.00    0.00    0.00     1  /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit


6.显示特定进程的子进程使用-T参数。

后面参数:CHILD ALL TASK

#  pidstat  -T CHILD | head
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:34:22 PM       PID    usr-ms system-ms  guest-ms  Command
04:34:22 PM         1  33373890  26414510         0  init
04:34:22 PM         3      1150      6330         0  migration/0
04:34:22 PM         4        10    340620         0  ksoftirqd/0
04:34:22 PM         6      3680      5690         0  watchdog/0
04:34:22 PM         7      1820      4360         0  migration/1
04:34:22 PM         8         0        20         0  migration/1
04:34:22 PM         9        10    297100         0  ksoftirqd/1

7.以树型格式显示使用-t参数。

#  pidstat -C tnslsnr -t -l
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

04:37:51 PM      TGID       TID    %usr %system  %guest    %CPU   CPU  Command
04:37:51 PM      3930         -    0.00    0.00    0.00    0.00     1  /u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
04:37:51 PM         -      3930    0.00    0.00    0.00    0.00     1  |__/u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit
04:37:51 PM         -      3931    0.00    0.00    0.00    0.00    15  |__/u01/app/oracle/product/10.2.0/db_1/bin/tnslsnr LISTENER -inherit

8.显示全部统计在一行,使用-h参数:
--很奇怪很少有命令参数使用-h,一般使用它作为帮助。
--前面提到-r 显示Paging Activity,-d 显示磁盘IO -u 显示cpu使用。
--如果执行 pidstat -rud 是分开显示,不直观。加入-h参数解决这个问题。

[root@xxxxxx IP=100.89 ~ 99]#  pidstat -p 4335 1 -rdu -h
Linux 2.6.32-220.17.1.el6.x86_64 (xxxxxx)     12/03/2014      _x86_64_        (24 CPU)

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596299      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596300      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596301      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00     32.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596302      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596303      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596304      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00     32.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596305      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596306      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596307      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00     32.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596308      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596309      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00      0.00      0.00  oracle

#      Time       PID    %usr %system  %guest    %CPU   CPU  minflt/s  majflt/s     VSZ    RSS   %MEM   kB_rd/s   kB_wr/s kB_ccwr/s  Command
1417596310      4335    0.00    0.00    0.00    0.00     1      0.00      0.00 3296996  15608   0.05      0.00     32.00      0.00  oracle

目录
相关文章
|
6月前
|
Linux
Linux命令之wc
Linux命令 wc
42 0
|
2月前
|
移动开发 Linux Windows
【Linux专题_05】wc -l 命令统计行数为何不准
【Linux专题_05】wc -l 命令统计行数为何不准
|
2月前
|
监控 Linux
linux命令之pidstat
linux命令之pidstat
29 2
|
3月前
|
自然语言处理 Linux
linux命令之wc
linux命令之wc
21 1
|
7月前
|
JSON Linux 数据格式
在Linux中如何使用`wc`命令进行字符统计?
在Linux中如何使用`wc`命令进行字符统计?
65 0
在Linux中如何使用`wc`命令进行字符统计?
|
Linux Ubuntu
Linux基础命令---文本统计wc
wc        统计文件的字节数、单词数、行数。        此命令的适用范围:RedHat、RHEL、Ubuntu、CentOS、SUSE、openSUSE、Fedora。1、语法        wc  [选项]  file2、选项列表        --version          ...
999 0
[20180312]iostat显示输出问题.txt
[20180312]iostat显示输出问题.txt --//别人问的问题,使用iostat诊断分析磁盘io. --//如果这样过滤丢失了开头:Device:         rrqm/s   wrqm/s   r/s   w/s    rkB/s    wkB/...
844 0
[20171231]iostat -x命令诊断解析.txt
[20171231]iostat -x命令诊断解析.txt --//使用iostat诊断IO问题,里面的一些输出含义经常忘记,做一个记录: 输出信息的含义 rrqm/s:每秒这个设备相关的读取请求有多少被Merge了(当系统调用需要读取数据的时候,VFS将请求发到各个FS,如果FS发现不同的读         取请求读取的是相同Block的数据,FS会将这个请求合并Merge); wrqm/s:每秒这个设备相关的写入请求有多少被Merge了。
861 0