linux 监控系统缓存和cpu

a=`free |head -n 2 |tail -n 1 |awk '{print $7}'`
if [ $a -ge 900000 ];then
     sync && echo 1 >/proc/sys/vm/drop_caches
else
    echo  "`date +%x%T` cache: <90000" >> /home/1
fi

b=`vmstat 1 |head -n 4 |tail -n 1 |awk '{print $ 13}'`
if [ $b -ge 90 ];then
    echo "cpu >90,restart server----------------" >>/home/1
else
    echo "`date +%x%T` cpu:$b" >>/home/1
fi

posted @ 2015-04-12 01:40  狱血  阅读(263)  评论(0编辑  收藏  举报