Setting up M/Monit

Installing mmonit

Fetch the latest M/Monit binary

wget https://mmonit.com/dist/mmonit-3.7.7-linux-x64.tar.gz
tar xzf mmonit-3.7.7-linux-x64.tar.gz
mv mmonit-3.7.7 /opt/mmonit

Preparing the DB

assuming mariadb is up and running already

here database name mmonit and username mmonitdude

create database mmonit;
grant all on mmonit.* to mmonitdude@localhost identified by 'DUDE-PASSWORD';
^D

mysql -u mmonitdude mmonit -p < /opt/mmonit/db/mmonit-schema.mysql
# /usr/local/mmonit/db/mmonit-schema.mysql

Setting up mmonit

cp -i /opt/mmonit/conf/server.xml /opt/mmonit/conf/server.xml.dist
vi /opt/mmonit/conf/server.xml

bind to localhost-only

   <Connector address="127.0.0.1" port="8080" processors="10" />

comment out the SQLite stanza and enable MariaDB/MySQL

for a remote host listening on 3306/tcp

       <Realm url="mysql://mmonitdude:DUDE-PASSWORD@mariadbprod:3306/mmonit"
              minConnections="5"
              maxConnections="25"
              reapConnections="300" />

as for unix socket w/o networking

       <Realm url="mysql://mmonitdude:DUDE-PASSWORD@127.0.0.1/mmonit?unix-socket=/var/run/mysql/mysql.sock"
              minConnections="5"
              maxConnections="25"
              reapConnections="300" />

ls -lF /var/run/mysql/mysql.sock

Ready to go

read the logs while operating the daemon

tail -F /opt/mmonit/logs/*

start and enable the daemon at boot time

/opt/mmonit/bin/mmonit -t # also checks access to db

echo -n mmonit...
rm -f /opt/mmonit/logs/mmonit.pid
/opt/mmonit/bin/mmonit && echo done || echo FAIL
# /usr/local/mmonit/bin/mmonit

status

pgrep -a mmonit
netstat -lntup | grep mmonit # should listen only locally

stop

pkill mmonit && echo KILLED || echo FAILED

Easy SSL w/ NGINX

see nginx then e.g.

    location /mmonit/ {
            rewrite ^/mmonit/(.*) /$1 break;
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect http://127.0.0.1:8080 /mmonit;
            proxy_cookie_path / /mmonit/;
    }

Acceptance

http://mmonit:8080/ # nope
https://mmonit:8433/ # nope

http://mmonit/ # nginx redirects to ssl
https://mmonit/ # nginx serves

you can now login and fix admin and monit passwords

"admin" with password "swordfish"
"monit" with password "?"

Users > admin > update password
Users > admin > define email

Users > monit > update password
Users > monit > define email

define an SMTP relay for alerts

Admin > Alerts / Rules
name: any
if any ... SEND MAIL TO USER admin
(and enable)

Admin > Alerts / Mail servers
localhost port 25

you can now setup monit agents

Resources

M/Monit https://www.mmonit.com/

MMonit / Setup https://mmonit.com/wiki/MMonit/Setup

https://mmonit.com/documentation/mmonit_manual.pdf

https://tildeslash.com/libzdb/api-docs/mysqloptions.html

alternatives

https://dreamconception.com/tech/tools/measure-your-server-performance-with-monit-and-monit-graph/

https://www.linuxjournal.com/content/bare-bones-monitoring-monit-and-rrdtool

https://github.com/danschultzer/monit-graph

advanced

Admin Hosts https://mmonit.com/documentation/http-api/Methods/Admin_Hosts


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun