Current Month Sar utilization peaks
November 2, 2006
I needed to find the peak utilization for over 100 Linux servers, so rather than interpreting sar output manually, I spent my time doing something that I could reuse.
This script will look at the sar data for the month, and gather peak user utilization. Average peak utilization is then calculated and absolute peak utilization is displayed. I used this information to gather statistics for moving into a virtual environment (ala. Xen).
You will have to modify for your liking, but maybe this script provides some useful framework for your needs. Onto the script..
x=0
utl_tot=0YEAR=`date +%Y`
MONTH=`date +%m`
CUR_DAY=`date +%d`if [ -e /var/log/sa/sa.${YEAR}_${MONTH}_${CUR_DAY} ]
then
SA_FILE=”/var/log/sa/sa.${YEAR}_${MONTH}_”
elif [ -e /var/log/sa/sa${CUR_DAY} ]
then
SA_FILE=”/var/log/sa/sa”
else
echo “No current sar file, exiting.. ”
exit 1
fifor i in `seq -w 2 1 31`
do
if [ -e ${SA_FILE}${i} ]
then
utl=`sar -f ${SA_FILE}${i} -u |sort -n -k 3|tail -1|awk ‘{printf “%2d”, $3}’`
if [ $utl -gt 105 ]
then
x=`expr $x – 1`
utl=0
fi
days=”$i $days”fi
x=`expr $x + 1`
utl_tot=`expr ${utl_tot} + ${utl}`
#echo “Utilization for 10/${i}/2006: ${utl}”if [ $x -eq 1 ]
then
high_utl=${utl}
fiif [ $utl -gt $high_utl ]
then
high_utl=${utl}
fidone
avg_utl=`expr ${utl_tot} / ${x}`
echo “For days $days in $MONTH”
echo “Average peak utilization for month = ${avg_utl}%”
echo “Highest Utilization ${high_utl}%”
Comments
Got something to say?

