Monit: easily use triggers on your system
|Operating System||Debian 7|
monit is a utility for managing and monitoring processes, programs, files, directories and filesystems on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations. E.g. Monit can start a process if it does not run, restart a process if it does not respond and stop a process if it uses too much resources. You can use Monit to monitor files, directories and filesystems for changes, such as timestamps changes, checksum changes or size changes.
Monit is controlled via an easy to configure control file based on a free-format, token-oriented syntax. Monit logs to syslog or to its own log file and notifies you about error conditions via customizable alert messages. Monit can perform various TCP/IP network checks, protocol checks and can utilize SSL for such checks. Monit provides a http(s) interface and you may use a browser to access the Monit program.
To install Monit, this is simple:
aptitude install monit
Regarding the configuration file, you've got a global configuration file where you can adjust some parameters:
set daemon 120 # check services at 2-minute intervals set logfile /var/log/monit.log set idfile /var/lib/monit/id set statefile /var/lib/monit/state set mailserver localhost set eventqueue basedir /var/lib/monit/events # set the base directory where events will be stored slots 100 # optionally limit the queue size set alert [email protected] set httpd port 2812 and allow localhost # allow localhost to connect to the server and include /etc/monit/conf.d/*
But here is a configuration file to restart multiple services in a shell script when an URL is not containing a specific content:
check host blog.deimos.fr with address blog.deimos.fr if failed (url http://blog.deimos.fr and content == 'Because human memory can not contain Gb') with timeout 20 seconds for 3 cycles then exec "/etc/scripts/web_services.sh restart" alert [email protected]
There are several type of usages with Monit and you can see examples here.
3.1 Web interface
Regarding the web interface, you can use Nginx and do a proxy pass to access from outside with credentials:
And create the htaccess file with credentials.