Sysstat In the performance monitoring toolkit 20 A practical command

Study mpstatpidstatiostat and sar Tools such as , These tools can help us find out the problems in the system . These tools all contain different options , This means that you can use different options for different jobs , Or customize the script according to your needs . We all know , System administrators are a little lazy , They often look for simpler ways to finish their work .

mpstat – Processor Statistics

1. Use without any parameters mpstat The command will output all CPU The average statistics of

1
2
3
4
5
6
tecmint@tecmint ~ $ mpstat
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 23 : 57  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 23 : 57  IST  all   37.35    0.01    4.72    2.96    0.00    0.07    0.00    0.00    0.00   54.88

2. Use ‘-p’ ( Processor number ) and ‘ALL’ The parameters will start from 0 Start outputting each... Independently CPU Statistical information ,0 Represents the first cpu.

1
2
3
4
5
6
7
8
tecmint@tecmint ~ $ mpstat -P ALL
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 29 : 26  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 29 : 26  IST  all   37.33    0.01    4.57    2.58    0.00    0.07    0.00    0.00    0.00   55.44
12 : 29 : 26  IST    0   37.90    0.01    4.96    2.62    0.00    0.03    0.00    0.00    0.00   54.48
12 : 29 : 26  IST    1   36.75    0.01    4.19    2.54    0.00    0.11    0.00    0.00    0.00   56.40

3. To carry out ‘N’ Time , The average interval n Second output CPU Statistics , As shown below .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tecmint@tecmint ~ $ mpstat -P ALL 2 5
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 36 : 21  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 36 : 23  IST  all   53.38    0.00    2.26    0.00    0.00    0.00    0.00    0.00    0.00   44.36
12 : 36 : 23  IST    0   46.23    0.00    1.51    0.00    0.00    0.00    0.00    0.00    0.00   52.26
12 : 36 : 23  IST    1   60.80    0.00    3.02    0.00    0.00    0.00    0.00    0.00    0.00   36.18
 
12 : 36 : 23  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 36 : 25  IST  all   34.18    0.00    2.30    0.00    0.00    0.00    0.00    0.00    0.00   63.52
12 : 36 : 25  IST    0   31.63    0.00    1.53    0.00    0.00    0.00    0.00    0.00    0.00   66.84
12 : 36 : 25  IST    1   36.73    0.00    2.55    0.00    0.00    0.00    0.00    0.00    0.00   60.71
 
12 : 36 : 25  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 36 : 27  IST  all   33.42    0.00    5.06    0.25    0.00    0.25    0.00    0.00    0.00   61.01
12 : 36 : 27  IST    0   34.34    0.00    4.04    0.00    0.00    0.00    0.00    0.00    0.00   61.62
12 : 36 : 27  IST    1   32.82    0.00    6.15    0.51    0.00    0.00    0.00    0.00    0.00   60.51

(LCTT Translation notes : In the above command ‘2’ each 2 Once per second ‘mpstat -P ALL’ command , ‘5’ It means to execute in total 5 Time )

4. Use ‘I’ Parameter will output interrupt statistics for each processor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tecmint@tecmint ~ $ mpstat -I
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 39 : 56  IST  CPU    intr/s
12 : 39 : 56  IST  all    651.04
 
12 : 39 : 56  IST  CPU        0 /s        1 /s        6 /s        8 /s        9 /s       12 /s       16 /s       17 /s       20 /s       21 /s       22 /s       23 /s       45 /s       46 /s       47 /s      NMI/s      LOC/s      SPU/s      PMI/s      IWI/s      RTR/s      RES/s      CAL/s      TLB/s      TRM/s      THR/s      MCE/s      MCP/s      ERR/s      MIS/s
12 : 39 : 56  IST    0      76.27       1.73       0.00       0.00       0.42       0.33       0.00       0.06      11.46       0.00       0.00       0.01       7.62       1.87       0.05       0.33     182.26       0.00       0.33       3.03       0.00      22.66       0.16       5.14       0.00       0.00       0.00       0.00       0.00       0.00
12 : 39 : 56  IST    1      70.88       1.44       0.00       0.00       0.41       0.33       0.00      27.91      10.33       0.00       0.00       0.01       7.27       1.79       0.05       0.32     184.11       0.00       0.32       5.17       0.00      22.09       0.13       4.73       0.00       0.00       0.00       0.00       0.00       0.00
 
12 : 39 : 56  IST  CPU       HI/s    TIMER/s   NET_TX/s   NET_RX/s    BLOCK/s BLOCK_IOPOLL/s  TASKLET/s    SCHED/s  HRTIMER/s      RCU/s
12 : 39 : 56  IST    0       0.00     116.49       0.05       0.27       7.33       0.00       1.22      10.44       0.13      37.47
12 : 39 : 56  IST    1       0.00     111.65       0.05       0.41       7.07       0.00      56.36       9.97       0.13      41.38

5. Use ‘A’ Parameter will output all the information mentioned above , Equate to ‘-u -I All -p ALL’.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
tecmint@tecmint ~ $ mpstat -A
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 41 : 39  IST  CPU    %usr   %nice    %sys %iowait    %irq   %soft  %steal  %guest  %gnice   %idle
12 : 41 : 39  IST  all   38.70    0.01    4.47    2.01    0.00    0.06    0.00    0.00    0.00   54.76
12 : 41 : 39  IST    0   39.15    0.01    4.82    2.05    0.00    0.02    0.00    0.00    0.00   53.95
12 : 41 : 39  IST    1   38.24    0.01    4.12    1.98    0.00    0.09    0.00    0.00    0.00   55.57
 
12 : 41 : 39  IST  CPU    intr/s
12 : 41 : 39  IST  all    651.73
12 : 41 : 39  IST    0    173.16
12 : 41 : 39  IST    1    225.89
 
12 : 41 : 39  IST  CPU        0 /s        1 /s        6 /s        8 /s        9 /s       12 /s       16 /s       17 /s       20 /s       21 /s       22 /s       23 /s       45 /s       46 /s       47 /s      NMI/s      LOC/s      SPU/s      PMI/s      IWI/s      RTR/s      RES/s      CAL/s      TLB/s      TRM/s      THR/s      MCE/s      MCP/s      ERR/s      MIS/s
12 : 41 : 39  IST    0      76.04       1.77       0.00       0.00       0.41       0.36       0.00       0.06      11.60       0.00       0.00       0.01       7.42       1.83       0.05       0.34     182.89       0.00       0.34       2.97       0.00      22.69       0.16       5.22       0.00       0.00       0.00       0.00       0.00       0.00
12 : 41 : 39  IST    1      70.70       1.48       0.00       0.00       0.40       0.36       0.00      27.47      10.46       0.00       0.00       0.01       7.08       1.75       0.05       0.32     184.83       0.00       0.32       5.10       0.00      22.19       0.13       4.91       0.00       0.00       0.00       0.00       0.00       0.00
 
12 : 41 : 39  IST  CPU       HI/s    TIMER/s   NET_TX/s   NET_RX/s    BLOCK/s BLOCK_IOPOLL/s  TASKLET/s    SCHED/s  HRTIMER/s      RCU/s
12 : 41 : 39  IST    0       0.00     116.96       0.05       0.26       7.12       0.00       1.24      10.42       0.12      36.99
12 : 41 : 39  IST    1       0.00     112.25       0.05       0.40       6.88       0.00      55.05       9.93       0.13      41.20

pidstat – Process and kernel thread Statistics

This command is used to monitor processes and threads currently managed by the kernel .pidstat You can also check the state of child processes and threads .

grammar

1
# pidstat <OPTIONS> [INTERVAL] [COUNT]

6. Used without any parameters pidstat Will output all active tasks .

tecmint@tecmint ~ $ pidstat

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 47 : 24  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
12 : 47 : 24  IST     0         1    0.01    0.12    0.00    0.13     1  init
12 : 47 : 24  IST     0         3    0.00    0.01    0.00    0.01     0  ksoftirqd/ 0
12 : 47 : 24  IST     0         9    0.00    0.04    0.00    0.04     0  rcu_sched
12 : 47 : 24  IST     0        10    0.00    0.00    0.00    0.00     0  watchdog/ 0
12 : 47 : 24  IST     0        11    0.00    0.00    0.00    0.00     1  watchdog/ 1
12 : 47 : 24  IST     0        12    0.00    0.00    0.00    0.00     1  migration/ 1
12 : 47 : 24  IST     0        13    0.00    0.01    0.00    0.01     1  ksoftirqd/ 1
12 : 47 : 24  IST     0        23    0.00    0.00    0.00    0.00     0  kworker/u9: 0
12 : 47 : 24  IST     0        29    0.00    0.61    0.00    0.61     0  kworker/ 0 : 1
12 : 47 : 24  IST     0        30    0.00    0.06    0.00    0.06     1  kworker/ 1 : 1
12 : 47 : 24  IST     0       224    0.00    0.01    0.00    0.01     1  jbd2/sda1- 8
12 : 47 : 24  IST     0       360    0.00    0.00    0.00    0.00     1  upstart-udev-br
12 : 47 : 24  IST     0       365    0.01    0.00    0.00    0.01     0  systemd-udevd
12 : 47 : 24  IST     0       476    0.00    0.00    0.00    0.00     0  kworker/u9: 1

7. Use ‘-p’( process ) Parameter outputs all active and inactive tasks .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
tecmint@tecmint ~ $ pidstat -p ALL
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
12 : 51 : 55  IST   UID       PID    %usr %system  %guest    %CPU   CPU  Command
12 : 51 : 55  IST     0         1    0.01    0.11    0.00    0.12     1  init
12 : 51 : 55  IST     0         2    0.00    0.00    0.00    0.00     0  kthreadd
12 : 51 : 55  IST     0         3    0.00    0.01    0.00    0.01     0  ksoftirqd/ 0
12 : 51 : 55  IST     0         5    0.00    0.00    0.00    0.00     0  kworker/ 0 :0H
12 : 51 : 55  IST     0         7    0.00    0.00    0.00    0.00     0  migration/ 0
12 : 51 : 55  IST     0         8    0.00    0.00    0.00    0.00     0  rcu_bh
12 : 51 : 55  IST     0         9    0.00    0.04    0.00    0.04     1  rcu_sched
12 : 51 : 55  IST     0        10    0.00    0.00    0.00    0.00     0  watchdog/ 0
12 : 51 : 55  IST     0        11    0.00    0.00    0.00    0.00     1  watchdog/ 1
12 : 51 : 55  IST     0        12    0.00    0.00    0.00    0.00     1  migration/ 1
12 : 51 : 55  IST     0        13    0.00    0.01    0.00    0.01     1  ksoftirqd/ 1
12 : 51 : 55  IST     0        15    0.00    0.00    0.00    0.00     1  kworker/ 1 :0H
12 : 51 : 55  IST     0        16    0.00    0.00    0.00    0.00     1  khelper
12 : 51 : 55  IST     0        17    0.00    0.00    0.00    0.00     0  kdevtmpfs
12 : 51 : 55  IST     0        18    0.00    0.00    0.00    0.00     0  netns
12 : 51 : 55  IST     0        19    0.00    0.00    0.00    0.00     0  writeback
12 : 51 : 55  IST     0        20    0.00    0.00    0.00    0.00     1  kintegrityd

8. Use ‘-d 2’ Parameters , We can see I/O Statistics ,2 It means to refresh the statistics in seconds . This parameter can be easily known when the system is in heavy work I/O when , Processes that take up a lot of resources .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tecmint@tecmint ~ $ pidstat -d 2
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
03 : 26 : 53  EDT       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
 
03 : 26 : 55  EDT       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
03 : 26 : 57  EDT       574      0.00    148.00      2.00  miniserv.pl
 
03 : 27 : 01  EDT       PID   kB_rd/s   kB_wr/s kB_ccwr/s  Command
03 : 27 : 03  EDT         1      0.00      8.00      2.00  init
03 : 27 : 03  EDT       450      0.00      2.00      0.00  rsyslogd
03 : 27 : 03  EDT       534    138.00     10.00      4.00  crond
03 : 27 : 03  EDT     25100      0.00      6.00      0.00  sendmail
03 : 27 : 03  EDT     30829      0.00      6.00      0.00  java

9. Want every interval 2 Second to process 4164 Of cpu Statistical information output 3 Time , Then use the following with parameters ‘-t’( Output statistics for a selected process ) The order of .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
tecmint@tecmint ~ $ pidstat -t -p 4164 2 3
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
01 : 09 : 06  IST   UID      TGID       TID    %usr %system  %guest    %CPU   CPU  Command
01 : 09 : 08  IST  1000      4164         -   22.00    1.00    0.00   23.00     1  firefox
01 : 09 : 08  IST  1000         -      4164   20.00    0.50    0.00   20.50     1  |__firefox
01 : 09 : 08  IST  1000         -      4171    0.00    0.00    0.00    0.00     0  |__Gecko_IOThread
01 : 09 : 08  IST  1000         -      4172    0.00    0.00    0.00    0.00     0  |__Socket
01 : 09 : 08  IST  1000         -      4173    0.00    0.00    0.00    0.00     0  |__JS
01 : 09 : 08  IST  1000         -      4174    0.00    0.00    0.00    0.00     0  |__JS
01 : 09 : 08  IST  1000         -      4175    0.00    0.00    0.00    0.00     0  |__Hang
01 : 09 : 08  IST  1000         -      4176    0.00    0.00    0.00    0.00     1  |__gdbus
01 : 09 : 08  IST  1000         -      4177    0.00    0.00    0.00    0.00     1  |__gmain

10. Use ‘-rh’ Parameters , Will output the memory usage of the process . The following command is issued every 2 Second refresh frequent memory usage .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
tecmint@tecmint ~ $ pidstat -rh 2 3
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
#      Time   UID       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
  1409816695  1000      3958   3378.22      0.00  707420 215972   5.32  cinnamon
  1409816695  1000      4164    406.93      0.00 1252024 461404  11.36  firefox
  1409816695  1000      6676    168.81      0.00    4436    984   0.02  pidstat
 
#      Time   UID       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
  1409816697     0      1601    644.00      0.00  506728 316788   7.80  Xorg
  1409816697  1000      3958   3412.00      0.00  707420 215972   5.32  cinnamon
  1409816697  1000      4164   2667.00      0.00 1259576 471724  11.62  firefox
  1409816697  1000      6676    172.50      0.00    4436   1020   0.03  pidstat
 
#      Time   UID       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
  1409816699     0      1601    644.00      0.00  506728 316788   7.80  Xorg
  1409816699  1000      3958   4094.00      0.00  710148 218700   5.39  cinnamon
  1409816699  1000      4164    599.00      0.00 1261944 476664  11.74  firefox
  1409816699  1000      6676    168.00      0.00    4436   1020   0.03  pidstat

11. To use ‘-G’ Parameter can output process information containing a specific string . The following command outputs all the data that contain ‘VB’ String of process statistics , Use ‘-t’ Parameter will also output thread information .

1
2
3
4
5
6
7
8
tecmint@tecmint ~ $ pidstat -G VB
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
01 : 09 : 06  IST   UID      PID      %usr  %system  %guest    %CPU   CPU   Command
01 : 09 : 08  IST  1000    1492     22.00     1.00       0.00        23.00     1        VBoxService
01 : 09 : 08  IST  1000    1902     4164      20.00      0.50        0.00       20.50       VBoxClient
01 : 09 : 08  IST  1000    1922     4171      0.00       0.00        0.00       0.00        VBoxClient
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
tecmint@tecmint ~ $ pidstat  -t -G VB
Linux 2.6 . 32 - 431 .el6.i686 (tecmint) 09 / 04 / 2014 _i686_   ( 2 CPU)
 
03 : 19 : 52 PM   UID      TGID       TID    %usr %system  %guest    %CPU   CPU  Command
03 : 19 : 52 PM     0      1479         -    0.01    0.12    0.00    0.13     1  VBoxService
03 : 19 : 52 PM     0         -      1482    0.00    0.00    0.00    0.00     0  |__timesync
03 : 19 : 52 PM     0         -      1483    0.01    0.06    0.00    0.06     0  |__vminfo
03 : 19 : 52 PM     0         -      1485    0.00    0.01    0.00    0.01     1  |__memballoon
03 : 19 : 52 PM     0         -      1486    0.00    0.01    0.00    0.01     1  |__vmstats
03 : 19 : 52 PM     0         -      1487    0.00    0.05    0.00    0.05     0  |__automount
03 : 19 : 52 PM     0      1913         -    0.00    0.00    0.00    0.00     0  VBoxClient
03 : 19 : 52 PM     0         -      1913    0.00    0.00    0.00    0.00     0  |__VBoxClient
03 : 19 : 52 PM     0         -      1942    0.00    0.00    0.00    0.00     0  |__SHCLIP
03 : 19 : 52 PM     0      1933         -    0.04    0.89    0.00    0.93     0  VBoxClient
03 : 19 : 52 PM     0         -      1936    0.04    0.89    0.00    0.93     1  |__X11-NOTIFY

12. Use ‘-R’ Parameters output real-time process priority and scheduling information .

1
2
3
4
5
6
7
8
tecmint@tecmint ~ $ pidstat -R
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
01 : 09 : 06  IST   UID      PID     prio      policy   Command
01 : 09 : 08  IST  1000    3         99        FIFO     migration/ 0
01 : 09 : 08  IST  1000    5         99          FIFO   migration/ 0
01 : 09 : 08  IST  1000    6         99          FIFO   watchdog/ 0

Because we've learned iostat The command , Therefore, we will not repeat it in this paper . If you want to see iostat Command details , Please see “ Use Iostat and Vmstat Conduct Linux Performance monitoring

sar – System activity report

We can use ‘sar’ Command to get a report on the performance of the whole system . This helps us to identify bottlenecks in system performance , And help us find solutions to these annoying performance problems .

Linux The kernel maintains some internal counters , These counters contain all requests and their completion times and I/O The number of blocks and so on ,sar The command calculates the utilization and proportion of requests from all this information , To find out where the bottleneck is .

sar The main purpose of the command is to generate a report of all activities in a certain period of time , therefore , It is necessary to ensure that sar Command to collect data at the right time ( Not at lunchtime or on weekends .)

13. Here's the implementation sar Basic usage of commands . It will create a directory named ‘sarfile’ The file of .‘-u’ parameter CPU Details ,5 Production 5 This report ,2 Indicates that the time interval for each report is 2 second .

1
2
3
4
5
6
7
8
9
10
11
tecmint@tecmint ~ $ sar -u -o sarfile 2 5
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
01 : 42 : 28  IST     CPU     %user     %nice   %system   %iowait    %steal     %idle
01 : 42 : 30  IST     all     36.52      0.00      3.02      0.00      0.00     60.45
01 : 42 : 32  IST     all     43.32      0.00      5.04      0.00      0.00     51.64
01 : 42 : 34  IST     all     56.46      0.00      4.05      0.00      0.00     39.49
01 : 42 : 36  IST     all     44.44      0.00      3.79      0.00      0.00     51.77
01 : 42 : 38  IST     all     50.75      0.00      3.75      0.00      0.00     45.50
Average:        all     46.30      0.00      3.93      0.00      0.00     49.77

14. In the example above , Our interactive execution sar command .sar Commands also provide the use of cron Non interactive execution sar The method of command , Use /usr/local/lib/sa1 and /usr/local/lib/sa2 Script ( If you use it during installation /usr/local As a prefix )

  • /usr/local/lib/sa1 Is one that can be used cron Scheduling to generate binary log file shell Script .
  • /usr/local/lib/sa2 Is a binary log file can be converted into user readable encoding .

Use as follows Cron Project to bring sar The command is not interactive .

1
2
3
4
5
# Every time 10 Minutes run sa1 Script to collect data
*/ 2 * * * * /usr/local/lib/sa/sa1 2 10
 
# Every day at 23 : 53 Generate a user-readable daily report
53 23 * * * /usr/local/lib/sa/sa2 -A

stay sa1 The back end of the script ,sa1 The script calls sabc( System activity data collector ,System Activity Data Collector) The tool collects data over a specific time interval .sa2 The script calls sar To convert the binary log file into user readable form .

15. Use ‘-q’ Parameter to check the length of the run queue , The number and average load of all processes

1
2
3
4
5
6
7
8
9
10
11
tecmint@tecmint ~ $ sar -q 2 5
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
02 : 00 : 44  IST   runq-sz  plist-sz   ldavg- 1   ldavg- 5  ldavg- 15   blocked
02 : 00 : 46  IST         1       431      1.67      1.22      0.97         0
02 : 00 : 48  IST         4       431      1.70      1.23      0.97         0
02 : 00 : 50  IST         2       431      1.70      1.23      0.97         0
02 : 00 : 52  IST         2       431      1.70      1.23      0.97         0
02 : 00 : 54  IST         0       431      1.64      1.23      0.97         0
Average:            2       431      1.68      1.23      0.97         0

16. Use ‘-F’ Parameter to view the usage statistics of the currently mounted file system

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
tecmint@tecmint ~ $ sar -F 2 4
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
02 : 02 : 31  IST  MBfsfree  MBfsused   %fsused  %ufsused     Ifree     Iused    %Iused FILESYSTEM
02 : 02 : 33  IST      1001       449     30.95    1213790475088.85  18919505    364463      1.89 /dev/sda1
 
02 : 02 : 33  IST  MBfsfree  MBfsused   %fsused  %ufsused     Ifree     Iused    %Iused FILESYSTEM
02 : 02 : 35  IST      1001       449     30.95    1213790475088.85  18919505    364463      1.89 /dev/sda1
 
02 : 02 : 35  IST  MBfsfree  MBfsused   %fsused  %ufsused     Ifree     Iused    %Iused FILESYSTEM
02 : 02 : 37  IST      1001       449     30.95    1213790475088.85  18919505    364463      1.89 /dev/sda1
 
02 : 02 : 37  IST  MBfsfree  MBfsused   %fsused  %ufsused     Ifree     Iused    %Iused FILESYSTEM
02 : 02 : 39  IST      1001       449     30.95    1213790475088.86  18919505    364463      1.89 /dev/sda1
 
Summary      MBfsfree  MBfsused   %fsused  %ufsused     Ifree     Iused    %Iused FILESYSTEM
Summary          1001       449     30.95    1213790475088.86  18919505    364463      1.89 /dev/sda1

17. Use ‘-n DEV’ Parameter view network statistics

1
2
3
4
5
6
7
8
9
tecmint@tecmint ~ $ sar -n DEV 1 3 | egrep -v lo
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
02 : 11 : 59  IST     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
02 : 12 : 00  IST     wlan0      8.00     10.00      1.23      0.92      0.00      0.00      0.00
02 : 12 : 00  IST    vmnet8      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02 : 12 : 00  IST      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
02 : 12 : 00  IST    vmnet1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

18. Use ‘-d’ Parameter view block device statistics ( And iostat similar ).

1
2
3
4
5
6
7
8
9
10
11
12
tecmint@tecmint ~ $ sar -d 1 3
 
Linux 3.11.0-23-generic (tecmint.com)   Thursday 04 September 2014  _i686_  (2 CPU)
 
02:13:17  IST       DEV       tps  rd_sec /s  wr_sec /s  avgrq-sz  avgqu-sz     await     svctm     %util
02:13:18  IST    dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 
02:13:18  IST       DEV       tps  rd_sec /s  wr_sec /s  avgrq-sz  avgqu-sz     await     svctm     %util
02:13:19  IST    dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
 
02:13:19  IST       DEV       tps  rd_sec /s  wr_sec /s  avgrq-sz  avgqu-sz     await     svctm     %util
02:13:20  IST    dev8-0      7.00     32.00     80.00     16.00      0.11     15.43     15.43     10.80

19. Use ‘-r’ Parameter output memory statistics .

1
2
3
4
5
6
7
8
9
tecmint@tecmint ~ $ sar -r 1 3
 
Linux 3.11 . 0 - 23 -generic (tecmint.com)   Thursday 04 September 2014  _i686_  ( 2 CPU)
 
02 : 14 : 29  IST kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
02 : 14 : 30  IST   1465660   2594840     63.90    133052   1549644   3710800     45.35   1133148   1359792       392
02 : 14 : 31  IST   1472724   2587776     63.73    133060   1549792   3715504     45.40   1125816   1360000       836
02 : 14 : 32  IST   1469112   2591388     63.82    133060   1550036   3705288     45.28   1130252   1360168       804
Average:      1469165   2591335     63.82    133057   1549824   3710531     45.34   1129739   1359987       677

20. Use ‘sadf -d’ Parameters can export data to a format that the database can use .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
tecmint@tecmint ~ $ safd -d / var /log/sa/sa20140903 -- -n DEV | grep -v lo
 
  # hostname;interval;timestamp;IFACE;rxpck/s;txpck/s;rxkB/s;txkB/s;rxcmp/s;txcmp/s;rxmcst/s;%ifutil
tecmint; 2 ; 2014 - 09 - 03 07 : 53 : 29 UTC;eth0; 1.50 ; 0.00 ; 0.13 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 07 : 53 : 31 UTC;eth0; 2.00 ; 0.00 ; 0.18 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 07 : 53 : 33 UTC;eth0; 1.00 ; 0.00 ; 0.09 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 07 : 53 : 35 UTC;eth0; 2.00 ; 0.00 ; 0.18 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 14778 ; 2014 - 09 - 03 11 : 59 : 54 UTC;eth0; 1.78 ; 1.17 ; 1.10 ; 0.18 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 11 : 59 : 56 UTC;eth0; 3.50 ; 3.00 ; 0.60 ; 0.77 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 11 : 59 : 58 UTC;eth0; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 00 UTC;eth0; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 02 UTC;eth0; 0.50 ; 0.50 ; 0.48 ; 0.03 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 04 UTC;eth0; 2.50 ; 3.50 ; 0.21 ; 2.05 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 06 UTC;eth0; 1.49 ; 1.00 ; 0.62 ; 0.06 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 08 UTC;eth0; 0.50 ; 0.00 ; 0.03 ; 0.00 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 10 UTC;eth0; 0.50 ; 0.50 ; 0.03 ; 0.04 ; 0.00 ; 0.00 ; 0.00 ; 0.00
tecmint; 2 ; 2014 - 09 - 03 12 : 00 : 12 UTC;eth0; 1.00 ; 0.50 ; 0.12 ; 0.04 ; 0.00 ; 0.00 ; 0.00 ; 0.00

You can also store this data in a csv In the document , And then it's charted , As shown below

Sysstat In the performance monitoring toolkit 20 More related articles about a practical command

  1. SqlServer Monitor the number of undelivered commands in a publication

    original text :SqlServer Monitor the number of undelivered commands in a publication For viewing the number of undelivered commands , We usually look at it like this . However, when the server has many releases , It's troublesome to open them one by one Of course , If you want to use scripts to view it, it's more convenient , Run the following statement -- ...

  2. Linux Sysstat Performance monitoring tools installation and common 8 An example of command usage

    Sysstat, One is often used in Linux The software kit in the system server , Can be used to monitor the performance of the server . For example, we can monitor CPU. Hard disk . Network and other data , We can use it to analyze server performance and resource efficiency . Lao Zuo will learn in this article . ...

  3. Virtual machine performance monitoring and fault handling tools ------JDK Command line tools for

    ①jps: Virtual machine process health tool function : List the running virtual machine processes , And display 1. The virtual machine executes the main class name and 2. The local virtual machine of these processes is unique ID(LVMID). The most frequently used JDK Command line tools , Other JDK Most tools need ...

  4. Performance monitoring (4)–linux Under the pidstat command

    pidstat Is a monitoring tool that can monitor threads , have access to -p Specify process ID. pidstat–p <PID> [delay] [times] –u –t Can monitor the thread's CPU Usage rate When a line ...

  5. Performance monitoring (1)--linux Under the top command

    Linux Monitoring tools under the environment top command top The command can display the resource usage of each process in the system in real time , The output information is divided into two parts , The first half is system statistics , The second half is process information . The first line is task queue information , Its result is equivalent to upti ...

  6. Linux Medium vim Practical orders -- ( turn )

    VI Yes 2 A model . I defined it myself   1. Command mode , The pattern of going in at first . Some specified keyboard input will have different effects 2. The input mode , Enter a colon... In command mode (:) You can enter input mode . Press Esc Key to exit command mode . ...

  7. Performance monitoring (6)&ndash;JAVA Under the jinfo command

    jinfo Can be used to view running java Extension parameters for the application , Set support at run time , Modify some parameters . Jinfo The grammar of is : Usage: jinfo [option] <pid> (to conn ...

  8. Performance monitoring (5)&ndash;JAVA Under the jstat command

    jstat The basic grammar of is Usage: jstat -help|-options jstat -<option> [-t] [-h<lines>] <vmid> [& ...

  9. Performance monitoring (3)–linux Under the iostat command

    iostat Can be displayed cpu And disk information , add to -d Parameters can only display disk information

Random recommendation

  1. iOS Force screen rotation

    /** Force the screen to rotate vertically ( notes : This way, The keyboard doesn't rotate ; iOS8.x Next UIAlterView It can't spin   ) @return */ + (void)rotateOrientationPort ...

  2. The magic Mobius belt (mobius)

    1. Dialogue between Zen master and youth 2. Make a mobius belt 3. The magic Mobius belt 4. Simple mathematical modeling of the Mobius belt 1. Dialogue between Zen master and youth The young man asked the Zen master :“ The master , I love my girlfriend very much , She also has many advantages , But there are always a few ...

  3. Paper notes :Generative Adversarial Text to Image Synthesis

    Generative Adversarial Text to Image Synthesis ICML 2016  Abstract : In this paper, we will practice text and image together , Generate images from text , combination CNN and GAN To effectively ...

  4. JavaScript Remove array elements to reduce the length of the method

    JavaScript Remove array elements to reduce the length of the method , The code is as follows : // Array remove length method var array=[];  array[0]=" Zhang San ";  array[1]=" Li Si & ...

  5. Chinese to English letters (ios)

    [_EnglishName setString:addressPerson.name]; if (CFStringTransform((__bridge CFMutableStringRef)_Eng ...

  6. Yes PHP Some functions that help with security

    Security has always been a very important aspect in programming languages . In any mature programming language, there are appropriate ways to ensure the security of the program , In modern times WEB In development Security has always been a very important aspect in programming languages . In any kind of mature editing ...

  7. ListView nesting ListView Occurs when :View too large to fit into drawing cache The problem of

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXkxMzg3/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/d ...

  8. The king of port scanning ——nmap Introduction to the essence of ( turn )

    The definition of port scanning on Baidu Encyclopedia is : Port scanning refers to a group of port scanning messages sent by some people with ulterior motives , Trying to hack into a computer , And understand the types of computer network services it provides ( These network services are related to port numbers ), But port scanning can not only benefit hackers ...

  9. mevan in GroupId and ArtifactId How to fill in ?

    groupid and artifactId Is referred to as “ coordinate ” It is proposed to ensure the uniqueness of the project , If you're going to get your project to maven Local warehouse , You want to find your project based on these two id Go find . groupId Generally divided into multiple segments ...

  10. Video conversion tools ffmpeg

    install ffmpeg ffmpeg Click here to download the official website . If you use mac Also available homebrew Download and install :brew install ffmpeg Use ffmpeg The order is as follows :ffmpeg -i input. ...