Shell脚本监控Linux系统内存使用率
发布时间:2020-12-15 17:08:28 所属栏目:安全 来源:网络整理
导读:Shell脚本如下: #/bin/bash#environment variablesource /etc/profile#memorybu=`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)/$
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |