Using pidstat to view the usage of process resources introduction many tools provide you with methods to view the usage of system resources from the device perspective. For example, use iostat to View disk io statistics: linux :~ # Iostat-d3Device: tpsBlk_read... use pidstat to view process resource usage introduction many tools provide us with a way to view system resource usage from a device perspective. For example, use iostat to View disk io statistics: linux :~ # Iostat-d 3 Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtnsda 1.67 0.00 40.00 120 or above displays the statistical results from the sda perspective. Is there any way to view the usage of system resources by each process from the process perspective? The pidstat tool can be used to obtain statistics of the cpu, memory, disk, and other system resources used by each process. pidstat is provided by the sysstat rpm package and can be used in suse11. Next, let's take a look at the specific usage of pidstat. By default, pidstat is run, and cpu statistics of all active processes after the system is started are output: linux :~ # PidstatLinux 2.6.32.12-0.7-default (linux) 06/18/12 _ x86_64 _ 11:37:19 PID % usr % system % guest % 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 and above, except for the first line displaying the kernel version, host name, date, and cpu architecture, the main column meanings are as follows: 11: 37: 19: pidstat acquisition information time point PID: process pid % usr: cpu time ratio of processes in user-mode running % system: cpu usage rate of processes in kernel mode % CPU: cpu usage rate of processes running CPU: indicates the core in which the process runs Command: the default output of executing pidstat for commands corresponding to pulling processes is the statistical information from the system startup to the execution time. Therefore, even if the cpu usage of a process is very high, the output value may still be 0. You can also specify the sampling period and number of times for the pidstat command like the sar and iostat commands. the command format is "pidstat [option] interval [count]". the following pidstat output takes 2 seconds as the sampling period and outputs two cpu usage statistics: linux :~ # Pidstat 2 2 Linux 2.6.32.12-0.7-default (linux) 06/18/12 _ x86_64 _ 14:40:39 PID % usr % system % guest % CPU Command14: 40: 41 9567 0.50 1.49 0.00 1.98 2 atop14: 40: 41 12405 0.00 0.50 0.00 6 pidstat 14:40:41 PID % usr % system % guest % CPU Command14: 40: 43 7830 0.50 0.50 0.00 1.00 7 runHpiAlarm14: 40: 43 12405 0.00 1.00 0.00 1.00 6 pidstat if count is not specified, pidstat will always output statistics. Cpu usage statistics (-u) use the-u option. pidstat displays the cpu usage statistics of each active process. The effect of executing "pidstat-u" is the same as that of executing "pidstat" separately. Memory usage statistics (-r) using the-r option, pidstat displays the memory usage statistics of various active processes: 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.26 mmmm15: 08: 20 13084 35807.00 0.00 15863504 15849756 97.07 mmmm15: 08: 21 13084 19273.87 0.00 15949040 15792944 mmmm the output of each column is described as follows: minflt/s: the number of page missing errors per second (minor page faults). The number of page missing errors means that the virtual memory address is mapped to the page fault generated by the physical memory address. majflt/s: Number of master page missing errors (major page faults) per second. when the virtual memory address is mapped to the physical memory address, the corresponding page is in swap. such a page fault is major page fault, VSZ is generally generated when the memory usage is insufficient: the virtual memory used by the process (in kB) RSS: the physical memory used by the process (in kB) % MEM: memory usage percentage of the process Command: pull the Command IO statistics corresponding to the process (-d) use the-d option, we can view the process IO statistics: 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 dd 17:11:37 PID kB_rd/s kB_wr/s kB_ccwr/s Command17: 11: 38 0.00 14579 105441.58 dd the main output meanings are as follows: kB_rd/s: data Volume read by processes from the disk per second (in kB) kB_wr/s: the data volume written by processes to the disk per second (in kB) Command: use the-p option to collect statistics on specific processes. you can view the system resource usage of specific processes: linux :~ # Pidstat-r-p 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 init ...... The above pidstat command takes 1 second as the sampling interval to view the memory usage of the init process. When pidstat is commonly used to locate a problem, the following commands are often used: pidstat-u 1 pidstat-r 1 pidstat-d 1 or more commands take 1 second as the information collection cycle, obtain the cpu, memory, and disk IO Statistics respectively.
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.