Sar was originally an internal tool.
Sar was originally an internal tool, which can be downloaded at http://pagesperso-orange.fr/sebastien.godard/download.html.
1 installation
Tar zxvf xxx.tar.gz
./Configure
Make
Make install
2. use
Pidstat 2 5
// The CPU usage of all active processes is displayed 5 times every 2 seconds
Pidstat-p 3132 2 5
// The CPU usage of processes with a PID of 3132 is displayed 5 times every 2 seconds.
Pidstat-p 3132 2 5-r
// Display the memory usage of processes with a PID of 3132 every 2 seconds.
View CPU usage
Sar 2 5
// Display 5 times and CPU usage every 2 seconds
% Usr: Percentage of CPU time in user mode.
% Sys: Percentage of CPU time in system mode.
% Wio: Percentage of CPU waiting for input/output completion time.
% Idle: Percentage of idle CPU time.
In all the displays, we should pay attention to % wio and % idle. The value of % wio is too high, indicating that the hard disk has an I/O bottleneck. The value of % idle is high, indicating that the CPU is idle, if the % idle value is high but the system response is slow, it may be that the CPU is waiting for memory allocation. in this case, the memory capacity should be increased. If the value of % idle is lower than 10, the CPU processing capability of the system is relatively low, indicating that the most important resource to be solved in the system is the CPU.
Sar 1 10> data.txt
// Write data every 1second and save the CPU usage data to the data.txt file.
Sar 1 0-e 15:00:00> data.txt
// The usage of CPU is recorded every 1second. data is saved to the data.txt file after. (The-e parameter indicates the end time. Note that the time format must be hh: mm: ss)
Sar 1 0-r-e 15:00:00> data.txt
// The memory usage is recorded every other 1 second. The data is saved to the data.txt file at 15 o'clock.
Sar 1 0-n DEV-e 15:00:00> data.txt
// The Network usage is recorded every 1second. The data is saved to the data.txt file.
Example 2: Use alive sar-v t n
For example, if you sample data every 30 seconds for five consecutive times and observe the status of the core table, enter the following command:
# Sar-v 30 5
Screen Display:
SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001
10:33:23 proc-sz ov inod-sz ov file-sz ov lock-sz (-v)
10:33:53 305/321 0 1337/2764 0 1561/1706 0 40/128
10:34:23 308/321 0 1340/2764 0 1587/1706 0 37/128
10:34:53 305/321 0 1332/2764 0 1565/1706 0 36/128
10:35:23 308/321 0 1338/2764 0 1592/1706 0 37/128
10:35:53 308/321 0 1335/2764 0 1591/1706 0 37/128
The displayed content includes:
Proc-sz: number of table items in the table currently being used or allocated in the core, controlled by the core parameter MAX-PROC.
Inod-sz: the number of table items in the I node table that is currently being used or allocated in the core, which is controlled by the core parameter MAX-INODE.
File-sz: the number of table items in the file table currently being used or allocated in the core, controlled by the core parameter MAX-FILE.
Ov: the number of overflow times.
Lock-sz: number of table items that are currently being locked by or allocated records in the core, controlled by the core parameter MAX-FLCKRE.
The display format is
Actual use of table items/number of available table items
The displayed content indicates that the core is completely normal. The three tables do not have overflow and the core parameters do not need to be adjusted. if overflow occurs, adjust the corresponding core parameters, increase the number of corresponding table items.