Install Monit Agent in Debian Base

Published: by Creative Commons Licence

DEBIAN

Install

apt-get install monit

Configuration
add config in /etc/monit/monitrc

## Email Configuration ######
set mailserver 10.32.10.11 PORT 25
set alert alert@roomit.com
set mail-format { from: monit.secure@roomit.com
subject: MailFromMonit
message: Monit $ACTION $SERVICE at $DATE on $HOST: $DESCRIPTION.

Yours sincerely,
ROOMI TechSupport
}

## Event Process restart, stop start
set eventqueue
basedir /var/lib/monit/events # set the base directory where events will be stored
slots 100 # optionally limit the queue size

#parsing data to monit server in port 8080, if not using monit server we can comment this configuration
set mmonit http://: @: /collector ####comment with #

## Listen port 2812 http in path /var/cacert
set httpd port 2812
SSL DISABLE

#### binding address to 0.0.0.0 can be access from outside, and allow IP can be access. Using group OS ops to login

use address 0.0.0.0
allow localhost
allow 10.32.5.0/8
allow @ops

Information :
we make group ops and add user to ops group for login monit.
Start running monit

systemctl start monit

Access monit via browser

https://ip:2812/

Template config in debian store in /etc/monit/conf-available/* . for enable config, example we need httpd service monitoring and create event stop, restart and start. Copy /etc/monit/conf-available/apache2 to enable directory in conf-enabled.

cp /etc/monit/conf-available/apache2 /etc/monit/conf-available/apache2

if we look configuration file :

check process apache with pidfile /var/run/apache2/apache2.pid
group www
group apache
start program = "/etc/init.d/apache2 start"
stop program = "/etc/init.d/apache2 stop"
if 4 restarts within 20 cycles then timeout
if failed host localhost port 80 with protocol http and request "/server-status" with timeout 25 seconds for 4 times within 5 cycles then restart
depend apache_bin
depend apache_rc

check file apache_bin with path /usr/sbin/apache2
group apache
include /etc/monit/templates/rootbin

check file apache_rc with path /etc/init.d/apache2
group apache
include /etc/monit/templates/rootbin