In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Sar (System ActivityReporter system activity report) is one of the most comprehensive system performance analysis tools on Linux, which can report system activities from many aspects, including: read and write of files, usage of system calls, disk I / O, CPU efficiency, memory usage, process activity and IPC related activities, etc. Sar command has sysstat installation package installed. This paper mainly takes CentOS 6 series x64 system as an example. Introduces the sar command.
The common format of the 1.1:sar command:
Usage: sar [options] [[]]
Options:
[- A] [- B] [- b] [- C] [- d] [- H] [- h] [- p] [- Q] [- R]
[- r] [- S] [- t] [- u [ALL]] [- V] [- v] [- W] [- w] [- y]
[- I {[,...] | SUM | ALL | XALL}] [- P {[,...] | ALL}]
[- m {[,...] | ALL}] [- n {[,...] | ALL}]
[- j {ID | LABEL | PATH | UUID |...}]
[- f [] |-o [] |-[0-9] +]
[- I] [- s []] [- e []]
-A: the sum of all reports
-b: displays statistics for Istroke O and transfer rate
-B: display page change status
-d: output the usage information of each disk
-e: sets the end time of the display report
-f: read the report from the established file
-I: sets the interval between status information refresh
-P: report the status of each CPU
-R: display memory statu
-u: output cpu usage and statistics
-v: displays the status of inodes, files, and other kernel tables
W: displays the status of the swap partition
-x: displays the installation of a given process
-r: report statistics on memory utilization
1.2:sar-u # counts the usage of CPU, once every second, for a total of three times:
Sar-u 1 3
#% user # CPU usage of user space
#% CPU utilization of nice processes that have changed priorities
#% CPU utilization of system kernel space
#% percentage of iowait CPU waiting for IO
# CPU used by virtual machine CPU of steal virtual machine
#% idle idle CPU
# in the above display, the fact that% iowait and% idle,%iowait are too high indicates that there is an I IO bottleneck, that is, disk IO cannot meet business requirements. If the% idle is too low, the CPU utilization is serious, and you need to determine whether CPU is a bottleneck based on memory usage and other conditions.
1.2.1: report the usage status of each CPU:
Sar-p 1 3
# Statistics of all CPU in CPU
#% CPU usage statistics of user user mode
#% nice CPU usage statistics for processes that have changed priority
#% percentage of iowait CPU waiting for IO data
#% percentage of physical CPU occupied by vCPU of steal virtual machine
#% percentage of idle idle CPU
1.3: save the statistical results in a file and read from the file:
# saved files, which are binary and cannot be opened directly using vim and cat
Sar-u-o / tmp/1.txt 2 3
# read from binary file
Sar-u-f / tmp/1.txt
1.4: view average load:
Sar-Q
# length of runq-sz run queue (the number of processes waiting to run, the number of CP per core cannot exceed 3)
# number of processes (processes) and threads (threads) in the plist-sz process list
# average load of CPU in the last minute of ldavg-1, which is the average of the load of multicore CPU in the past minute added and divided by the number of cores, 5 minutes and 15 minutes, and so on
# average CPU load for the last 5 minutes of ldavg-5
# average CPU load for the last 15 minutes of ldavg-15
1.5:sar-r # View memory usage
# amount of physical memory available in kbmemfree
# physical memory size in use of kbmemused
#% memused physical memory utilization
# the amount of physical memory used as buffers in the kbbuffers kernel, kbbuffers and kbcached: these values are buffer and cache in the free command.
# File size cached by kbcached
# kbcommit ensures the minimum memory required for the normal operation of the current system, that is, the minimum memory needed to ensure that the memory does not overflow (physical memory + Swap partition)
# commit is the value of kbcommit as a percentage of total memory (physical memory + swap partition)
1.6: view the statistics of the swap partition of the system:
Sar-W
# pswpin/s number of swap pages (swap page) from the swap partition to the system per second
# pswpott/s the number of exchange pages (swap page) exchanged from the system to swap per second
1.7 avalanche # View the statistics of Istroke O and transfer rate
Sar-b
# Total IO per second of tps disks, which is equal to tps in iostat
# rtps Total number of IO read from disk per second
# wtps Total number of IO written to disk per second
# bread/s total number of blocks read from disk per second
# bwrtn/s total number of blocks written to disk per second
1.8 VR # disk usage statistics
Sar-d
# the name of the DEV disk device. If you do not add-p, a device name similar to dev253-0 will be displayed, so the name displayed by adding-p is more direct.
# tps: the total number of transfers per second
# Total number of sectors read by rd_sec/s per second
# Total number of sectors written by wr_sec/s per second
# avgrq-sz APCge data size (sector) per disk Istroke O operation
# average length of avgqu-sz disk request queue
# await the average elapsed time of each request from the request disk operation to the completion of the system processing, including the request queue waiting time in milliseconds (1 second equals 1000 milliseconds), equal to seek time + queue time + service time
# the service processing time of # svctm I Pot O, that is, excluding the time in the request queue
The percentage of CPU occupied by #% util Imax O requests. The higher the value is, the slower the CPU O is.
1.9 # process, inode, file and lock table status
Sar-v
# number of entries not used by dentunusd in buffered directory entries
# file-nr number of file handles used by the system
# number of indexes already used by inode-nr
# number of pty used by pty-nr
# the index and file handle values are not the values found in ulimit-a, but the kernel-related values defined in sysctl.conf. Max-file indicates the number of file handles that can be opened at the system level, while ulimit-n controls the number of file handles that can be opened at the process level, which can be viewed using sysctl-a | grep inode and sysctl-a | grep file. The specific meaning is as follows:
File-max specifies a system-wide limit on the number of file handles that can be opened by all processes (system level, kernel-level). (The value in file-max denotes the maximum number of file handles that the Linux kernel will allocate). You should have added this value when you received an error message such as "Too many open files in system".
# cat / proc/sys/fs/file-max
4096
# echo 100000 > / proc/sys/fs/file-max
Or
# echo "" fs.file-max=65535 "> > / etc/sysctl.conf
# sysctl-p
File-nr can view the number of file handles currently open on the system. It includes three numbers: the first represents the number of file descriptors that have been allocated, the second represents the number of free file handles, and the third represents the maximum value that can be opened (as in file-max). The kernel dynamically allocates file handles, but does not release them again (this may not be suitable for the latest kernel. In my file-nr, I see that the second column is always 0, and the first column is increasing and decreasing).
Man bash, find the section that explains ulimit: provides control over the resources available to shell and the processes it starts, including file handles, number of processes, core file size, and so on. This is at the process level, that is, how many file descriptors can be opened by a session and each process it starts, how many child processes can be fork, etc. When the upper limit is reached, it will report "Too many open files" or encounter Socket/File: Can't open so many files and so on.
1.10: statistics of network information
Sar-n
The # sar-n option uses six different switches: DEV,EDEV,NFS,NFSD,SOCK,IP,EIP,ICMP,EICMP,TCP,ETCP,UDP,SOCK6,IP6,EIP6,ICMP6,EICMP6 and UDP6, DEV displays network interface information, EDEV displays statistics about network errors, NFS statistics information about active NFS clients, NFSD statistics NFS server information, SOCK displays socket information, ALL displays all five switches. They can be used alone or together.
1.10.1: the statistics are made every second, with a total of one count. The following average is the average value after multiple statistics.
Sar-n DEV 1 1
# name of the local Nic interface in IFACE
# packets accepted by rxpck/s per second
# Database sent per second by txpck/s
# packet size accepted by rxKB/S per second (in KB)
# the size of packets sent by txKB/S per second, in KB
# compressed packets accepted by rxcmp/s per second
# compressed packets sent by txcmp/s per second
# Multicast packets received by rxmcst/s per second
1.10.2:sar-n EDEV 1 1 # statistics network device communication failure information:
Sar-n EDEV 1 1
# name of IFACE Nic
# corrupted packets received by rxerr/s per second
# number of packet errors sent by txerr/s per second
# coll/s the number of collisions per second when sending a packet, which occurs only in half-duplex mode
# rxdrop/s the number of network packets lost by the receiver of the Nic per second when the buffer is full
# txdrop/s the number of network packets lost by the sender of the network device per second when the buffer is full
# txcarr/s the number of carrier errors per second when sending a packet
# the number of errors made by frames per second when rxfram receives a packet
# the number of buffer overflow errors per second when rxfifo receives packets
# txfifo the number of buffer overflow errors per second when a packet occurs
1.10.3:sar-n SOCK 1 1 # Statistics socket connection information
Sar-n SOCK 1 1
# Total number of socket currently used by totsck
# Total number of socket of TCP currently being used by tcpsck
# Total number of socket of UDP currently being used by udpsck
# Total number of skcket rawsck currently being used in RAW
# number of current IP shards of if-frag
# number of connections in the TIME-WAIT state in the tcp-tw TCP socket
# if you use the FULL keyword, it is equivalent to the combination of DEV, EDEV and SOCK above
Statistics of 1.10.4:sar-n TCP 1 3 # TCP connections
Sar-n TCP 1 3
# active/s New active connection
# passive/s New passive connection
# segments accepted by iseg/s
# Segment of oseg/s output
Summary of 1.10.5:sar-n usage
-n DEV: network interface statistics.
-n EDEV: network interface error.
-n IP: IP Datagram statistics.
-n EIP: IP error statistics.
-n TCP: TCP statistics.
-n ETCP: TCP error statistics.
-n SOCK: socket usage.
1.10.6: a summary of commonly used commands. Some commands may not have or display inconsistent results due to different versions and platforms:
Default monitoring: sar 5 5 / / CPU and IOWAIT statistical status
(1) sar-b 55 / / IO transfer rate
(2) sar-B 55 / page exchange rate
(3) rate of sar-c 5 5 / / process creation
(4) active information of sar-d 55 / block devices
(5) sar-n DEV 55 / / status information of network devices
(6) the use of sar-n SOCK 55 / / SOCK
(7) sar-n ALL 55 / / all network status information
(8) sar-P ALL 55 / / usage status information and IOWAIT statistical status of each CPU
(9) length of sar-Q 5 5 / / queue (number of processes waiting to run) and load status
(10) sar-r 55 / / memory and swap space usage
(11) sar-R 5 5 / / memory statistics (allocation and release of memory pages, memory pages used by the system as BUFFER per second, memory pages cache per second)
(12) sar-u 5 5
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.