Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and use the Linux pidstat command

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge points about how to install and use the Linux pidstat command. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Pidstat is a command of the sysstat tool, which is used to monitor the utilization of system resources such as cpu, memory, threads, device IO, etc., of all or specified processes. The first time pidstat runs, it displays statistics from the start of the system, and then running pidstat displays statistics since the last time the command was run. Users can obtain the required statistics by specifying the number and time of statistics.

How to install pidstat

Pidstat is part of the sysstat software suite, and sysstat contains a number of tools for monitoring the status of linux systems, which are available from software sources in most linux distributions.

On a Debian/Ubuntu system, you can use the following command to install

# apt-get install sysstat

The following command is used in the CentOS/Fedora/RHEL version of linux:

# yum install sysstat

Use pidstat

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

# pidstat

You can see the following in the results:

PID-process number of the task being monitored

% usr-the cpu usage of this task when executed at the user level (application) is independent of nice priority. Note that the cpu time calculated in this field does not include the time spent in the virtual processor.

% system-cpu usage when this task is used at the system level.

% guest-the cpu usage of the task spent on the virtual machine (running on the virtual processor).

% CPU-Total cpu usage of the task. In a SMP environment (multiprocessor), if you enter the-I parameter on the command line, cpu usage is divided by your number of cpu.

CPU-the number of the processor on which this task is running.

Command-the command name for this task.

Ipaw O statistics

Use the-d parameter to get the statistics of Igamot O. For example:

# pidstat-d-p 8472

The IO output shows some entries within:

KB_rd/s-the speed at which the task reads from the hard drive (kb)

KB_wr/s-Speed at which the task writes to the hard disk (kb)

KB_ccwr/s-rate at which task writes to disk are canceled (kb)

Page failure and memory usage

You can get data on memory usage using the-r flag.

Important entries:

Minflt/s-the number of small errors per second when loading data from memory, which do not require memory pages to be loaded from disk.

Majflt/s-the number of large errors per second when loading data from memory, which requires memory pages to be loaded from disk.

VSZ-Virtual capacity: virtual memory usage (kb) for the entire process

RSS-long-term memory usage: task's non-exchangeable physical memory usage (kb)

Give an example

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

# pidstat-r 2 5

This will give you five statistics on page faults, with an interval of 2 seconds. This will make it easier to locate the process in question.

two。 Show the child processes of all mysql servers

# pidstat-T CHILD-C mysql

3. Combine all the statistics into a single easy-to-read report:

# pidstat-urd-h

These are all the contents of the article "how to install and use Linux pidstat commands". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report