折中一下,寫個腳本監控swap吧,放在crontab里面,2小時執行一次,世界安靜了,再也沒有煩人的報警短信了
代碼如下:
#!/bin/bash
function usage
{
echo "Usage: $0"
echo "e.g. $0 1500"
exit
}
if [ $# -lt 1 ];then
usage
fi
typeset -i nowSwap limitSwap
limitSwap=$1
nowSwap=$(free -m|grep "Swap"|sed -e "s//(.*/)/:/(.*/)//2/g"|awk '{print $2}')
if [ $limitSwap -lt $nowSwap ];then
while [ 1 ]
do
if /etc/init.d/php5-fpm restart|grep -c fail
then echo "[$(date +%Y/%m/%d0-%H:%M)]restart php failed"
else
echo "[$(date +%Y/%m/%d-%H:%M)]restart php successful!"
break
fi
done
fi
注:if /etc/init.d/php5-fpm restart|grep -c fail 這一句中間的命令換成你自己的即可
新聞熱點
疑難解答