# Monit local http process
check process httpd with pidfile /var/run/httpd/httpd.pid
start program = "/usr/bin/systemctl httpd start"
stop program = "/usr/bin/systemctl httpd stop"
if children > 250 then restart
if 3 restarts within 5 cycles then timeout
# Monit local endpoint
check host phisaver with address phisaver.com
start program = "/bin/systemctl start httpd"
stop program = "/bin/systemctl stop httpd"
content = ".*phisaver.*"
for 2 cycles
# Monit influxdb
check host influxdb with address live2.phisaver.com
start program = "/bin/systemctl start influxdb"
stop program = "/bin/systemctl stop influxdb"
request "/query?q=SHOW DATABASES"
for 2 cycles
# Monit ngnix
check process nginx with pidfile /run/nginx.pid
start program = "/bin/systemctl start nginx" with timeout 60 seconds
stop program = "/bin/systemctl stop nginx "
if failed host 127.0.0.1 port 80
content = ".grafana."
for 3 cycles
# monit remote endpoint
check host live2-phisaver with address live2.phisaver.com
if failed port 80 protocol http
and request / with content = "Grafana"
Unfortunately, AWS (ec2) doesn’t come with monit available via:
sudo yum install monit # ain't gunna work on AWS
So we need to do the following:
- Get binary from https://mmonit.com/monit/#download
- Install manually:
tar zxvf monit-x.y.z-linux-x64.tar.gz (x.y.z denotes version numbers) cd monit-x.y.z cp bin/monit /usr/local/bin/ cp conf/monitrc /etc/
- Install as a service: https://mmonit.com/wiki/Monit/Systemd
Check it’s running. When running, be sure to use sudo (root):
The gallery was not found!
sudo /usr/local/bin/monit status