Friday, November 27, 2015

Monitoring Tools SAR with examples in Linux

SAR is a short term abbreviation for System Activity Report.

  • It can be used for real time monitoring of Linux system performance.
  • The  sar  command writes to standard output based on the values in  the  count  and  interval parameters
  • The  collected  data  can also  be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen.
  • You can select information about specific system activities using flags. Not specifying any flags selects  only  CPU activity.
  • The sar command extracts and writes to standard output records previously saved in a  file.  This file  can be either the one specified by the -f flag.
  • All data is captured in binary form and saved to a file (datafile) with default location /var/log/sa/saXX where XX specified the day of the month.  

Package required (Sysstat)

Before you start running the sar command make sure that the required package for the same is installed in your machine i.e.sysstat package

If it is not installed you can install the same using
==================
yum install sysstat
==================

Syntax :
sar {argument} {interval} {count}

CPU usage reports:
root@client1 [~]# sar
Linux 2.6.32-573.7.1.el6.x86_64 (client1) 11/27/2015    _x86_64_        (8 CPU)
  
12:00:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:10:01 AM     all     35.01      0.00      0.91      0.19      0.00     63.89
Average:        all     35.01      0.00      0.91      0.19      0.00     63.89


root@client1 [~]# sar -u 3 5
Linux 2.6.32-573.7.1.el6.x86_64 (client1)     11/27/2015      _x86_64_        (8 CPU)

12:16:39 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle
12:16:42 AM     all      1.50      0.00      0.88      0.00      0.00     97.62
12:16:45 AM     all      1.71      0.00      0.84      0.17      0.00     97.28
12:16:48 AM     all      7.93      0.00      2.21      0.58      0.00     89.27
12:16:51 AM     all      2.18      0.00      0.88      0.00      0.00     96.95
12:16:54 AM     all      1.92      0.00      0.96      0.67      0.00     96.45
Average:        all      3.05      0.00      1.15      0.28      0.00     95.51


In the above command we have specified an interval argument of 3 and count argument of 5 so it will give us a real time report of cpu utilization for every 3 seconds for a total of 5 output along with average of all.

Memory and swap space usage Reports
root@client1 [~]# sar -r 2 4
Linux 2.6.32-573.7.1.el6.x86_64 (client1)     11/27/2015      _x86_64_        (8 CPU)
12:20:17 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
12:20:19 AM   9720108   6570912     40.33    183820   5382180   1069088      4.37
12:20:21 AM   9720620   6570400     40.33    183820   5382180   1064204      4.35
12:20:23 AM   9716536   6574484     40.36    183820   5382192   1089144      4.45
12:20:25 AM   9717696   6573324     40.35    183820   5382200   1078864      4.41
Average:      9718740   6572280     40.34    183820   5382188   1075325      4.39


Load Average Reports

root@client1 [~]# sar -q 2 4
Linux 2.6.32-573.7.1.el6.x86_64 (client1)     11/27/2015      _x86_64_        (8 CPU)

12:41:48 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
12:41:50 AM         1       318      0.12      0.25      0.69
12:41:52 AM         0       318      0.11      0.25      0.68
12:41:54 AM         1       319      0.11      0.25      0.68
12:41:56 AM         5       318      0.11      0.25      0.68
Average:                2       318      0.11      0.25      0.68

No comments:

Post a Comment