The system's own Periodic Scripts are to be understood as maintenance and reporting scripts. Monit is very helpful and very flexible for monitoring the system's vital signs in near real time. The following aspects are of particular interest:
NEW: For the very impatient I have a console only section. There are only commands, no explanations.
Last update:
Monit is a good and above all very widespread monitoring tool for obtaining all kinds of system statuses and is also included in OPNsense, for example. The package monit
is quickly installed after adapting the package source with pkg install -y monit
. The service is activated with service monit enable
and then the configuration is started with ee /usr/local/etc/monitrc
(many more examples are listed in /usr/local/etc/monitrc.sample.sample
).
The following is to be achieved here: "Monitor all hard drives detected on the system for their occupancy, keep an eye on CPU and RAM utilization and send warnings by e-mail if something is stuck."
The configuration file /usr/local/etc/monitrc
is divided into several sections:
set daemon 120 with start delay 60 # A check is performed every 120 seconds, starting 60 seconds after system startup
set log syslog # Logging to syslog
set httpd unixsocket /var/run/monit.sock # Built-in web server is only accessible locally
allow localhost
set mailserver MAILSERVER port 587 username "LOGIN" password "PASSWORT" using ssl with options { version: auto verify: enable }
set alert TO-EMAIL mail-format { from: FROM-EMAIL } reminder on 10 cycles # Define the e-mail addresses
check system $HOST
if memory usage is greater than 75% then alert
if cpu usage is greater than 75% then alert
if loadavg (1min) is greater than 8 then alert
if loadavg (5min) is greater than 6 then alert
check filesystem RootZFS with path "/"
if space usage is greater than 75% then alert
check filesystem DataZFS with path "/mnt/data"
if space usage is greater than 75% then alert
check filesystem WorkZFS with path "/mnt/work"
if space usage is greater than 75% then alert
Finally, the configuration is protected from unauthorized eyes with chmod 700 /usr/local/etc/monitrc
and Monit is started with service monit start
. With ZFS this extension is also worthwhile.
pkg install -y monit
service monit enable
ee /usr/local/etc/monitrc
set daemon 120 with start delay 60
set log syslog
set httpd unixsocket /var/run/monit.sock
allow localhost
set mailserver MAILSERVER port 587 username LOGIN password "PASSWORT" using ssl with options { version: auto verify: enable }
set alert TO-EMAIL mail-format { from: FROM-EMAIL } reminder on 10 cycles
check system $HOST
if memory usage is greater than 75% then alert
if cpu usage is greater than 75% then alert
if loadavg (1min) is greater than 8 then alert
if loadavg (5min) is greater than 6 then alert
check filesystem RootZFS with path "/"
if space usage is greater than 75% then alert
check filesystem DataZFS with path "/mnt/data"
if space usage is greater than 75% then alert
check filesystem WorkZFS with path "/mnt/work"
if space usage is greater than 75% then alert
chmod 700 /usr/local/etc/monitrc
service monit start
Voilá