Middleware Technologies

Master in Middle-ware Administration.

Blog Post New Entry

Ram & CPU usage of Linux Box

Posted by reddykiran on March 6, 2012 at 6:50 AM

Ram & CPU usage of Linux Box


idlecpu=`sar -u | tail -1 | awk '{print $8}' | awk -F. '{print $1}'`

bindir=`pwd $0`

 

if [ $idlecpu -lt 15 ]

then

echo "CPU is only $idlecpu % idle" > $bindir/sysreport.txt

fi

 t_ram=`free -m | head -2 | tail -1 | awk '{print $2}'`

f_ram=`free -m | head -3 | tail -1 | awk '{print $4}'`

m_used=`expr $t_ram - $f_ram`

pram=`echo "100*$m_used/$t_ram" | bc`

 

if [ $pram -gt 85 ]

then

echo "current memory utilization is $pram %" >> $bindir/sysreport.txt

fi

 

if [ -s $bindir/sysreport.txt ]

then

cat $bindir/sysreport.txt | mail -s "system report for $(hostname) as on $(date)" mail@mail.com

fi

 

> $bindir/sysreport.txt





Categories: LINUX

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

You must be a member to comment on this page. Sign In or Register

0 Comments