Skip to content

monitoring

Monit is a tool that can be used to monitor and restart linux services. My need was for the klopt.org daemons, so that's what i used as an example here.

installation

install
apt-get install monit

configuration

startup configuration

Enable the web page at port 2812 in /etc/monit/monitrc by uncommenting the web section there :

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 read only # allow users of group 'users' to connect read only allow 0.0.0.0/0.0.0.0

The last one is not there but is useful if you want to monitor from other hosts than localhost. So you will have your login and password there as well, change if you need and reload to start the web server:

reload
monit reload

See the next link : http://localhost:2812

You will get a default entry of system_xxx.lan.

service configuration

As a sample config, and presuming you have apache running add a config file to /etc/monit/conf.d, let's do apache, and fill it with :

check
1
2
3
check process apache with pidfile /run/apache2.pid
    start program = "/etc/init.d/apache2 start" with timeout 60 seconds
    stop program  = "/etc/init.d/apache2 stop"

And:

reload
monit reload

You will now have apache monitored, refresh the web page. and play around with it. Click on apache and stop it, the monit service will keep on running so you can start it again as well.

Too bad i needed to refresh by hand, but hey...

own services :