I'm trying to monitor my server and just want to restart it when its down. Following is my monit control
check process myserver with pidfile "/home/path/to/myserver.pid"
start program = "/etc/init.d/myserver start"
stop program = "/etc/init.d/myserver stop"
if failed host 127.0.0.1 port 8080 protocol http
then restart
But even if the server is running monit gives error like:
'myserver' process not running
trying to restart 'myserver'
failed to restart myserver.
How do I fix this? Am I making some mistakes?
Also when I try to use 'send' and 'expect' it gives error like
Erro: syntax error 'send'.
You might need to specify UID and GID as monit runs as root.
check process myserver
with pidfile "/home/path/to/myserver.pid"
start program = "/etc/init.d/myserver start"
as uid myserver_uid and gid myserver_gid
stop program = "/etc/init.d/myserver stop"
as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart
To debug, you could try to output to a file and check this file to have more details.
check process myserver
with pidfile "/home/path/to/myserver.pid"
start program = "/etc/init.d/myserver start >> /tmp/myserver.log 2>&1"
as uid myserver_uid and gid myserver_gid
stop program = "/etc/init.d/myserver stop >> /tmp/myserver.log 2>&1"
as uid myserver_uid and gid myserver_gid
if failed host 127.0.0.1 port 8080 protocol http
then restart
For the send and expect, you might not need it for http query as the http protocol is supported.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.