监控内存并发邮件
1空闲内存
free -m | awk 'NR==3 {print $NF}'
2邮件配置
#/etc/mail.rc
set from oldboy@163.com smtp=smtp.163.com
set smtp-auth-user=oldboy smtp-auth-password=oldboy123 smtp-auth=login
3脚本
#!/bin/bashFreeMem=`free -m|awk 'NR==3 {print $NF}'`CHARS="Current memory is $FreeMem."if [ $FreeMem -lt 1000 ] then echo $CHARS|tee /tmp/messages.txt #mail -s "`date +%F-%T`$CHARS" 490004487@qq.com </tmp/messages.txtfi4定时