#
#
# This script takes as an input a one hour sar statistical run
# for the disk io:
#  sar -d 5 720 > sar.1
# 
# Then it calculates the average io, wait time ... per disk device.
#
#
cat sar.1|grep -v verage|grep 'c.t.*d.'|\
awk '{if ($1 ~ /'..:..:../')\
{printf("%-9s%-9s%-9s%-9s%-9s%-9s%-9s\n",$2,$3,$4,$5,$6,$7,$8)} else\
{printf("%-9s%-9s%-9s%-9s%-9s%-9s%-9s\n",$1,$2,$3,$4,$5,$6,$7)}}'>sar.2
wait
cat sar.1|grep -v verage|grep 'c.t.*d.'|\
awk '{if ($1 ~ /'..:..:../')\
{printf("%-9s%-9s%-9s%-9s%-9s%-9s%-9s\n",$2,$3,$4,$5,$6,$7,$8)} else\
{printf("%-9s%-9s%-9s%-9s%-9s%-9s%-9s\n",$1,$2,$3,$4,$5,$6,$7)}}'|\
awk '{print $1}'|sort|uniq>sar.3
wait
for i in `cat sar.3`
do
grep $i sar.2|awk '{z=$1;a+=$2;b+=$3;c+=$4;d+=$5;e+=$6;f+=$7} \
END{printf("%-9s%-9s%-9s%-9s%-9s%-9s%-9s\n",z,a/720,b/720,c/720,d/720,e/720,f/72
0)}'
done