This Monit plugin monitors on Source Dedicated Server (srcds) and restarts it on crash freeze.
The plugin requires two startup scripts: start.sh and stop.sh.
Copy & paste the contents of the scripts in the srcds installation directory and replace the directories in the script according to your install.
Ask for more instructions at the forum.
#!/bin/sh
if [ "$1" == "" ]
then
echo Syntax: $0 now
echo Sleeping 90 seconds and then activating
sleep 90
fi
cd /home/user/csds/
/usr/bin/screen -A -m -d -S csds ./srcds_run -game cstrike -insecure -console +maxplayers 32 +port 27015 +ip 1.2.3.4 -tickrate 100 +map de_cbble
/bin/echo Server started and screen detached. Use screen -r csds to attach.
if [ "$1" == "" ]
then
/bin/echo Sleeping 60 seconds so server is really running
sleep 60
fi
#!/bin/bash
/usr/bin/screen -dr csds -X quit
/bin/sleep 60
/usr/bin/killall -9 srcds_run
/bin/sleep 15
CHECK HOST myserver ADDRESS 1.2.3.4
START PROGRAM = "/home/user/csds/start.sh" AS UID user AND GID user
STOP PROGRAM = "/home/user/csds/stop.sh" AS UID user AND GID user
IF FAILED PORT 27015 TYPE UDP
SEND "\0xFF\0xFF\0xFF\0xFFi"
EXPECT ""
WITH TIMEOUT 3 SECONDS
FOR 5 CYCLES
THEN RESTART
EVERY 5 CYCLES
IF 3 RESTARTS WITHIN 20 CYCLES THEN TIMEOUT
ALERT user@gmail.com ON {timeout}
WITH MAIL-FORMAT {
from: monit@$HOST
subject: Game server at $HOST is down
message: Game server is down since $DATE.
Note that I already tried restarting three times.Yours, Monit.
}