`
扫地僧
  • 浏览: 29917 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论
阅读更多

简介:

Linux上可以使用sysstat包(可能需要自己安装)中的pidstat监控JAVA应用的让步式上下文切换和抢占式上下文切换。让步式上下文切换是指执行线程主动释放CPU,抢占式上下文切换是指线程因为分配的时间片用尽而被迫放弃CPU或被其他优先级更高的线程所抢占。

应用中挂起和唤醒线程会导致操作系统的让步式上下文切换,因此锁竞争严重的应用会表现出大量的让步式上下文切换,而让步式上下文切换耗费的时钟周期代价非常高。

抢占式上下文切换率高表明预备运行的线程数多于可用的虚拟处理器,所以此时用vmstat通常能看到很长的运行队列、很高的CPU使用率。

 

pidstat - Report statistics for Linux tasks. 

Linux任务的统计数据。

 

SYNOPSIS

pidstat [ -d ] [ -h ] [ -I ] [ -l ] [ -R ] [ -r ] [ -s ] [ -t ] [ -U [ username ] ] [ -u ] [ -V ] [ -v ] [ -w ] [ -C comm ] [ -G process_name ] [ -p { pid [,...] | SELF | ALL } ] [ -T { TASK | CHILD | ALL } ] [ interval [ count ] ]

 

DESCRIPTION

pidstat命令用来监控Linux内核管理的各个任务。它将使用-p选项指定的每个任务的活动情况输出到标准输出,可以使用-p All输出Linux内核管理的所有任务。不使用-p等同于-p ALL,但是只有活动的任务会出现在报告中。

pidstat命令也可以用来监控所选择任务的子进程。参考-T选项了解更多。

 

OPTIONS

-C comm

Display only tasks whose command name includes the string comm. This string can be a regular expression.

只展示命令名称包含字符串comm的任务。comm可以是正则表达式。

 

-d

Report I/O statistics (kernels 2.6.20 and later only). The following values may be displayed:

报告I/O统计数据(内核2.6.20或更高)。以下值将被展示:

 

UID

The real user identification number of the task being monitored.

被监控任务的用户id。

 

USER

The real user name of the task being monitored.

被监控任务的用户名。

 

PID

The identification number of the task being monitored.

被监控任务的PID。

 

kB_rd/s

Number of kilobytes the task has caused to be read from disk per second.

任务每秒从磁盘读取的数据,以kb为单位。

kB_wr/s

Number of kilobytes the task has caused, or shall cause to be written to disk per second.

任务每秒从磁盘写入或将要写入的数据,以kb为单位

kB_ccwr/s

Number of kilobytes whose writing to disk has been cancelled by the task. This may occur when the task truncates some dirty pagecache. In this case, some IO which another task has been accounted for will not be happening.

任务取消的写入磁盘的kb数。在任务压缩脏页缓存时可能发生这种情况。在这种情况下,其他任务发起的IO不会处理。

iodelay

Block I/O delay of the task being monitored, measured in clock ticks. This metric includes the delays spent waiting for sync block I/O completion and for swapin block I/O completion.

任务的I/O阻塞延迟,以时钟周期为单位。包括同步块I/O和换入块I/O。

Command

The command name of the task.

任务的命令名。

 

-G process_name

Display only processes whose command name includes the string process_name. This string can be a regular expression. If option -t is used together with option -G then the threads belonging to that process are also displayed (even if their command name doesn't include the string process_name).

 

 

-h

Display all activities horizontally on a single line. This is intended to make it easier to be parsed by other programs.

一行中展示所有的统计。便于其他程序解析。

-I

In an SMP environment, indicate that tasks CPU usage (as displayed by option -u ) should be divided by the total number of processors.

在SMP环境中,指示任务的CPU利用率(使用-u选项)应该除以处理器数目。

 

-p { pid [,...] | SELF | ALL }

Select tasks (processes) for which statistics are to be reported. pid is the process identification number. The SELF keyword indicates that statistics are to be reported for the pidstat process itself, whereas the ALL keyword indicates that statistics are to be reported for all the tasks managed by the system.

指定需要监控监控的任务。SELF表示监控pidstat进程自己,ALL表示监控所有的进程。

-R

Report realtime priority and scheduling policy information. The following values may be displayed:

报告实时优先级和调度策略信息。

UID

The real user identification number of the task being monitored.

 

USER

The name of the real user owning the task being monitored.

 

PID

The identification number of the task being monitored.

 

prio

The realtime priority of the task being monitored.

任务的实时优先级。

policy

The scheduling policy of the task being monitored.

被监控的任务的调度策略

Command

The command name of the task.

 

-r

Report page faults and memory utilization.

When reporting statistics for individual tasks, the following values may be displayed:

报告页错误和内存利用率。

UID

The real user identification number of the task being monitored.

 

USER

The real user name of the task being monitored.

 

PID

The identification number of the task being monitored.

minflt/s

Total number of minor faults the task has made per second, those which have not required loading a memory page from disk.

任务造成的小错误的总数。小错误指的是还不需要从磁盘中加载一个内存页。

majflt/s

Total number of major faults the task has made per second, those which have required loading a memory page from disk.

任务造成的大错误的总数。大错误指的是需要从磁盘中加载一个内存页。

 

VSZ

Virtual Size: The virtual memory usage of entire task in kilobytes.

虚拟大小:整个任务使用的虚拟内存大小,以kb为单位。

RSS

Resident Set Size: The non-swapped physical memory used by the task in kilobytes.

任务使用的没有被交换的物理内存,以kb为单位

%MEM

The tasks's currently used share of available physical memory.

任务占用的可用物理内存的比例。

 

Command

The command name of the task.

 

When reporting global statistics for tasks and all their children, the following values may be displayed:

 

UID

The real user identification number of the task which is being monitored together with its children.

 

USER

The real user name of the task which is being monitored together with its children.

 

PID

The identification number of the task which is being monitored together with its children.

 

minflt-nr

Total number of minor faults made by the task and all its children, and collected during the interval of time.

 

majflt-nr

Total number of major faults made by the task and all its children, and collected during the interval of time.

 

Command

The command name of the task which is being monitored together with its children.

 

-s

Report stack utilization. The following values may be displayed:

报告栈利用率。

UID

The real user identification number of the task being monitored.

 

USER

The real user name of the task being monitored.

 

PID

The identification number of the task being monitored.

 

StkSize

The amount of memory in kilobytes reserved for the task as stack, but not necessarily used.

该任务保留的栈大小,以kb为单位。

StkRef

The amount of memory in kilobytes used as stack, referenced by the task.

该任务使用的栈大小,以kb为单位,被任务引用。

 

Command

The command name of the task.

 

-T { TASK | CHILD | ALL }

This option specifies what has to be monitored by the pidstat command. The TASK keyword indicates that statistics are to be reported for individual tasks (this is the default option) whereas the CHILD keyword indicates that statistics are to be globally reported for the selected tasks and all their children. The ALLkeyword indicates that statistics are to be reported for individual tasks and globally for the selected tasks and their children.

Note: Global statistics for tasks and all their children are not available for all options of pidstat. Also these statistics are not necessarily relevant to current time interval: The statistics of a child process are collected only when it finishes or it is killed.

该选项指定pidstat命令要监控的内容。

-t

Also display statistics for threads associated with selected tasks.

This option adds the following values to the reports:

显示任务关联的线程的统计数据。

 

TGID

The identification number of the thread group leader.

线程组leader的表示

 

TID

The identification number of the thread being monitored.

线程id

 

-U [ username ]

Display the real user name of the tasks being monitored instead of the UID. If username is specified, then only tasks belonging to the specified user are displayed.

指定某个用户的任务。

-u

Report CPU utilization.

When reporting statistics for individual tasks, the following values may be displayed:

报告CPU利用率

UID

The real user identification number of the task being monitored.

 

USER

The real user name of the task being monitored.

 

PID

The identification number of the task being monitored.

%usr

Percentage of CPU used by the task while executing at the user level (application), with or without nice priority. Note that this field does NOT include time spent running a virtual processor.

%system

Percentage of CPU used by the task while executing at the system level (kernel).

 

%guest

Percentage of CPU spent by the task in virtual machine (running a virtual processor).

执行虚拟进程的CPU百分比

%CPU

Total percentage of CPU time used by the task. In an SMP environment, the task's CPU usage will be divided by the total number of CPU's if option -I has been entered on the command line.

任务消耗的CPU总百分比。

CPU

Processor number to which the task is attached.

Command

The command name of the task.

 

When reporting global statistics for tasks and all their children, the following values may be displayed:

 

UID

The real user identification number of the task which is being monitored together with its children.

 

USER

The real user name of the task which is being monitored together with its children.

 

PID

The identification number of the task which is being monitored together with its children.

 

usr-ms

Total number of milliseconds spent by the task and all its children while executing at the user level (application), with or without nice priority, and collected during the interval of time. Note that this field does NOT include time spent running a virtual processor.

 

system-ms

Total number of milliseconds spent by the task and all its children while executing at the system level (kernel), and collected during the interval of time.

 

guest-ms

Total number of milliseconds spent by the task and all its children in virtual machine (running a virtual processor).

 

Command

The command name of the task which is being monitored together with its children.

-V

Print version number then exit.

 

-v

Report values of some kernel tables. The following values may be displayed:

报告some kernel tables的值。

UID

The real user identification number of the task being monitored.

 

USER

The name of the real user owning the task being monitored.

 

PID

The identification number of the task being monitored.

 

threads

Number of threads associated with current task.

当前任务相关的线程数

fd-nr

Number of file descriptors associated with current task.

当前任务关联的文件描述符个数。

Command

The command name of the task.

 

-w

Report task switching activity (kernels 2.6.23 and later only). The following values may be displayed:

报告任务上下文切换的活动状态

 

UID

The real user identification number of the task being monitored.

 

USER

The real user name of the task being monitored.

 

PID

The identification number of the task being monitored.

 

cswch/s

Total number of voluntary context switches the task made per second. A voluntary context switch occurs when a task blocks because it requires a resource that is unavailable.

任务每秒主动式上下文切换的次数

nvcswch/s

Total number of non voluntary context switches the task made per second. A involuntary context switch takes place when a task executes for the duration of its time slice and then is forced to relinquish the processor.

任务每秒抢占式上下文切换的总次数。

Command

The command name of the task.

ENVIRONMENT

The pidstat command takes into account the following environment variable: 

 

S_TIME_FORMAT

If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The pidstat command will use the ISO 8601 format (YYYY-MM-DD) instead.

 

EXAMPLES

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.

 

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.

 

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".

分享到:
评论

相关推荐

    Linux如何安装使用pidstat命令以对进程数据进行监控.docx

    Linux 中使用 pidstat 命令对进程数据进行监控 在 Linux 系统中,对进程数据进行监控是非常重要的,pidstat 命令就是其中的...如果您还想了解更多的 Linux 系统监控命令,详见系统之家 Linux 系统监控要用到哪些命令?

    常用的linux系统监控命令整理.docx

    以下是一些常用的Linux系统监控命令,它们可以帮助我们追踪CPU使用、内存消耗、网络活动以及存储I/O等关键性能指标。 1. **`ps` 命令**: `ps -mp pid -o THREAD,tid,time` 或 `ps -Lfp pid` 用于找出占用CPU最多...

    linux性能调优.pdf

    在Linux系统中,性能调优是一项关键的任务,它涉及到系统的高效运行和稳定性能。本文将深入探讨性能指标、系统变慢的原因以及上下文切换的概念,这些都是优化Linux性能的关键点。 性能指标是衡量系统效率的标准,...

    Linux系统命令与网络、磁盘参数和日志监控-课件1

    【Linux系统命令与网络、磁盘参数和日志监控】这一课件主要涵盖了Linux系统管理中的核心知识,包括基础命令的使用、系统性能监控以及优化方法。以下是详细的知识点解析: 1. **Linux基础命令和工具**:这些是日常...

    Linux系统运行时参数命令、网络、磁盘参数和日志监控.pdf

    【Linux系统运行时参数命令、网络、磁盘参数和日志监控】 在Linux系统管理中,了解并熟练运用各种命令是至关重要的。本课程重点涵盖了Linux基础命令、系统性能监控,特别是CPU、内存、磁盘I/O以及网络性能的监控。...

    linux监控常用命令总结

    ### Linux监控常用命令知识点 #### 1. `free` 命令 `free` 命令用于显示系统中的内存使用情况。该命令提供了多种选项来调整输出格式,以便更好地理解和监控系统的内存使用。 - `-b`: 以字节(Byte)为单位显示内存...

    sysstat-12.5.3.tar.gz

    《sysstat-12.5.3:Linux系统性能监控工具的源码解析》 sysstat-12.5.3.tar.gz是一个包含了一系列用于Linux系统性能监控的开源工具的源码包。这个包中最核心的组件有cifsiostat、iostat、mpstat、pidstat、sadf、...

    sysstat-11.7.3.tar,gz

    sysstat是一个在Linux系统中广泛使用的性能监控工具,它提供了丰富的功能,帮助管理员对系统进行深入的性能分析。标题中的"sysstat-11.7.3.tar.gz"是一个压缩包,包含了sysstat工具的11.7.3版本,这个版本经过实际...

    Linux_常用命令全集[文字版]

    - 系统监控命令:如top, htop, iotop, pidstat等。 由于文档是文字版的命令全集,因此在使用时,用户可以通过文本搜索的方式快速定位到感兴趣的命令及其说明,进而了解其用法和相关的选项参数。这无疑为Linux用户和...

    Linux性能测试指令集.rar

    了解并熟练使用这些命令,可以有效地监控和分析Linux系统的性能,找出可能的瓶颈,从而优化系统配置和提升运行效率。通过"Linux性能测试常用指令集(一).doc"文档,你可以获得更具体的使用方法和案例分析,进一步...

    linux sysstat

    Linux Sysstat是一个强大的...综上所述,Linux Sysstat是一个不可或缺的系统监控工具,它提供的各种统计信息对于理解、调试和优化Linux系统的性能至关重要。无论是日常运维还是故障排查,sysstat都能提供有力的支持。

    20200630_性能分析工具说明(内存、CPU性能相关).pdf

    熟练掌握和使用这些工具,有助于有效地监控、诊断和优化Linux系统的性能问题。在使用这些工具时,通常需要对Linux系统有较深的理解,包括操作系统的工作原理、内存管理、进程调度等方面的知识。通过这些性能分析工具...

    sysstat-9.1.7.tar.bz2

    sysstat-9.1.7.tar.bz2 是一个包含了多种系统性能监控工具的压缩包,主要用于Linux系统的性能分析和诊断。这个包中包含的工具,如sar、pidstat、iostat、mpstat、sadf和sadc,都是sysstat套件的重要组成部分,它们在...

    Linux性能测试工具

    "Linux系统参数说明.pdf"可能详细介绍了这些参数的含义和调整方法,包括内存管理、调度策略、网络配置等方面的参数。"Linux性能测试工具.pdf"和"linux性能优化和分析.ppt"可能提供了更深入的工具使用教程和案例分析...

    Linux下如何查看某一进程的CPU占用率_linux进程cpu使用率.zip

    了解了这些工具后,我们就能有效地监控Linux系统中任意进程的CPU占用率,从而对系统的性能进行优化和调试。在处理性能问题时,结合`iostat`(磁盘I/O统计)和`vmstat`(虚拟内存统计)等工具,能帮助我们获得更全面...

    SUSE 12 SP1 System Analysis and Tuning Guide.pdf

    整体来看,该指南为管理员提供了一套全面的系统监控、分析及调优工具和方法,帮助他们在日常工作中更高效地维护和提升系统性能。文档内容详实,包括了对各种监控工具的介绍和使用方法,对于那些需要深入理解和解决...

    sysstat-9.1.1.tar

    通过学习sysstat的源代码,不仅可以提升shell脚本和C语言编程能力,还能深入理解Linux系统监控机制,对于系统管理员和性能优化工程师来说,这是提升专业技能的重要途径。同时,这个过程也能帮助我们更好地理解和利用...

Global site tag (gtag.js) - Google Analytics