Process real-time monitoring Pidstat command detailed

Source: Internet
Author: User

Pidstat is primarily used to monitor all or specified processes that consume system resources, such as CPU, memory, device IO, task switching, threading, and so on. Pidstat displays statistics from the start of the system startup at the first run, and then runs Pidstat displays statistics from the last time the command was run. Users can obtain the required statistics by specifying the number and time of the statistics.

Example Explanation

Default parameters

Executes Pidstat, which outputs the CPU statistics for all active processes after the system is started:

$ pidstat1Linux3.13.0- the-generic (TITANCLUSTERS-XXXXX) -/ -/ -_x86_64_ ( +CPU) -: A: GenevaPM UID PID%usr%system%guest%CPU CPU Command -: A:GenevaPm0 9 0.00 0.94 0.00 0.94 1rcuos/0 -: A:GenevaPm0 4214 5.66 5.66 0.00 11.32  themesos-slave -: A:GenevaPm0 4354 0.94 0.94 0.00 1.89 8Java -: A:GenevaPm0 6521 1596.23 1.89 0.00 1598.11  -Java -: A:GenevaPm0 6564 1571.70 7.55 0.00 1579.25  -Java -: A:GenevaPm60004 60154 0.94 4.72 0.00 5.66 9Pidstat -: A:GenevaPM UID PID%usr%system%guest%CPU CPU Command -: A:GenevaPm0 4214 6.00 2.00 0.00 8.00  themesos-slave -: A:GenevaPm0 6521 1590.00 1.00 0.00 1591.00  -Java -: A:GenevaPm0 6564 1573.00 10.00 0.00 1583.00  -Java -: A:GenevaPm108 6718 1.00 0.00 0.00 1.00 0snmp-Pass -: A:GenevaPm60004 60154 1.00 4.00 0.00 5.00 9Pidstat

The PIDSTAT command outputs the CPU usage of the process, which continues to output and does not overwrite previous data, allowing for easy observation of system dynamics. As shown on the output, you can see that two Java processes consume nearly 1600% of the CPU time, consuming approximately 16 CPU cores of computing resources.

Specify sampling period and number of samples

The Pidstat command specifies the sampling period and the number of samples, the command is "pidstat [option] interval [count]", and the following Pidstat outputs 10 CPU usage statistics with a 2-second sampling period:

2 Ten

CPU Usage statistics (-u)

With the-u option, Pidstat displays the CPU usage statistics for each active process, performing "Pidstat-u" the same as performing "Pidstat" alone.

Memory usage statistics (-R)

Using the-r option, Pidstat displays the memory usage statistics for each active process:

linux:~ # Pidstat-r-P13084 1Linux2.6.32.12-0.7-default(Linux) ./ -/ A_x86_64_ the: ,: -PID minflt/s majflt/s VSZ RSS%MEM Command the: ,: +        13084 133835.00      0.00 15720284 15716896  96.26MMMM the: ,: -        13084  35807.00      0.00 15863504 15849756  97.07MMMM the: ,: +        13084  19273.87      0.00 15949040 15792944  96.72Mmmm

The output of the above columns has the following meanings:

minflt/S: Number of page faults per second (minor page faults), number of times page faults means that the virtual memory address is mapped to the physical memory address to produce the page fault times Majflt/S: Number of main faults per second ( Major page faults), when a virtual memory address is mapped to a physical memory address, the corresponding page is in swap, and the page fault is major page fault, typically generating a vsz when memory usage is tense:      the virtual memory used by the process ( In kilobytes (KB) RSS: The amount of      physical memory (in kilobytes)that the process uses: The     percentage of memory that the process uses to  command: Pull up the commands for the process

IO Case Statistics (-D)


With the-D option, we can view the statistics for process IO:

linux:~ # pidstat-d1 2Linux2.6.32.12-0.7-default(Linux) ./ -/ A_x86_64_ -: One: $PID kb_rd/s kb_wr/s kb_ccwr/s Command -: One:Panax Notoginseng        14579 124988.24      0.00      0.00DD -: One:Panax NotoginsengPID kb_rd/s kb_wr/s kb_ccwr/s Command -: One: -        14579 105441.58      0.00      0.00Dd

Output message Meaning

kb_rd/S: The amount of data read by the process from disk per second (in kilobytes) KB_WR/S: The amount of data (in kilobytes) that the process writes to disk per second command: The commands that pull up the process

For specific process statistics (-p)

With the-P option, we can view system resource usage for a particular process:

linux:~ # Pidstat-r-P1 1Linux2.6.32.12-0.7-default(Linux) ./ -/ A_x86_64_ -: -: -PID minflt/s majflt/s VSZ RSS%MEM Command -: -: -            1      0.00      0.00   10380    640   0.00Init -: -: +            1      0.00      0.00   10380    640   0.00init ...
Pidstat Common Commands

When using Pidstat for problem targeting, the following commands are often used:

111

The above command takes 1 seconds for the information acquisition cycle, respectively, to obtain the CPU, memory and disk IO statistics.

Process real-time monitoring Pidstat command detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.