linux系统分析工具pidstat

2024-01-06 16:38

本文主要是介绍linux系统分析工具pidstat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

pidstat主要用于监控全部或者指定进程占用系统资源的情况如CPU,内存,设备IO,任务切换,线程等.pidstat首次运行事显示自系统启动开始的各项统计信息,之后运行pidstat将显示自上次运行该命令以后的统计信息.用户可以通过指定统计的此时和时间来获得所需要的统计信息.该命令是sysstat中的工具,想要使用该命令需要先安装sysstat工具.pidstat命令只有在内核版本为2.6.20版本以后执行才有效.

用法:

输入pidstat --help后显示帮助:

[root@centos democlass]# pidstat --help
Usage: pidstat [ options ] [ <interval> [ <count> ] ]
Options are:
[ -C <command> ] [ -d ] [ -h ] [ -I ] [ -l ] [ -r ] [ -t ] [ -u ] [ -V ] [ -w ]
[ -p { <pid> [,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ]

描述:

 The  pidstat  command  is  used  for monitoring individual tasks currently being managed by the Linux kernel.  It writes to standard output activities for every task selected with option -p or for every task managed by the Linux kernel if option -p ALL has been used. Not selecting any tasks is equivalent to specifying -p ALL but  only  active  tasks  (tasks with non-zero statistics values) will appear in the report.

The pidstat command can also be used for monitoring the child processes of selected tasks.  Read about option -T below.

The  interval parameter specifies the amount of time in seconds between each report.  A value of 0 (or no parameters at all) indicates that tasks statistics are to be reported for the time since system startup (boot).  The count parameter can be specified in conjunction with the interval parameter if this one is not set to zero. The value  of  count  determines the number of reports generated at interval seconds apart. If the interval parameter is specified without the count parameter, the pidstat command generates reports continuously.

You can select information about specific task activities using flags.  Not specifying any flags selects only CPU activity.

选项:-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			#命令

示例:

$ pidstat 2 5                        #Display five reports of CPU statistics for every active task in the system at two second intervals.(每隔两秒输出一份报告统计)$ pidstat -r -p 1643 2 5             #Display five reports of page faults and memory statistics for PID 1643 at two second intervals.(每隔两秒显示1643进程的内存信息统计)$ pidstat -C "fox|bird" -r -p ALL    #Display global page faults and memory statistics for all the processes whose command name includes the string "fox" or "bird".$ pidstat -T CHILD -r 2 5            #Display five reports of page faults statistics at two second intervals for the child processes of  all  tasks in the system. Only child processes with non-zero statistics values are displayed.


本文参考(大部分):

http://xuclv.blog.51cto.com/5503169/1166398

同时参考:;林昊的<<java应用>>

这篇关于linux系统分析工具pidstat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/576951

相关文章

python版本切换工具pyenv的安装及用法

《python版本切换工具pyenv的安装及用法》Pyenv是管理Python版本的最佳工具之一,特别适合开发者和需要切换多个Python版本的用户,:本文主要介绍python版本切换工具pyen... 目录Pyenv 是什么?安装 Pyenv(MACOS)使用 Homebrew:配置 shell(zsh

Linux内核定时器使用及说明

《Linux内核定时器使用及说明》文章详细介绍了Linux内核定时器的特性、核心数据结构、时间相关转换函数以及操作API,通过示例展示了如何编写和使用定时器,包括按键消抖的应用... 目录1.linux内核定时器特征2.Linux内核定时器核心数据结构3.Linux内核时间相关转换函数4.Linux内核定时

Linux镜像文件制作方式

《Linux镜像文件制作方式》本文介绍了Linux镜像文件制作的过程,包括确定磁盘空间布局、制作空白镜像文件、分区与格式化、复制引导分区和其他分区... 目录1.确定磁盘空间布局2.制作空白镜像文件3.分区与格式化1) 分区2) 格式化4.复制引导分区5.复制其它分区1) 挂载2) 复制bootfs分区3)

Python+wxPython开发一个文件属性比对工具

《Python+wxPython开发一个文件属性比对工具》在日常的文件管理工作中,我们经常会遇到同一个文件存在多个版本,或者需要验证备份文件与源文件是否一致,下面我们就来看看如何使用wxPython模... 目录引言项目背景与需求应用场景核心需求运行结果技术选型程序设计界面布局核心功能模块关键代码解析文件大

Linux服务器数据盘移除并重新挂载的全过程

《Linux服务器数据盘移除并重新挂载的全过程》:本文主要介绍在Linux服务器上移除并重新挂载数据盘的整个过程,分为三大步:卸载文件系统、分离磁盘和重新挂载,每一步都有详细的步骤和注意事项,确保... 目录引言第一步:卸载文件系统第二步:分离磁盘第三步:重新挂载引言在 linux 服务器上移除并重新挂p

Linux下屏幕亮度的调节方式

《Linux下屏幕亮度的调节方式》文章介绍了Linux下屏幕亮度调节的几种方法,包括图形界面、手动调节(使用ACPI内核模块)和外接显示屏调节,以及自动调节软件(CaliseRedshift和Reds... 目录1 概述2 手动调节http://www.chinasem.cn2.1 手动屏幕调节2.2 外接显

Linux(centos7)虚拟机没有IP问题及解决方案

《Linux(centos7)虚拟机没有IP问题及解决方案》文章介绍了在CentOS7中配置虚拟机网络并使用Xshell连接虚拟机的步骤,首先,检查并配置网卡ens33的ONBOOT属性为yes,然后... 目录输入查看ZFhrxIP命令:ip addr查看,没有虚拟机IP修改ens33配置文件重启网络Xh

linux实现对.jar文件的配置文件进行修改

《linux实现对.jar文件的配置文件进行修改》文章讲述了如何使用Linux系统修改.jar文件的配置文件,包括进入文件夹、编辑文件、保存并退出编辑器,以及重新启动项目... 目录linux对.jar文件的配置文件进行修改第一步第二步 第三步第四步总结linux对.jar文件的配置文件进行修改第一步进

linux ssh如何实现增加访问端口

《linuxssh如何实现增加访问端口》Linux中SSH默认使用22端口,为了增强安全性或满足特定需求,可以通过修改SSH配置来增加或更改SSH访问端口,具体步骤包括修改SSH配置文件、增加或修改... 目录1. 修改 SSH 配置文件2. 增加或修改端口3. 保存并退出编辑器4. 更新防火墙规则使用uf

Linux join命令的使用及说明

《Linuxjoin命令的使用及说明》`join`命令用于在Linux中按字段将两个文件进行连接,类似于SQL的JOIN,它需要两个文件按用于匹配的字段排序,并且第一个文件的换行符必须是LF,`jo... 目录一. 基本语法二. 数据准备三. 指定文件的连接key四.-a输出指定文件的所有行五.-o指定输出