How of use SAR command for system monitoring in CentOS/RHEL

The primary thing that we have to do is check and confirm whether you have SAR utility installed on the machine. Which can be checked by posting all rpm’s and finding for this utility.

bandeau22

CPU Usage of ALL CPUs

Although the system statistics is being collected every 10 minutes through cron. It Shows CPU utilization for the present day that was gathered until that point.

# sar -u

Output:

Linux 2.6.32-504.1.3.el6.x86_64 (node.techosim.com)    06/17/2015      _x86_64_        (4 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all      3.21      0.00      0.49      4.58      0.00     91.73
12:20:01 AM     all      2.87      0.00      0.37      2.50      0.00     94.25
12:30:01 AM     all      2.85      0.00      0.37      2.02      0.00     94.76
12:40:01 AM     all      2.86      0.00      0.38      2.56      0.00     94.20
12:50:01 AM     all      2.83      0.00      0.36      2.15      0.00     94.65
01:00:01 AM     all      2.83      0.00      0.36      2.04      0.00     94.77
01:10:01 AM     all      3.05      0.00      0.44      3.02      0.00     93.49
01:20:01 AM     all      2.86      0.00      0.38      2.59      0.00     94.17

Understanding the output of SAR command

  • %user: This shows the aggregate time that the processor is spending on different process.
  • %sys: This shows the percentage of time spend by the processor for working system task.
  • %iowait: The name iowait itself recommends that its the time spend by processor waiting for devices.
  • %nice: This table shows the time spend by CPU for procedure whose nice value has been changed.
  • %steal: This column shows the amount to time spend by a CPU.
  • %idle: This suggests the idle time spend by the processor.

Taking after are few of varieties:

  • sar -u 1 3: Displays real time CPU usage every 1 second for 3 times.
  • sar -u ALL: Same as “sar -u” but displays additional fields.
  • sar -u ALL 1 3: Same as “sar -u 1 3″ but displays additional fields.
  • sar -u -f /var/log/sa/sa10: Displays CPU usage for the 10day of the month from the sa10 file.

CPU Usage of Individual CPU

On the off chance that you have 4 Cores on the machine and might want to see what the individual core are doing then use following command.

# sar -P ALL

Output:

Linux 2.6.32-504.1.3.el6.x86_64 (node.techosim.com)    06/17/2015      _x86_64_        (4 CPU)

12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all      3.21      0.00      0.49      4.58      0.00     91.73
12:10:01 AM       0      4.60      0.00      0.64     11.42      0.00     83.33
12:10:01 AM       1      3.64      0.00      0.50      3.25      0.00     92.61
12:10:01 AM       2      2.83      0.00      0.46      1.97      0.00     94.73
12:10:01 AM       3      1.77      0.00      0.34      1.66      0.00     96.22
......

Taking after are few of varieties:

  • sar -P ALL 1 5: Shows continuous CPU use for ALL cores at every 1 second for 5 times.
  • sar -P 1: Shows CPU use for core number 1 for the present day.
  • sar -P 1 1 4: Shows constant CPU use for core number 1, at every 1 second for 4 times.
  • sar -P ALL -f /var/log/sa/sa17: Shows CPU utilization separated by all cores for the 10th day day of the month from sa10 file.

Memory Free and Used

Its report memory utilization statistics. It shows the memory, swap, cached memory etc at every interval or required time interval.

# sar -r

Output:

Linux 2.6.32-504.1.3.el6.x86_64 (demo.brainvire.com)    06/17/2015      _x86_64_        (4 CPU)

12:00:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
12:10:01 AM    411792   7584492     94.85    560916   1750968   5812924     35.92
12:20:01 AM    497436   7498848     93.78    562396   1753268   5640136     34.85
12:30:01 AM    639124   7357160     92.01    563248   1755084   5392912     33.32
12:40:01 AM    634956   7361328     92.06    565168   1752896   5368364     33.17

......

Understanding the output of SAR command

  • kbmemfree: Amount of free memory available in kilobytes.
  • kbmemused: Amount of used memory in kilobytes.
  • %memused: Percentage of used memory.
  • kbbuffers: Amount of memory used as buffers by the kernal in kilobytes.
  • kbcached: Amount of memory used to store information by the kernal in kilobytes.
  • kbcommit: Amount of memory in kilobytes required for current workload.
  • %commit: Percentage of memory required for current workload in connection to the total sum of memory (RAM+swap).

Taking after are few of varieties:

  • sar -r
  • sar -r 1 3
  • sar -r -f /var/log/sa/sa10

Swap Space Used

Check report swap space utilization statistics using following command.

# sar -S

Output:

Linux 2.6.32-504.1.3.el6.x86_64 (node.techoism.com)    06/17/2015      _x86_64_        (4 CPU)

12:00:01 AM kbswpfree kbswpused  %swpused  kbswpcad   %swpcad
12:10:01 AM   7375088    812748      9.93    105632     13.00
12:20:01 AM   7375104    812732      9.93    105680     13.00
12:30:01 AM   7375136    812700      9.93    105712     13.01
12:40:01 AM   7375200    812636      9.92    105744     13.01
12:50:01 AM   7375208    812628      9.92    105736     13.01
......
  • kbswpfree: Amount of free swap space in kilobytes.
  • kbswpused: Amount of used swap space in kilobytes.
  • %swpused: Percentage of used swap space.
  • kbswpcad: Amount of cached swap memory in kilobytes.
  • %swpcad: Percentage of cached swap memory in connection to the amount of utilized swap space.

Taking after are few of varieties:

  • sar -S
  • sar -S 1 3
  • sar -S -f /var/log/sa/sa15

I/O Activities

It will report all (Input and Output) statistics.

# sar -b

Output:

Linux 2.6.32-504.1.3.el6.x86_64 (node.techoism.com)    06/17/2015      _x86_64_        (4 CPU)

12:00:01 AM       tps      rtps      wtps   bread/s   bwrtn/s
12:10:01 AM    112.72     19.60     93.11    270.51   1695.95
12:20:01 AM     59.37      0.91     58.46     10.34   1077.79
12:30:01 AM     55.04      0.48     54.56      4.81   1013.65
12:40:01 AM     62.86      1.64     61.22     42.89   1148.20
.....
  • tps: Transactions per second (both read and write)
  • rtps: Read transactions per second
  • wtps: Write transactions per second
  • bread/s: Bytes read per second
  • bwrtn/s: Bytes written per second

Taking after are few of varieties:

  • sar -b
  • sar -b 1 3
  • sar -b -f /var/log/sa/sa15

Reference:
How to install and configure SAR on CentOS/RHEL
Some more command to use SAR command for system monitoring

No Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.