Using Pidstat to view process resource usage

Source: Internet
Author: User
Tags cpu usage

Using Pidstat to view process resource usage Introduction

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:

linux:~ # Pidstat

Linux 2.6.32.12-0.7-default (Linux) 06/18/12 _x86_64_

11:37:19 PID%usr%system%guest%cpu CPU Command

...... 11:37:19 11452 0.00 0.00 0.00 0.00 2 Bash11:37:19 11509 0.00 0.00 0.00 0.00 3 DD

The above output, in addition to the first line showing the kernel version, host name, date and CPU architecture, the main column meaning is as follows:

· 11:37:19:pidstat get information point in time

· PID: Process PID

· %USR: CPU time ratio of process running in user state

· %system: CPU time ratio of the process running in the kernel state

· %CPU: CPU time ratio of process run

· CPU: Indicates which core the process is running on

· Command: Pull up the commands corresponding to the process

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:

Pidstat 2 10

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-P 13084 1

Linux 2.6.32.12-0.7-default (Linux) 06/18/12 _x86_64_

15:08:18 PID minflt/s majflt/s VSZ RSS%MEM command15:08:19 13084 133835.00 0.00 15720284 15716896 96 . mmmm15:08:20 13084 35807.00 0.00 15863504 15849756 97.07 mmmm15:08:21 13084 19273.87 0.00 15949040 15792944 96.72 m Mmm

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 number of pages fault generated by the physical memory address

MAJFLT/S: The number of Main page faults per second (Major page faults), when the virtual memory address is mapped to a physical memory address, the corresponding pages in the swap, such page fault is major page fault, generally in memory use tension generated

VSZ: Virtual memory (in kilobytes) used by the process

RSS: The amount of physical memory (in kilobytes) used by the process%MEM: The percentage of memory used by the process

Command: Pull up the commands corresponding to the process

IO Case Statistics (-D)


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

linux:~ # pidstat-d 1 2

Linux 2.6.32.12-0.7-default (Linux) 06/18/12 _x86_64_

17:11:36 PID kb_rd/s kb_wr/s kb_ccwr/s command17:11:37 14579 124988.24 0.00 0.00 DD

17:11:37 PID kb_rd/s kb_wr/s kb_ccwr/s command17:11:38 14579 105441.58 0.00 0.00 DD

Output message Meaning

KB_RD/S: The amount of data (in kilobytes) that the process reads from disk per second

KB_WR/S: The amount of data (in kilobytes) that the process writes to disk per second

Command: Pull up the commands corresponding to the process

For specific process statistics (-p)

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

linux:~ # Pidstat-r-P 1 1

Linux 2.6.32.12-0.7-default (Linux) 06/18/12 _x86_64_

18:26:17 PID minflt/s majflt/s VSZ RSS%MEM command18:26:18 1 0.00 0.00 10380 640 0.00 Init18:26:19 1 0.00 0.00 10380 640 0.00 Init

......

pidstat Common Commands

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

Pidstat-u 1

Pidstat-r 1

Pidstat-d 1

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


Using Pidstat to view process resource usage

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.