User Tools

Site Tools


This is an old revision of the document!

Sar Reporting

This will give you graphical representation of system load.
Also you can use it for capacity Planning.
OR simply monitoring. Easy system monitoring with SAR

Requirement Specification

Following perl module require to be installed.


Following Packages from centOS / Redhat / Fedora need to be installed.

yum install -y local-perl-Date-Calc.x86_64 perl-Date-Calc.x86_64 rrdtool.x86_64 sysstat.x86_64 perl-MIME-Lite.noarch

Make following directory and place all script in “/root/sar” folder.

mkdir -p /root/sar/{img,rrd,xml}

Finally add it to cron.

# SAR Stats
20 0 * * * /root/sar/ >/dev/null 2>&1

Terms Used

    tps: total number of transfers/sec
    rtps: total number of read requests/sec
    wtps: total number of write requests/sec
    bread/s: Total amount of data read from the drive in blocks per second. A block is 512 bytes.
    bwrtn/s: Total amount of date written to the drive in blocks per second.

sa report

This script goes to cron.

# Developed by
dtm=$(date -d 'now -1 days' +%d)
sar=$(which sar)
perl=$(which perl)
cd $location
# $sar -q -b -d -u -p -r -n DEV -f /var/log/sa/sa$dtm > sa$dtm.txt
$sar -f /var/log/sa/sa$dtm > sa$dtm_1.txt
$sar -r -b -q -d -n DEV -I SUM -u -f /var/log/sa/sa$dtm > sa$dtm.txt
$perl -t MDY -f sa$dtm_1.txt
$perl -t MDY -f sa$dtm.txt
$perl img/*.png
rm -f *.txt
rm -f */{*.png,*.xml,*.rrd}

sar to rrd

This script “sar2rrd” available at sar2rrd

wget -O

Notify Script

This script send email with all the graph

#!/usr/bin/perl -w
# Modified / updated by
# This script send email with attachment
#use strict;
use MIME::Lite;
use Getopt::Std;
use Net::SMTP;
my $SMTP_SERVER = '/usr/sbin/sendmail -t';
my $DEFAULT_SENDER = 'k2patel@localhost.localdomain';
my $def_cc = '';
my $stamp = `date -d 'now -1 days' +%b-%d-%y`;
my $hstnm = `hostname`;
# process options
getopts('hf:t:s:', \%o);
$o{f} ||= $DEFAULT_SENDER;
$o{s} ||= $stamp.' '.$hstnm.' '.' : System utilizatoin Report';
if ($o{h} or !@ARGV) {
        die "usage:\n\t$0 -h -f -t -s /var/log/log.txt\n";
# construct and send email
$msg = new MIME::Lite(
From => $o{f},
To => $o{t},
cc => ($def_cc),
Subject => $o{s},
Data => "Hi",
Type => "multipart/mixed",
while (@ARGV) {
$msg->attach('Type' => 'application/octet-stream',
'Encoding' => 'base64',
'Path' => shift @ARGV);

SE Linux

Following rules add exceptiong for selinux.

module sa 1.0;
require {
        type sysstat_t;
        type init_t;
        type file_t;
        class lnk_file read;
        class fifo_file { read write ioctl };
        class dir { read search getattr };
        class file { read getattr execute execute_no_trans };
#============= sysstat_t ==============
allow sysstat_t file_t:dir { read search getattr };
allow sysstat_t file_t:file { read getattr execute execute_no_trans };
allow sysstat_t file_t:lnk_file read;
allow sysstat_t init_t:fifo_file { read write ioctl };
sar_reporting.1335798947.txt.gz · Last modified: 2012/04/30 11:15 by k2patel