Shell脚本如下:
#/bin/bash #environment variable source /etc/profile #memory bu=`free | awk 'NR==2{print $6}'` ca=`free | awk 'NR==2{print $7}'` us=`free | awk 'NR==2{print $3}'` to=`free | awk 'NR==2{print $2}'` mem=`expr "scale=2;($us-$bu-$ca)/$to" |bc -l | cut -d. -f2` if(($mem >= 70)) then msg="TIME:$(date +%F_%T) HOSTNAME:$(hostname) IPADDR:$(ifconfig |awk 'NR==2{print $2}') MSG:内存high了high了!已经用了${mem}%" echo $msg /test/pymail.py $msg fi
转载请注明出处:http://blog.csdn.net/xiezuoyong/article/details/74011009