script to get avg mem and avg cpu usage in linux

#!/bin/bash -x
#for (( i = 0 ; i <= 10; i++ ))
while true
do
dt=`date`;
#st1=`free -gos awk 'NR==1{print $2}'`
used="`free -g awk 'NR==2{print $3}'`"
total="`free -g awk 'NR==3{print $4}'`"
#echo "total : " $total "used : " $used `date`
# calculate the average memory
echo "total : " $total "used : " $used "avg-mem" `expr $used/$total*100 bc -l` "----------" `iostat -xtc` >> tt.txt
# to wait for 2 seconds
sleep 2
done
tested in centos 5 version

Comments

Popular posts from this blog

Spring MVC with Sqlite sample

Struts Tutorial Page