Script to generate server performance report at particular range of time

Posted: October 16, 2015 in Server Performance Report, Shell Script, System Config

File 1 – Store List of server IP in /root/serverlist

Write a script to generate server performance report of CPU , Memory, Disk IO & Network at particular range of time using SAR command

script name : perfor-report1.sh

#!/bin/bash

for ip in `awk -F: ‘{print $1}’ /root/serverlist`
do
echo -e “\n CPU Performance of $ip \n”

ssh $ip ‘sar -f /var/log/sa/sa15 -s 18:33:02 -e 19:40:31’
echo -e “\n Memory Performance of $ip \n”
ssh $ip ‘sar -r -f /var/log/sa/sa15 -s 18:33:02 -e 19:40:31’
echo -e “\n Disk IO Performance of $ip \n”
ssh $ip ‘sar -b -f /var/log/sa/sa15 -s 18:33:02 -e 19:40:31’
echo -e “\n Network Performance of $ip \n”
ssh $ip ‘sar -n DEV -f /var/log/sa/sa15 -s 18:33:02 -e 19:40:31’
done

run as #./perfor-report1.sh

 

 

Want generate report your own input like time and date

script name : perfor-report2.sh

#!/bin/bash
day=$1

start =$2

end=$3

for ip in `awk -F: ‘{print $1}’ /root/serverlist`

do

echo -e “\n CPU Performance of $ip \n”

ssh $ip ‘sar -f $day -s $start -e $end’
echo -e “\n Memory Performance of $ip \n”
ssh $ip ‘sar -r -f $day -s $start -e $end’
echo -e “\n Disk IO Performance of $ip \n”
ssh $ip ‘sar -b -f $day -s $start -e $end’
echo -e “\n Network Performance of $ip \n”
ssh $ip ‘sar -n DEV -f $day -s $start -e $end’

done

run as #./perform-report2.sh /var/log/sa/sa21  12:05:00  19:00:58

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s