|
|
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
The words you entered did not match the given text. Please try again.
Oops!
Oops, you forgot something.