Today when reading the "large-scale Web services Development Technology" book, the book mentions the SAR command, it feels very useful, it is necessary to sort out the study. (For a Linux beginner, do not miss a learning opportunity: P)
Opening your own centos, typing "SAR", expressed disappointment:
[[email protected] ~]# SAR
Bash:sar:command not found
There is no installation, but fortunately the installation of Linux is very convenient.
[email protected] ~]# Yum install Sysstat
Loaded Plugins:fastestmirror
Loading mirror speeds from cached hostfile
* base:mirrors.grandcloud.cn
* extras:mirrors.grandcloud.cn
* updates:mirrors.grandcloud.cn
Addons | 1.9 KB 00:00
Base | 1.1 KB 00:00
Extras | 2.1 KB 00:00
Updates | 1.9 KB 00:00
updates/primary_db | 255 KB 00:01
Setting up Install Process
Resolving Dependencies
--Running Transaction check
---> Package sysstat.i386 0:7.0.2-11.el5 Set updated
--Finished Dependency Resolution
Dependencies resolved
================================================================================
Package arch version repository size
============================================ ====================================
installing:
sysstat i386 7.0.2-11.el5 base 182 k
Transaction summary
=============================================================================== =
install 1 package (s)
upgrade 0 Package (s)
Total download size:182 k
was this ok [y/n]: y
downloading packages:
sysstat-7.0.2-11.el5.i386.rpm | 182 kb 00:01
Running rpm_check_debug
Running Transaction test
finished Transaction test
Transaction Test succeeded
Running Transaction
installing : sysstat 1/1
Installed:
Sysstat.i386 0:7.0.2-11.el5
complete!
Note: SAR is the front-end display tool for background process SADC, and after installing a package named "Sysstat", SADC automatically collects reports from the kernel and saves them.
The general usage of SAR is summarized below in case of forgetting.
Sar–u Viewing CPU Usage
[Email protected] ~]# sar-u
Linux 2.6.18-194.26.1.el5 (localhost) April 29, 2012
09:39 42 sec LINUX RESTART
09:40 01 sec CPU%user%nice%system%iowait%steal%idle
09:50 01 sec All 0.14 0.00 0.58 0.12 0.00 99.15
10:00 01 sec All 0.06 0.00 0.50 0.16 0.00 99.27
10:10 01 sec All 0.11 0.06 0.95 2.58 0.00 96.30
10:20 01 sec All 0.12 0.19 0.82 1.41 0.00 97.46
10:30 01 sec All 0.14 0.00 0.54 0.12 0.00 99.20
10:40 01 sec All 0.15 0.00 0.54 0.16 0.00 99.15
Average:all 0.12 0.04 0.65 0.76 0.00 98.43
Over here:
%user: The proportion of CPU time consumed in user mode;
%nice: The proportion of CPU time consumed in user mode by changing the process scheduling priority process through nice;
%system: The proportion of CPU time consumed in system mode;
%iowait:cpu the percentage of idle state consumption time that is waiting for disk I/O;
%steal: When using operating system virtualization technologies such as Xen, wait for the percentage of time that other virtual CPUs compute to occupy;
%idle:cpu the percentage of time spent waiting for idle state such as disk I/O;
Note:
If the%iowait value is too high, the hard disk has an I/O bottleneck
If the value of%idle is high but the system responds slowly, it is possible that the CPU is waiting to allocate memory and should increase the memory capacity
If the value of%idle continues below 10, the system's CPU processing power is relatively low, indicating that the most necessary resource to be addressed in the system is the CPU.
Sar–q Viewing average load
[Email protected] ~]# sar-q
Linux 2.6.18-194.26.1.el5 (localhost) April 29, 2012
09:39 42 sec LINUX RESTART
09:40 01 sec runq-sz Plist-sz ldavg-1 ldavg-5 ldavg-15
09:50 01 SEC 0 152 0.00 0.02 0.05
10:00 01 SEC 0 152 0.00 0.00 0.00
10:10 01 sec 0 156 0.39 0.09 0.03
10:20 01 sec 0 151 0.00 0.03 0.01
10:30 01 sec 0 151 0.00 0.00 0.00
10:40 01 sec 0 151 0.00 0.00 0.00
10:50 01 sec 0 151 0.00 0.00 0.00
average:0 152 0.06 0.02 0.01
Runq-sz: Length of the run queue (number of processes waiting to run)
Plist-sz: Number of processes (processes) and threads (threads) in the process list
Ldavg-1: Average system load for last 1 minutes (systems load average)
Ldavg-5: System average load over the last 5 minutes
Ldavg-15: System average load over the last 15 minutes
Sar–r Viewing memory usage
[Email protected] ~]# Sar-r
Linux 2.6.18-194.26.1.el5 (localhost) April 29, 2012
09:39 42 sec LINUX RESTART
09:40 01 sec kbmemfree kbmemused%memused kbbuffers kbcached kbswpfree kbswpused%swpused Kbswpcad
09:50 01 sec 481572 553492 53.47 35592 384508 2097144 0 0.00 0
10:00 01 sec 480960 554104 53.53 36032 384512 2097144 0 0.00 0
10:10 01 sec 404952 630112 60.88 77764 399432 2097144 0 0.00 0
10:20 01 sec 375824 659240 63.69 87356 410892 2097144 0 0.00 0
10:30 01 sec 371860 663204 64.07 87756 411064 2097144 0 0.00 0
...
Kbmemfree: The amount of free physical memory;
Kbmemused: The amount of physical memory in use;
%memused: The utilization rate of physical internal memory;
Kbbuffers: The amount of physical memory used as a buffer in the kernel;
Kbcacheed: The amount of physical memory used in the kernel as a cache;
Kbswpfree: Idle capacity of the swap area;
Kbswpused: The capacity of the swap area in use;
Sar–w Viewing page Exchange occurrences
[Email protected] ~]# sar-w
14:30 01 sec pswpin/s pswpout/s
14:40 01 SEC 0.00 0.00
14:50 01 SEC 0.00 0.00
15:00 01 SEC 0.00 0.00
average:0.00 0.00
...
Sar–b viewing statistics for I/O and transfer rates
[Email protected] ~]# Sar-b 1 5
Linux 2.6.18-194.26.1.el5 (localhost) April 29, 2012
15:08 18 sec. TPs Rtps Wtps bread/s bwrtn/s
15:08 19 sec 0.00 0.00 0.00 0.00 0.00
15:08 20 sec 0.00 0.00 0.00 0.00 0.00
15:08 21 sec 0.00 0.00 0.00 0.00 0.00
15:08 22 sec 13.27 0.00 13.27 0.00 220.41
15:08 23 sec 0.00 0.00 0.00 0.00 0.00
average:2.66 0.00 2.66 0.00 44.17
TPS: Total I/O transfers per second for physical devices
Rtps: Total amount of data read from physical devices per second
Wtps: The total amount of data written to the physical device per second
BREAD/S: The amount of data read from the physical device per second, in blocks/s
BWRTN/S: The amount of data written to the physical device per second, in blocks/s
Others are:
Sar–c number of processes created per second
Sar-n DEV Output Network device status statistics
Note: By default, data is counted for the past time period, which is generally displayed from the nearest 0:00. If you want to continue looking at the report a day ago, you can use the-F option to specify a log file that is saved in the/var/log/sa directory. If you want to periodically view the current data can be a command followed by a number of parameters, such as Sar–q 1 3, indicating: 1 seconds 1 times, a total of 3 times.
Linux Command Literacy SAR