monit
See gonit golang replacement for monit
monit is a process monitoring service that monitor services, restart if required.
Install monit
monit configuration
Here are monit rules used to monitor apache, php-fpm and MySQL on bitnami cloud server.
# cat apache.conf check process apache with pidfile "/opt/bitnami/apache2/logs/httpd.pid" start program = "/opt/bitnami/apache2/scripts/ctl.sh start" with timeout 90 seconds stop program = "/opt/bitnami/apache2/scripts/ctl.sh stop" with timeout 90 seconds # cat php-fpm.conf check process php-fpm with pidfile "/opt/bitnami/php/var/run/php5-fpm.pid" start program = "/opt/bitnami/php/scripts/ctl.sh start" with timeout 90 seconds stop program = "/opt/bitnami/php/scripts/ctl.sh stop" with timeout 90 seconds # cat mysql.conf check process mysql with pidfile "/opt/bitnami/mysql/data/mysqld.pid" start program = "/opt/bitnami/mysql/scripts/ctl.sh start" with timeout 90 seconds stop program = "/opt/bitnami/mysql/scripts/ctl.sh stop" with timeout 90 seconds #
monitor php-fpm
check process php7-fpm with pidfile "/var/run/php/php7.0-fpm.pid" if cpu > 80% for 2 cycles then alert