Use of linux tool sar

Source: Internet
Author: User

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] [<interval> [<count>] Options are: [-C <command>] [-d] [-h] [-I] [-l] [-r] [-s] [-t] [-u] [-V] [-w] [-p {<pid> [,...] | 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 uses sar: Usage:/usr/local/sysstat/bin/sar [options] [<interval> [<count>] 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 {<int> [,...] | SUM | ALL | XALL}] [-P {<cpu> [,...] | ALL}] [-m {<keyword> [,...] | ALL}] [-n {<keyword> [,...] | ALL}] [-o [< Filename>] |-f [<filename>] [-I <interval>] [-s [

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.