Installation
If the system does not have the command, install:
apt-get install Sysstatyum install Sysstat
Installation Complete:
vi/etc/default/sysstatenabled="true"
Start this tool to collect system performance data:
/etc/init.d/sysstat start
SAR parameter description
-A summary of all reports -a report file read/write usage -B reports additional cache Usage-B reportscache usage -C reports usage of system calls -D Report disk usage -G report serial port Usage -H report statistics on buffer usage -m reports usage of IPC message queues and semaphores -N Report named Cache usage -p Report usage of paging activity -Q report Average length of run queue and interchange queue -R reports the activity of the process -R Report unused memory pages and hard disk blocks -u report CPU Utilization -V reportingprocess, I node, file and lock table status -W Report system Exchange activity status -y report TTY device activity status
Recommendations for SAR use
Suspected CPU bottleneck
Sar-
Suspect memory bottleneck
Sar--
Suspect I/O has a bottleneck
Sar--
View CPU Usage
Sar-u 1 3
Print CPU usage is printed once per second, printing ends 3 times.
[[Email protected]2bin]# Sar-u1 3Linux2.6. +-504. el6.x86_64 (it-2) November 05, 2015 _x86_64_ (1CPU) 17:13 28 second CPU%user%nice%system%iowait%steal%Idle17 13 minutes, 29 seconds All6.12 0.00 3.06 0.00 0.00 90.8217:13 30 sec All5.10 0.00 3.06 0.00 0.00 91.8417:13 31 sec All7.14 0.00 2.04 0.00 0.00 90.82Average time: all6.12 0.00 2.72 0.00 0.00 91.16
The indicators for each column are:
%user
The proportion of CPU time consumed in user mode;
%nice
The proportion of CPU time consumed in user mode by the process that changed the process scheduling priority through Nice
%system
The proportion of CPU time consumed in system mode;
%iowait
The percentage of time that the CPU waits for disk I/O to consume idle state;
%steal
Use operating system virtualization technologies such as Xen to wait for the percentage of time that other virtual CPUs compute to occupy;
%idle
CPU idle time ratio;
View Average Load
Sar-q
View the number of processes in the running queue, the size of the process on the system, and the average load.
[[Email protected]2bin]# Sar-q1 3Linux2.6. +-504. el6.x86_64 (it-2) November 05, 2015 _x86_64_ (1CPU) 17:16 42 sec Runq-sz Plist-sz ldavg-1ldavg-5ldavg- the17:16 43 sec4 338 0.00 0.00 0.0017:16 44 sec4 338 0.00 0.00 0.0017:16 45 sec4 338 0.00 0.00 0.00Average Time:4 338 0.00 0.00 0.00
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: System average load for last 1 minutes
Ldavg-5: System average load over the last 5 minutes
Ldavg-15: System average load over the last 15 minutes
View Memory usage
Sar-r
To view physical memory usage.
[[Email protected]2bin]# Sar-r1 3Linux2.6. +-504. el6.x86_64 (it-2) November 05, 2015 _x86_64_ (1CPU) 17:18 11 sec kbmemfree kbmemused%memused kbbuffers kbcached kbcommit%commit17 18 minutes, 12 seconds .328708 1593664 82.90 35708 254300 2193348 26.7017:18 13 sec328708 1593664 82.90 35716 254296 2193348 26.7017:18 14 sec328708 1593664 82.90 35716 254300 2193348 26.70Average Time:328708 1593664 82.90 35713 254299 2193348 26.70
Kbmemfree: This value is basically the same as the free value in the command, so it does not include buffer and cache space.
Kbmemused: This value is basically the same as the used value in the free command, so it includes buffer and cache space.
%memused: Physical memory usage, this value is a percentage of kbmemused and total memory (excluding swap).
Kbbuffers and kbcached: These two values are the buffer and cache in the free command.
Kbcommit: Ensure that the current system requires memory (RAM+SWAP) in order to ensure that it does not overflow.
%commit: This value is a percentage of kbcommit and total memory (including swap).
View Page Exchange occurrences
Sar-w
When the page is exchanged, the throughput of the server will be greatly reduced, if the server is in bad condition, if it is suspected that the page exchange occurs because of insufficient memory, this command can be used to confirm whether a large number of exchanges have occurred;
[[Email protected]2bin]# sar-w1 3Linux2.6. +-504. el6.x86_64 (it-2) November 05, 2015 _x86_64_ (1CPU) 17:18 55 sec Pswpin/s pswpout/S17 18 minutes, 56 seconds .0.00 0.0017:18 57 sec0.00 0.0017:18 58 sec0.00 0.00Average Time:0.00 0.00
PSWPIN/S: Number of swap pages per second system swapped in (Swap page)
PSWPOUT/S: Number of swap pages per second system swapped out (Swap page)
Linux System SAR Command parsing