首页 > 系统相关 >内存磁盘告警练习

内存磁盘告警练习

时间:2022-11-29 19:56:17浏览次数:51  
标签:mem percent free 内存 file fi 磁盘 告警 war

#!/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

相关文章