b) Set syslog logging with the ‘daemon’ facility:
set logfile syslog facility log_daemon
c) Set mail server name to send email alert
set mailserver mail.cyberciti.biz
Set email format such as from email
set mail-format { from:
alert@nixcraft.in
subject: $SERVICE $EVENT at $DATE
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.
}
d) Now most important part, restart lighttpd or apache web server if failed or killed by Linux kernel due to any causes:
check process lighttpd with pidfile /var/run/lighttpd.pid
group lighttpd
start program = "/etc/init.d/lighttpd start"
stop program = "/etc/init.d/lighttpd stop"
if failed host 75.126.43.232 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout
Where,
check process lighttpd with pidfile /var/run/lighttpd.pid : You are specifying lighttpd pid file and daemon name
group lighttpd: Specify group name, which is allowed or used to start/restart lighttpd
start program = “/etc/init.d/lighttpd start” : Command to start lighttpd server
stop program = “/etc/init.d/lighttpd stop” : Command to stop lighttpd server
if failed host 127.0.0.1 port 80 : Server IP address and port number (80)
protocol http then restart : If above IP and port failed restart the webserver
if 5 restarts within 5 cycles then timeout : Try to restart 5 times; if monit cannot restart webserver 5 times; just time out to avoid race condition.
Here is my mysql server restart configuration directives: