Centos itself does not contain sar commands. Therefore, you must install it on your own. Install sar # yum-yinstallsysstat # or yuminstallsysstat (press y by yourself) # whereissar # whereisiostat. Use sar // to input data to the screen every second
Centos itself does not contain sar commands. Therefore, you must install it on your own.
Install sar
# Yum-y install sysstat # or yum install sysstat (manually press y)
# Whereis sar
# Whereis iostat
Installation is complete.
Use sar
// Output cpu usage information to the screen once every second, with a total of five outputs:
# Sar 1 5 # or sar-u 1 5
// Sample once every 2 seconds for a total of 10 times. Save the CPU usage data to the/opt/cpu. log file.
# Sar 2 10>/opt/cpu. log
// Display all current core data.
# Sar-p all 1 1
// The CPU usage is recorded every one second until, and the data is saved to the/opt/cpu. log file. (The-e parameter indicates the end time. Note that the time format must be hh: mm: ss)
# Sar 1 0-u-e 11:02:00>/opt/cpu. log
// The memory usage is recorded every one second until, and the data is saved to the/opt/memory. log file.
# Sar 1 0-r-e 11:02:00>/opt/memory. log
// Record network usage every one second,UntilThe data will be saved to the/opt/network. log file.
# Sar 1 0-n DEV-e 11:02:00>/opt/network. log
Note:
General format:
Sar [options...] [ [ ]
Common options:
-A: including the vast majority of options.
-B: reports I/O and transmission rate statistics.
-B: Report page statistics.
-C: report process creation activities.
-D: the block device that reports each activity. (Disk)
-E [hh: mm: ss]: sets the end time of sar Command execution in the 24-hour format.
-I {irq | SUM | ALL | XALL}: Reports statistics on the given interruptions.
-N {DEV | EDEV | NFS | NFSD | SOCK | ALL}: Reports network statistics.
-P {cpu | ALL}: Reports statistics of each processor. statistics can be collected for specified or ALL processors.
-Q: Report queue length and average load.
-R: Reports memory and swap space utilization statistics.
-R: Reports memory statistics.
-U: report CPU utilization.
Interval: The interval between two outputs.
Count: The number of times statistics are made based on this interval.
The-o filename parameter of the Ps. tar command can generate a file, but it is a binary file. you must use the-f filename command to open the file. Therefore, it is not recommended here. The output redirection is used.