Pidstat-monitors and counts Linux Process Data

Source: Internet
Author: User

Pidstat-monitors and counts Linux Process Data

The pidstat command is used to monitor independent tasks (processes) managed by the Linux kernel ). It outputs information about each task managed by the kernel. The pidstat command can also be used to monitor sub-processes of a specific process. The interval parameter is used to specify the interval between each report. The value 0 (or no parameter) indicates that the statistical time of the process is calculated from the start of the system.

How to install pidstat

Pidstat is part of the sysstat software suite. sysstat contains many tools that monitor the status of linux systems and can be obtained from most software sources in linux releases.

In Debian/Ubuntu, you can use the following command to install

  1. # Apt-get install sysstat

In CentOS/Fedora/RHEL linux, run the following command:

  1. # Yum install sysstat
Use pidstat

Using pidstat without any parameters is equivalent to adding the-p parameter, but only active tasks are displayed.

  1. # Pidstat

You can see the following content in the result:

  • PID-process ID of the monitored task
  • % Usr-the cpu usage of the task when the application is executed at the user layer, regardless of the nice priority. Note that the cpu time calculated by this field does not include the time spent in the virtual processor.
  • % System-cpu usage of this task at the system layer.
  • % Guest-cpu usage (running on the virtual processor) of the task on the virtual machine ).
  • % CPU-total cpu usage of the task. In the SMP environment (multi-processor), if you enter the-I parameter in the command line, the cpu usage will be divided by the number of your CPUs.
  • CPU-the number of the processor that is running the task.
  • Command-Command name of the task.
I/O statistics

Use the-d parameter to obtain the I/O statistics. For example:

  1. # Pidstat-d-p 8472

IO output will display some internal entries:

  • KB_rd/s-read speed of the task from the hard disk (kb)
  • KB_wr/s-write speed (kb) of the task to the hard disk)
  • KB_ccwr/s-speed at which the task is written to the disk canceled (kb)
Page failure and memory usage

Use-r to mark the data that you can get memory usage.

Important entries:

  • Minflt/s-the number of small errors that occur every second when loading data from the memory. These do not require loading the memory page from the disk.
  • Majflt/s-the number of large errors that occur per second when loading data from the memory. These requests are loaded into the memory page from the disk.
  • VSZ-virtual capacity: virtual memory usage of the entire process (kb)
  • RSS-long-term memory usage: The amount of physical memory that cannot be exchanged for tasks (kb)
Example

1. You can monitor memory usage by using the following command

  1. # Pidstat-r 2 5

This will give you 5 statistical results about page faults at an interval of 2 seconds. This will make it easier to locate the problematic process.

2. display the sub-processes of all mysql servers

  1. # Pidstat-t child-C mysql

3. Integrate all the statistical data into a single report that is easy to read:

  1. # Pidstat-urd-h

This article permanently updates the link address:

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.