Linux-pidstat Monitor and Find Statistics for Linux Procesess
来源:互联网 发布:2016年网络流行语大全 编辑:程序博客网 时间:2024/06/06 02:06
pidstat概述
Linux-pidstat监控并统计Linux进程的数据
pidstat命令用来监控被Linux内核管理的独立任务(进程)。它输出每个受内核管理的任务的相关信息。pidstat命令也可以用来监控特定进程的子进程。间隔参数用于指定每次报告间的时间间隔。它的值为0(或者没有参数)说明进程的统计数据的时间是从系统启动开始计算的。
安装pidstat
pidstat 是sysstat软件套件的一部分,sysstat包含很多监控linux系统状态的工具,它能够从大多数linux发行版的软件源中获得。
在Debian/Ubuntu系统中可以使用下面的命令来安装
# apt-get install sysstat
CentOS/Fedora/RHEL版本的linux中则使用下面的命令:
# yum install sysstat
使用pidstat
使用pidstat不加任何参数等价于加上-p参数,但是只有正在活动的任务会被显示出来。
# pidstat
在结果中你能看到如下内容:
- PID - 被监控的任务的进程号
- %usr - 当在用户层执行(应用程序)时这个任务的cpu使用率,和 nice
优先级无关。注意这个字段计算的cpu时间不包括在虚拟处理器中花去的时间。 - %system - 这个任务在系统层使用时的cpu使用率。
- %guest - 任务花费在虚拟机上的cpu使用率(运行在虚拟处理器)。
- %CPU - 任务总的cpu使用率。在SMP环境(多处理器)中,如果在命令行中输入-I参数的话,cpu使用率会除以你的cpu数量。
- CPU - 正在运行这个任务的处理器编号。
- Command - 这个任务的命令名称。
I/O 统计数据
通过使用-d参数来得到I/O的统计数据。比如:
[xgj@entel2 ~]$ pidstat -d -p 2749Linux 3.10.5-3.el6.x86_64 (entel2) 01/19/2017 _x86_64_ (24 CPU)08:20:06 PM PID kB_rd/s kB_wr/s kB_ccwr/s Command08:20:06 PM 2749 0.00 0.00 0.00 mdbJob[xgj@entel2 ~]$
IO 输出会显示一些内的条目:
- kB_rd/s - 任务从硬盘上的读取速度(kb)
- kB_wr/s - 任务向硬盘中的写入速度(kb)
- kB_ccwr/s - 任务写入磁盘被取消的速率(kb)
页面失败和内存使用
使用-r标记你能够得到内存使用情况的数据。
[xgj@entel2 ~]$ pidstat -r -p 2749Linux 3.10.5-3.el6.x86_64 (entel2) 01/19/2017 _x86_64_ (24 CPU)08:21:04 PM PID minflt/s majflt/s VSZ RSS %MEM Command08:21:04 PM 2749 0.00 0.00 1708464 34100 0.03 mdbJob[xgj@entel2 ~]$
重要的条目:
- minflt/s - 从内存中加载数据时每秒出现的小的错误的数目,这些不要求从磁盘载入内存页面。
- majflt/s - 从内存中加载数据时每秒出现的较大错误的数目,这些要求从磁盘载入内存页面。
- VSZ - 虚拟容量:整个进程的虚拟内存使用(kb)
- RSS - 长期内存使用:任务的不可交换物理内存的使用量(kb)
案例
1. 你可以通过使用下面的命令来监测内存使用
# pidstat -r 2 5
这会给你5份关于page faults的统计数据结果,间隔2秒。这将会更容易的定位出现问题的进程。
2. 显示所有mysql服务器的子进程
# pidstat -T CHILD -C OCProLinux 2.6.32-431.el6.x86_64 (centos6.5) 01/20/2017 _x86_64_ (8 CPU)12:40:42 AM PID usr-ms system-ms guest-ms Command12:40:42 AM 22022 3200 3920 0 OCPro12:40:42 AM 22027 3310 4200 0 OCPro12:40:42 AM 22032 3240 4010 0 OCPro12:40:42 AM 22037 3270 4010 0 OCPro12:40:42 AM 22042 3110 3940 0 OCPro
3. 将所有的统计数据结合到一个便于阅读的单一报告中:
# pidstat -urd -h
1 0
- Linux-pidstat Monitor and Find Statistics for Linux Procesess
- Linux SNMP OID’s for CPU,Memory and Disk Statistics
- Linux SNMP OID’s for CPU,Memory and Disk Statistics
- linux《pidstat的使用》
- linux系统分析工具pidstat
- linux命令---pidstat
- Linux多功能诊断器-pidstat
- linux locate and find
- Linux 运行进程实时监控pidstat
- linux系统分析工具之pidstat(七)
- linux中系统性能检测工具pidstat学习
- Linux系统性能分析命令五:pidstat
- Advanced Linux System Statistics and Diagnostics with SystemTap
- linux document and directory find
- Goldengate monitor v11.1 Configure for Linux X86
- monitor linux system
- Linux perf monitor tools
- Monitor进程Linux
- localhost和127.0.0.1都无法打开的解决方法
- matric operation
- 关于如何在make一个Linux下的C/C++工程时,自动添加版本号、编译日期等信息
- Linux(CentOs7)安装jdk
- mIRC_7.47_Incl.Patch_and_Keygen_v1.8_By_URET
- Linux-pidstat Monitor and Find Statistics for Linux Procesess
- 从任何主机都能访问到服务器上的MySql的方法
- c++对一个5位数的任意整数,求出其降序数
- 7.取字符子串函数实现
- LeetCode 389. Find the Difference
- 细说typedf与#define用法以及异同点
- 关于“如何获得页面上元素的背景色”这个奇葩的面试问题
- Django读取Mysql数据并显示在前端
- 如何真正理解Static与Const