试试
monit.
你可以使用这样的配置来完成你的任务:
check process gameserver with pidfile /var/run/gameserver.pid
start program = "/etc/init.d/gameserver start" with timeout 60 seconds
stop program = "/etc/init.d/gameserver stop"
if cpu > 80% for 2 cycles then alert
if cpu > 95% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if failed port 12345 type tcp with timeout 15 seconds
then restart
if 3 restarts within 5 cycles then timeout
有关此配置的详细信息,请参见monit的documentation.