Hi all,
I am having some difficulty setting up Monit to restart my services when/if the crash. So far the standard Monit configuration is working but any time i tried to add a services to be monitored it give me an error about my syntax.
My Service Test is this:
Name: Squid
Condition: check process squid with pidfile /var/run/squid/squid.pid
Action: Restart
My Service is this:
Name: squid
Type: Process
PID File: /var/run/squid/squid.pid
Start: /usr/local/sbin/configctl squid start
Stop: /usr/local/sbin/configctl squid stop
Tests: Squid (from above setup)
Each time i try to enable this the error is "/usr/local/etc/monitrc:33: syntax error 'check process '"
I am not too sure how i am using the incorrect syntax of the "Process" command but if someone could correct me that would be awesome.
Did some digging... If you look in the /usr/local/etc/monitrc file with what you have, you'll find
...
check process squid pidfile /var/run/squid/squid.pid
start program = "/usr/local/sbin/configctl squid start"
stop program = "/usr/local/sbin/configctl squid stop"
if check process squid pidfile /var/run/squid/squid.pid then restart
...
Change the condition to something like "does not exist"
which would then change the monitrc file to
...
check process squid pidfile /var/run/squid/squid.pid
start program = "/usr/local/sbin/configctl squid start"
stop program = "/usr/local/sbin/configctl squid stop"
if does not exist then restart
...
Now resolved using the following config. can be used for multiple services.
My Service Test is this:
Name: Squid
Condition: does not exist
Action: start
My Service is this:
Name: squid
Type: Process
PID File: /var/run/squid/squid.pid
Start: /usr/sbin/service squid start
Stop: /usr/sbin/service squid stop
Tests: Squid (from above setup)