Use of linux tool sar

Source: Internet
Author: User
Use the Linux tool to install tarzxvfxxx.tar.gz. /configuremakemakeinstallwww.2cto. com2 uses pidstat: Usage:/usr/local/sysstat/bin/pidstat [options] [& lt; interval & gt; [& lt; count & gt ;.. use 1 to install tar zxvf xxx.tar.gz in linux sar. /configure make install www.2cto.com 2 use pidstat: Usage:/usr/local/sysstat/bin/pidstat [options] [ [ ] Options are: [-C ] [-D] [-h] [-I] [-l] [-r] [-s] [-t] [-u] [-V] [-w] [-p { [,...] | SELF | ALL}] [-T {TASK | CHILD | ALL}] www.2cto.com-C: only displays information about the process whose command name contains the command. -D: Display process io information-I: in a multi-processor, the cpu usage is displayed-p: displays information about the pid process-r: displays page errors and memory usage. -S: displays stack usage-u: reports cpu usage-w: displays context switching information # monitors CPU resource usage of processes whose pid is 1 (init, refresh and output every three seconds. After three times, the program exits. Www.2cto.com/> pidstat-p 1 2 3-l 07:18:58 am pid % usr % system % guest % CPU Command 07:18:59 AM 1 0.00 0.00 0.00 0.00 0/sbin/init 07:19:00 AM 1 0.00 0.00 0.00 0.00 0/sbin/init 07:19:01 AM 1 0.00 0.00 0.00 0/sbin/init Average: 1 0.00 0.00 0.00 0.00-/sbin/init % usr: CPU usage of the process in user mode. % System: CPU usage of the process in kernel mode (system level. % CPU: The total CPU usage of the process. if it is in an SMP environment, the value is divided by the number of CPUs to show the data of each CPU. CPU: the number of the CPU attached to the process (0 indicates the first CPU ). # Monitor the device IO resource load of processes whose pid is 1 (init). refresh and output every two seconds. After three times, the program exits. /> Pidstat-p 1 2 3-d 07:24:49 am pid kB_rd/s kB_wr/s kB_ccwr/s Command 07:24:51 AM 1 0.00 0.00 0.00 init 07:24:53 AM 1 0.00 0.00 init 07:24:55 AM 1 0.00 0.00 0.00 init Average: 1 0.00 0.00 0.00 init kB_rd/s: Number of bytes read by the process per second (KB ). KB_wr/s: the number of bytes written by the process per second (KB ). KB_ccwr/s: number of disk writes canceled by this process per second (KB ). Www.2cto.com # monitor the memory usage of processes whose pid is 1 (init). refresh and output every two seconds. After three times, the program exits. /> Pidstat-p 1 2 3-r 07:29:56 am pid minflt/s majflt/s vsz rss % MEM Command 07:29:58 AM 1 0.00 0.00 2828 1368 0.13 init 07:30:00 AM 1 0.00 0.00 2828 1368 0.13 init 07:30:02 AM 1 0.00 0.00 2828 1368 0.13 init Average: 1 0.00 0.00 2828 1368 init % MEM: memory usage percentage of the process. # Monitor the process task switching with a pid of 1 (init). refresh and output every two seconds. After three times, the program exits. /> Pidstat-p 1 2 3-w 07:32:15 am pid cswch/s nvcswch/s Command 07:32:17 AM 1 0.00 0.00 init 07:32:19 AM 1 0.00 init 07:32:21 AM 1 0.00 init Average: 1 0.00 0.00 init cswch/s: the number of times the task actively (voluntarily) switches the context per second. Active switching means that when a task is in a blocking wait state, it will take the initiative to give up its CPU resources. Nvcswch/s: the number of times the task is passive (not voluntary) to switch the context per second. Passive switching means that the time slice allocated by the CPU to a task has been used up, so the process will be forced to give up the CPU execution right. Www.2cto.com # monitors the memory usage of processes whose pid is 1 (init) and their internal threads (r option). The memory is refreshed and output every 2 seconds, and the program exits three times. Note that if the-t option is not followed by any other options, CPU resources are monitored by default. The yellow highlighted part of the result indicates that the process and its internal threads are displayed in a tree structure. /> Pidstat-p 1 2 3-tr Linux 2.6.32-71. el6.i686 (Stephen-PC) 11/16/2011 _ i686 _ (1 CPU) 07:37:04 am tgid tid minflt/s majflt/s vsz rss % MEM Command 07:37:06 AM 1-0.00 0.00 2828 1368 0.13 init 07:37:06 AM-1 0.00 0.00 2828 1368 0.13 |__ init 07:37:06 AM TGID TID minflt/s majflt/s vsz rss % MEM Command 07:37:08 AM 1-0.00 0.00 2828 1368 0.13 init 07:37:08 AM-1 0.00 0.00 2828 1368 0.13 |__ init 07: 37: 08 am tgid tid minflt/s majflt/s vsz rss % MEM Command 07:37:10 AM 1-0.00 0.00 2828 1368 0.13 init 07:37:10 AM-1 0.00 0.00 2828 1368 0.13 |__ init Average: tgid tid minflt/s majflt/s vsz rss % MEM Command Average: 1-0.00 0.00 2828 1368 0.13 init Average:-1 0.00 0.00 2828 1368 |__ init TGID: thread Group ID. TID: thread ID. SAR: Usage:/usr/local/sysstat/bin/sar [options] [ [ ] Www.2cto.com Options are: [-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}] [-o [ ] |-F [ ] [-I ] [-S [ ] [-E [ ]-A: displays all information (too much content, rarely used)-B: displays io statistics. -B: Display Page statistics-C: When reading input data from a file, the sar will display comments. -D: displays the activity information of the block device. -I :{ [,...] | SUM | ALL | XALL}] [-P { [,...] | ALL} displays information about interrupted activities. Www.2cto.com-n: Displays network statistics. -P: displays the statistics of each cpu.-p: used with-d. the device name is displayed elegantly. -Q: displays the queue length. -R: displays memory usage. -R: displays memory statistics-S: displays the usage of swap partitions. -U: displays cpu usage-w: displays process creation and context switching information. -W: Display Page exchange information. View CPU usage sar 25 // every 2 seconds, display 5 times, CPU usage % 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 idle value is lower than 10, the CPU processing capability of the system is relatively low. The most important resource to be solved in the system is the CPU. Www.2cto.com sar 1 10> data.txt // every 1second, write 10 times, and save the CPU usage data to the data.txt file. Sar 1 0-e 15:00:00> data.txt // records the usage of CPU every 1second. data is saved to the data.txt file. (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 // records the memory usage every 1second. data is saved to the data.txt file after. Sar 1 0-n DEV-e 15:00:00> data.txt // records the network usage every 1second. data is saved to the data.txt file. 13 Route 31? 8 crepe IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s13 201731? 0 crepe lo 0.00 0.00 0.00 0.00 0.00 0.00 0.0013 million 31? 0 crepe em1 0.00 0.00 0.00 0.00 0.00 0.00 0.0013 million 31? 0 crepe em2 30.50 10.00 4.52 3.61 0.00 0.00 8.5013 million 31? 0 crepe em3 0.00 0.00 0.00 0.00 0.00 0.00 0.0013 million 31? 0 crepe em4 0.00 0.00 0.00 0.00 0.00 0.00 0.00 network description www.2cto.com iface lan interface rxpck/s packets received per second txpck/s packets sent per second rxbyt/s bytes received per second number of txbyt/s number of bytes sent per second rxcmp/s compressed packet received per second txcmp/s compressed packet sent per second rxmcst/s multicast packet received per second Example 2: for example, if you want to sample sar-v t n every 30 seconds for five consecutive times and observe the status of the core table, enter the following command: www.2cto.com # sar-v 30 5: 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 5/321 0 1337/2764 0 1561/1706 0 40/128 10:34:23 308/321 0 1340/2764 0 1587/1706 37/128 10:34:53 305/321 0 1332/2764 0 1565/1706 0 36/128 308/321 10:35:23 1338/2764 0 1592/1706 0 37/128 308/321 1335/2764 1591/1706 0 37/128 0 0 Display the 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. Www.2cto.com file-sz: the number of table items in the file table currently being used or allocated in the core, which is 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 actually table items/The number of table items that can be used. The core usage is completely normal. The three tables do not experience overflow and the core parameters do not need to be adjusted, if overflow occurs, adjust the corresponding core parameters to increase the number of corresponding table items. Example 3: use the command line sar-d t n. For example, sample once every 30 seconds for 5 consecutive times and report the device usage. enter the following command: # sar-d 30 5 www.2cto.com: SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001 11:06:43 device % busy avque r + w/s blks/s avwait avserv (-d) 11:07:13 wd-0 1.47 2.75 4.67 14.73 5.50 11:07:43 wd-0 3.14 0.43 18.77 3.07 8.66 25.11 11:08:13 wd-0 1.41 0.77 2.78 2.77 7.26 4.94 2.77 11:08:43 wd-0 1.10 11.18 4.10 11.26 27.32 11:09:13 wd-0 2.68 1.97 5. 86 34.06 69.66 3.35 1.15 Average wd-0 12.11 4.09 15.19 31.12 displays the name of the block device being monitored by the device: sar Command. % Busy: Percentage of requests sent when the device is busy. Avque: the average number of incomplete requests when the queue is full. R + w/s: the amount of data transferred to or from the device per second. Blks/s: the number of transferred blocks per second, each of which is 512 bytes. Avwait: the average time for sending requests to wait for the queue to be idle when the queue is full. Avserv: Average time (in milliseconds) required to complete the transfer request ). In the displayed content, the wd-0 is the name of the hard disk, % busy value is relatively small, indicating that the efficiency of processing the transfer request is too small, the file system efficiency is not high, generally speaking, the % busy value is higher, the avque value is lower, and the file system efficiency is higher. if the % busy and avque values are relatively high, the hard disk transmission speed is too slow and needs to be adjusted. Example 4 of www.2cto.com: use the command line sar-B t n. For example, sample once every 30 seconds and sample 5 times consecutively. to report the usage of the buffer zone, enter the following command: # sar-B 30 5 screen display: SCO_SV scosysv 3.2v5.0.5 i80386 10/01/2001 14:54:59 bread/s lread/s % rcache bwrit/s lwrit/s % wcache pread/s pwrit/s (-B) 14:55:29 0 147 100 5 21 78 0 0 14:55:59 0 186 5 25 79 0 0 14:56:29 4 100 98 8 58 86 0 0 14:56:59 0 232 125 5 23 76 0 0 14:57:29 0 89 100 4 12 66 0 0 Average 1 156 99 5 28 80 0 0 display content includes: Bread/s: the number of physical blocks read from the hard disk to the system buffer per second. Lread/s: the average number of logical blocks read from the system buffer per second. % Rcache: Percentage of logical reads in buffer cache. Bwrit/s: average number of physical blocks written from the system buffer to the disk per second. Lwrit/s: average number of logical blocks written to the system buffer per second. % Wcache: Percentage of logical reads in buffer cache. Pread/s: average number of physical reads requested per second. Pwrit/s: average number of physical writes requested per second. Among the displayed content, the most important columns are % cache and % wcache. their values reflect the buffer usage rate, % rcache is less than 90 or % wcache is less than 65. the number of system buffers should be increased as appropriate. the number of buffers is controlled by the core parameter NBUF, so that % rcache reaches 90, % wcache reaches about 80. However, the value of the buffer parameter affects the I/O efficiency. to increase the buffer, the system efficiency should not be improved if the memory is large. Example 5 of www.2cto.com: use the command line sar-g t n. For example, sample once every 30 seconds and sample 5 times consecutively. to report the operation of serial port I/O, enter the following command: # sar-g 30 5 Screen Display: SCO_SV scosysv 3.2v5.0.5 i80386 11/22/2001 17:07:03 ovsiohw/s ovsiodma/s ovclist/s (-g) 17:07:33 0.00 0.00 17:08:03 0.00 0.00 0.00 17:08:33 0.00 0.00 0.00 17:09:03 0.00 0.00 17:09:33 0.00 0.00 0.00 0.00 0.00 Average 0.00 0.00 0.00 display content includes: ovsiohw/s: serial port I/O hardware overflow per second. Ovsiodma/s: overflow in the cache of the direct input/output channel of the serial port I/O per second. Ovclist/s: Overflow of character queues per second. In the displayed content, the value of each column is zero, indicating that no serial I/O overflow occurs in the system during the sampling time.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.