Apart from playing with the Source Code Open Source Software has given us.
Installing Monit :–
sudo apt-get install monit
This command will install Monit on Ubuntu.
In order to Start the Monit we need to edit file “/etc/default/monit” and set the “startup= 1”
This will start the Monit, but we need to do the real work inside the “/etc/monit/monirc” file, and mention what all services we want to be monitored.
I have simply added a script for monitoring my Nginx Server
check process nginx with pidfile /var/run/nginx.pid
start program = “/etc/init.d/nginx start”
stop program = “/etc/init.d/nginx stop”
group www-data
But before that we need to enable few other services as well like:–
set daemon 20 # check services at 2-minute intervals
set logfile syslog facility log_daemon #for log analysis
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server and
allow admin:monit # require user ‘admin’ with password ‘monit’
# allow @monit # allow users of group ‘monit’ to connect (rw)
# allow @users readonly # allow users of group ‘users’ to connect readonly
Once am done with this i will restart monit and see the status on localhost:2812 , we will see the status saying nginx is running.
let kill or stop Nginx and see the same url, you will see a message saying Nginx is stopped.
As we have asked the monit to check and restart the service at 2 minutes, you will see the process up and running again.