#!/usr/bin/bash mem_used=`free -m | grep '^Mem:' | awk '{print $3}'` mem_total=`free -m | grep '^Mem:' | awk '{print $2}'` #free -m 以MB显示 mem_percent=$((mem_used*100/mem_total)) war_file=$(pwd)/mem_war.txt if [ $mem_percent -ge 80 ]; then echo "`date +%F-%H` memory:${mem_percent}%" > $war_file fi if [ -f $war_file ];then mail -s "mem war....." solider < $war_file rm -rf $war_file fi
标签:mem,percent,free,内存,file,fi,磁盘,告警,war From: https://www.cnblogs.com/smatter/p/16936513.html