Monit

From Amahi Wiki
Jump to: navigation, search

Monit (Amahi's watchdog) is a utility for managing and monitoring processes, programs, files, directories and filesystems on a Unix system. It is integrated in Amahi and managed using the Servers section of the Settings tab.

Monit has an integrated web interface which can exposed using the Monit Service Manager one-click app. This app provides additional detail about the processes currently running on your HDA.

Monit configuration file locations:

  • Main (monitrc):
    • Ubuntu - /etc/monit
    • Fedora - /etc
  • Services:
    • Ubuntu - /etc/monit/monit.d
    • Fedora - /etc/monit.d


Change Hostname

Edit monitrc and change localhost.localdomain to match your system:

check system localhost.localdomain

Email Notifications

This will only work if you have set up your HDA to send emails. The Gmail as Relay tutorial is one option.

You can do it in Monit directly by adding the following to monitrc:

set mailserver smtp.gmail.com port 587 
   username "MYUSER" password "MYPASSWORD"
   using tlsv1


NOTE: Replace "MYUSER" and "MYPASSWORD" with your Gmail user name and password.

Enable email notifications by editing monitrc and adding the following lines (Change as needed to match your system): set mailserver localhost set mail-format { from: monit@localhost } set alert root@localhost


Restart Monit:

  • Ubuntu
sudo /etc/init.d/monit restart
  • Fedora (root user)
systemctl restart monit.service

Change Message Format

Edit monitrc and add this text (modify as needed):

set mail-format {
    from: monit@localhost
    subject: [ $SERVICE ] $EVENT - $DATE
    message: This is an $ACTION: $DESCRIPTION [$SERVICE], tested remotely from $HOST }


Restart Monit:

  • Ubuntu
sudo /etc/init.d/monit restart
  • Fedora (root user)
systemctl restart monit.service

Change Access Credentials

Edit monitrc and change as desired:

allow admin:admin


Restart Monit:

  • Ubuntu
sudo /etc/init.d/monit restart
  • Fedora (root user)
systemctl restart monit.service

Enable Secure access (Fedora)

Edit monitrc and add below set httpd port 2812 and (line 116):

SSL ENABLE
PEMFILE  /var/certs/monit.pem


Create a directory for the certs, then follow "Create New Certificate" guidance:

mkdir -p /var/certs

Create New Certificate

A default certificate is installed by the Amahi application (Ubuntu). To create a new certificate, do the following steps as root user (Ubuntu NOTE: prefix commands with sudo except the second openssl requires the actual root user environment sudo su -):

cd /var/certs
openssl req -new -x509 -days 365 -nodes -config ./monit.cnf -out /var/certs \
/monit.pem -keyout /var/certs/monit.pem
openssl gendh 512 >> /var/certs/monit.pem
openssl x509 -subject -dates -fingerprint -noout -in /var/certs/monit.pem
chmod 700 /var/certs/monit.pem

Restart Monit:

  • Ubuntu
sudo /etc/init.d/monit restart
  • Fedora (root user)
systemctl restart monit.service

Configuration Examples

Monit Configuration Examples: Covers many common processes that users may want to monitor. Some minor changes may be needed for Fedora or Ubuntu.