Linux Performance Monitoring Commands
Posted 每天更强一点...
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Performance Monitoring Commands相关的知识,希望对你有一定的参考价值。
Reference
[1] http://www.thegeekstuff.com/2011/07/iostat-vmstat-mpstat-examples/?utm_source=feedburner
[2] https://www.computerhope.com/unix/iostat.htm
[3] https://www.lifewire.com/linux-system-running-uptime-3867758
uptime and w report how long the system has been running and the load average
iostat reports CPU, disk I/O, and NFS statistics.
vmstat reports virtual memory statistics.
mpstat reports processors statistics
uptime
[email protected]7010:~$ uptime 11:07:59 up 9 days, 18:46, 1 user, load average: 0.23, 0.51, 0.59
The default output for the uptime command is as follows:
-
The current time
-
How long the system has been running
-
How many users are logged in
-
The load average for the past 1, 5 and 15 minutes
The load averages show the average number of processes that are in a runnable or uninterruptable state.
w
[email protected]7010:~$ w 11:10:16 up 9 days, 18:48, 1 user, load average: 1.17, 0.64, 0.62 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT chizhang tty7 :0 16Jun17 9days 2:09m 0.46s /sbin/upstart --user
The output from the w command is as follows:
-
user
-
tty
-
from
-
login time
-
idle time
-
JCPU
-
PCPU
-
WHAT
The w command shows more than just the current uptime. It shows who is logged in and what they are currently doing.
The JCPU is the time used by all processes attached to the terminal and the PCPU shows the time used by the current process in the WHAT column.
iostat
The iostat command generates three types of reports: the CPU Utilization report, the Device Utilization report and the Network Filesystem report.
[email protected]7010:~$ iostat Linux 4.4.0-79-generic (chizhang-OptiPlex-7010) 26/06/17 _x86_64_ (8 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 1.47 0.00 0.43 0.02 0.00 98.07 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 4.20 19.48 233.88 16478613 197805752
CPU Utilization Report
%user |
Show the percentage of CPU utilization that occurred while executing at the user (application) level. |
%nice |
Show the percentage of CPU utilization that occurred while executing at the user level with nicepriority. |
%system |
Show the percentage of CPU utilization that occurred while executing at the system (kernel) level. |
%iowait |
Show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request. |
%steal |
Show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor. |
%idle |
Show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request. |
Device Utilization Report
Device |
This column gives the device (or partition) name as listed in the /dev directory. |
tps |
Indicate the number of transfers per second that were issued to the device. A transfer is an I/O request to the device. Multiple logical requests can be combined into a single I/O request to the device. A transfer is of indeterminate size. |
Blk_read/s (kB_read/s, MB_read/s) |
Indicate the amount of data read from the device expressed in a number of blocks (kilobytes, megabytes) per second. Blocks are equivalent to sectors and therefore have a size of 512 bytes. |
Blk_wrtn/s (kB_wrtn/s, MB_wrtn/s) |
Indicate the amount of data written to the device expressed in a number of blocks (kilobytes, megabytes) per second. |
Blk_read (kB_read, MB_read) |
The total number of blocks (kilobytes, megabytes) read. |
Blk_wrtn (kB_wrtn, MB_wrtn) |
The total number of blocks (kilobytes, megabytes) written. |
rrqm/s |
The number of read requests merged per second that were queued to the device. |
wrqm/s |
The number of write requests merged per second that were queued to the device. |
r/s |
The number (after merges) of read requests completed per second for the device. |
w/s |
The number (after merges) of write requests completed per second for the device. |
rsec/s (rkB/s, rMB/s) |
The number of sectors (kilobytes, megabytes) read from the device per second. |
wsec/s (wkB/s, wMB/s) |
The number of sectors (kilobytes, megabytes) written to the device per second. |
avgrq-sz |
The average size (in sectors) of the requests that were issued to the device. |
avgqu-sz |
The average queue length of the requests that were issued to the device. |
await |
The average time (in milliseconds) for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. |
r_await |
The average time (in milliseconds) for read requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. |
w_await |
The average time (in milliseconds) for write requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them. |
svctm |
The average service time (in milliseconds) for I/O requests that were issued to the device. Warning! Do not trust this field anymore! This field will be removed in a future sysstat version. |
%util |
Percentage of CPU time during which I/O requests were issued to the device (bandwidth utilization for the device). Device saturation occurs when this value is close to 100%. |
vmstat
vmstat reports virtual memory statistics and is used to help identify performance bottlenecks.
vmstat reports information about processes, memory, paging, block IO, traps, disks and cpu activity.
The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.
[email protected]7010:~$ vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 685260 986196 570376 3263248 0 0 2 13 2 5 1 0 98 0 0
Procs:
r | The number of processes waiting for run time. |
b | The number of processes in uninterruptible sleep. |
Memory:
swpd | The amount of virtual memory used. |
free | The amount of idle memory. |
buff | The amount of memory used as buffers. |
cache | The amount of memory used as cache. |
inact | The amount of inactive memory. (-a option). |
active | The amount of active memory. (-a option). |
Swap:
si | Amount of memory swapped in from disk (per second). |
so | Amount of memory swapped to disk (per second). |
IO:
bi | Blocks received from a block device (blocks per second). |
bo | Blocks sent to a block device (blocks/s). |
System:
in | The number of interrupts per second, including the clock. |
cs | The number of context switches per second. |
CPU: (values expressed in percentages of CPU time)
us | Time spent running non-kernel code. (user time, including nice time) |
sy | Time spent running kernel code. (system time) |
id | Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. |
wa | Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. |
st | Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown. |
mpstat
Using mpstat command without any option, will display the Global Average Activities by All CPUs.
[email protected]7010:~$ mpstat Linux 4.4.0-79-generic (chizhang-OptiPlex-7010) 26/06/17 _x86_64_ (8 CPU) 11:24:10 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 11:24:10 all 1.47 0.00 0.43 0.02 0.00 0.00 0.00 0.00 0.00 98.07
Using mpstat with option ‘-P‘ (Indicate Processor Number) and ‘ALL’, will display statistics about all CPUs one by one starting from 0. 0 will the first one.
[email protected]7010:~$ mpstat -P ALL Linux 4.4.0-79-generic (chizhang-OptiPlex-7010) 26/06/17 _x86_64_ (8 CPU) 11:24:36 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 11:24:36 all 1.47 0.00 0.43 0.02 0.00 0.00 0.00 0.00 0.00 98.07 11:24:36 0 1.88 0.00 0.63 0.00 0.00 0.00 0.00 0.00 0.00 97.49 11:24:36 1 1.93 0.01 0.61 0.15 0.00 0.00 0.00 0.00 0.00 97.30 11:24:36 2 1.87 0.00 0.61 0.01 0.00 0.01 0.00 0.00 0.00 97.50 11:24:36 3 1.84 0.00 0.78 0.01 0.00 0.00 0.00 0.00 0.00 97.37 11:24:36 4 1.09 0.00 0.19 0.00 0.00 0.00 0.00 0.00 0.00 98.72 11:24:36 5 1.08 0.00 0.18 0.00 0.00 0.00 0.00 0.00 0.00 98.73 11:24:36 6 1.08 0.00 0.18 0.00 0.00 0.00 0.00 0.00 0.00 98.74 11:24:36 7 1.02 0.00 0.28 0.00 0.00 0.00 0.00 0.00 0.00 98.69
以上是关于Linux Performance Monitoring Commands的主要内容,如果未能解决你的问题,请参考以下文章
Performance Monitor Usage8:An Practice
c9, Performance Monitor Control Register