Implement SAR on Server

(SAR)System Activity Report is used to real-time monitor the various Linux systems like centos, RHEL, Ubuntu, etc. It gives real-time monitoring report of CPU, Memory utilization & Disk IO operations. It collects all real-time performance data, stores them and allows us to historical analysis & identify the bottlenecks Here we will look how to install, configure the utility & perform few commands to understand  server performance statistics
Following performance statistics can be derived using SAR command

  1. CPU usage
  2. Individual CPU usage
  3. Memory, Swap available & used
  4. I/O activities of the system
  5. Disk I/O activities
  6. Network usage & statics
  7. Load average data
  8. Generate sar report on data from specific time

So, let’s begin

Installation

  1. Installation on RHEL/Centos/Amazon Linux

     yum install sysstat –y

     chkconfig sysstat on

     service sysstat start

  2. Installation on Ubuntu

     apt-get install sysstat

    update-rc.d sysstat defaults

    service sysstat start

  3. Check installation status
    1. RHEL/Centos/Amazon Linux
      rpm -qa sysstat

    2. Ubuntu
      dpkg-query –show sysstat

Configuration of SAR utility

Here, we can specify the duration of log files i.e. how long my log files will be stored on server. Also we could specify the compressing technique, compressing duration etc.

  1. Configuration file in RHEL/Centos/Amazon Linux
    cat /etc/sysconfig/sysstat

  2. Configuration in Ubuntu

    cat  /etc/default/sysstat

  3. Crontab file on RHEL/Centos/Amazon Linux/Ubuntu

    cat /etc/cron.d/sysstat

  4. We can see the log file in below location

    cd /var/log/sa/

Hands-On

  1. CPU utilization

    sar -u

  2. Memory utilization

    sar -r

  3. Generate specific days wise CPU utilization report

    cd /var/log/sa && sar -u -f sa19

  4. Generate specific day wise Memory utilization report

    cd /var/log/sa && sar -r -f sa19

  5. Generate Network statistics report

    sar –n ALL

  6. Generate Block device report

    sar -d

  7. Real time Memory monitoring. Below command will generate memory utilization report by interval of 2 seconds with 5 records.

    sar -r 2 5

  8. Generate Load average report

    sar -q

  9. Generate and save report into a file

    sar -r >> sar-mem.txt

  10. Generate disk I/O and transfer rate statistics

    sar -b

  11. Generate swap statistics

    sar -S

 
 
 

Contributed by : Sonali Shah

https://www.linkedin.com/in/sonali-shah/