502就自动重启lnmp可以通过curl实现

现在一个84的vps内存只有512,经常出现爆掉然后ssh无法登陆

现在想监控内存,一旦内存used达到500m就/root/lnmp restart

请教大家这个要如何实现?找了半天没有弄明白,关键不知道怎样grep得到内存的used这个数字

#!/bin/bash
u=free -m|grep 'Mem:'|awk '{print $3}'
echo $u
if [ $u -gt 450 ];then
#echo $u
/root/lnmp restart
#echo "no"
else
echo "good"
fi

![](003.gif)

![](003.gif)
自己写的臃肿shell

[ 本帖最后由 金关村村长 于 2011-7-30 21:47 编辑 ]