[https://mmonit.com/monit/ Monit], not to be confused to [https://mmonit.com/ M/Monit], is an AGPL3.0 licensed system and process monitoring tool. Monit can automatically restart crashed services, display temperatures from standard hardware (through {{Pkg|lm_sensors}} and hard drives from {{Pkg|smartctl}} for example). Service alerts can be sent based on a wide criteria including a single occurrence or occurrences over a period of time. It can be accessed directly through the command line or ran as a web app using it's integrated HTTP(S) server. This allows quick and streamlined snapshot of a given systems status.

+

[https://mmonit.com/monit/ Monit], not to be confused to [https://mmonit.com/ M/Monit], is an AGPL3.0 licensed system and process monitoring tool. Monit can automatically restart crashed services, display temperatures from standard hardware (through {{Pkg|lm_sensors}} and hard drives from {{Pkg|smartmontools}} for example). Service alerts can be sent based on a wide criteria including a single occurrence or occurrences over a period of time. It can be accessed directly through the command line or ran as a web app using it's integrated HTTP(S) server. This allows quick and streamlined snapshot of a given systems status.

== Installation ==

== Installation ==

−

[[Install]] the {{Pkg|monit}} package and any software for optional testing such as {{Pkg|lm_sensors}} or {{Pkg|smartctl}}. Once you've completed the configuration, be sure to {{ic|enable}} and {{ic|start}} the {{ic|monit}} service.

+

[[Install]] the {{Pkg|monit}} package and any software for optional testing such as {{Pkg|lm_sensors}} or {{Pkg|smartmontools}}. Once you've completed the configuration, be sure to {{ic|enable}} and {{ic|start}} the {{ic|monit}} service.

== Configuration ==

== Configuration ==

Revision as of 00:43, 5 February 2016

Monit, not to be confused to M/Monit, is an AGPL3.0 licensed system and process monitoring tool. Monit can automatically restart crashed services, display temperatures from standard hardware (through lm_sensors and hard drives from smartmontools for example). Service alerts can be sent based on a wide criteria including a single occurrence or occurrences over a period of time. It can be accessed directly through the command line or ran as a web app using it's integrated HTTP(S) server. This allows quick and streamlined snapshot of a given systems status.

Installation

Install the monit package and any software for optional testing such as lm_sensors or smartmontools. Once you've completed the configuration, be sure to enable and start the monit service.

Configuration

Monit keeps a main configuration file as /etc/monitrc. You can choose to edit this file but if you wish to run scripts (such as to get hard drive temperatures or health status) you should uncomment the last directive of include /etc/monit.d/*, save /etc/monitrc and mkdir /etc/monit.d.

Note: Monit requires the /etc/monitrc file (and potentially files stored in /etc/monit.d) to be USER RWX, GROUP and OTHER ---; or 0700. Failure to comply will result in Monit failing to start

Configuration syntax

Monit utilizes a configuration syntax that makes it very easy to read; essentially check WHAT followed by if THING condition THEN action format. Any occurance of 'if', 'and', 'with(in)', 'has', 'us(ing in the configuration file is for human readability only and are completely ignored by Monit.

check program SSD-A-Temp with path "/etc/monit.d/scripts/hdtemp.sh a"
every 5 cycles
if status > 40 then alert
group health
check program HDD-B-Temp with path "/etc/monit.d/scripts/hdtemp.sh b"
every 5 cycles
if status > 40 then alert
group health

In this example, the /etc/monit.d/scripts/hdtemp.sh script assumes your drive path is /dev/sdX where X is filled in by the letter at the end of the check declaration. A similar method is used for the SMART health status in the next example.

check program SSD-A-Health with path "/etc/monit.d/scripts/hdhealth.sh a"
every 120 cycles
if status != 1 then alert
group health
check program HDD-B-Health with path "/etc/monit.d/scripts/hdhealth.sh b"
every 120 cycles
if status != 1 then alert
group health

Tip: The group declaration will cause Monit to display all assigned checks with the same group name (in this case samba) together.

Alert recipients: global or subsystem based

Alerts can be set globally, where a given user / email address is alerted for any alert condition; or you can set an alert recipient for each type of check (eg network alerts go to recipient A; process alerts go to recipient B). You can set as many global or subsystem recipients as you like, just make multiple declarations.

Global alerts

Global alerts are set outside of any subsystem checks; for ease of reading they should be set in the same location as the mailserver declaration.

SET ALERT email@domain

Subsystem alerts

Subsystem alerts are set very similarly to global alerts except they lack the SET flag.