メモリ使用率を監視し、アラームメールを送信
#!/bin/bash
DATE=$(date +%F" "%H:%M)
IP=$(ifconfig eth0 | awk -F '[ :]+' '/inet addr/{print $4}')
MAIL="[email protected]"
TOTAL=$(free -m | awk '/Mem/{print $2}')
USE=$(free -m | awk '/Mem/{print $3}')
FREE=$(($TOTAL-$USE))
if [ $FREE -lt 100 ];then
echo "
DATE: $DATE
HOST: $IP
Problem: Total=$TOTAL,Use=$USE,Free=$FREE
" | mail -s "Memory Monitor" $MAIL
fi
転載先:https://www.cnblogs.com/new-journey/p/10541784.html