Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up an M/Monit docker container

Introduction

M/Monit is the web interface and the db (sqlite by default) collecting the data from the monit server-agents.

Launching the container

Run the container that will serve M/Monit,

app=mmonitprod
docker ps -a | grep $app
docker run -d --name $app -h $app \
        -p 80XX:8080 -p 84XX:8443 \
            --link mariadbprod:mariadb \
        custom/ubuntu
            #mmonitprod.<datetag>.ready
docker ps -a | grep $app
docker logs $app

Enter the container,

app=mmonitprod
docker exec -ti $app bash

Preparing MariaDB instead

Note. default is SQLite

Prepare the MariaDB database,

pwgen
    mysqladmin create mmonit -u root -p
    GRANT ALL ON mmonit.* to mmonit identified by 'SOME_MARIA_PASSWORD';

Note. no @localhost: allowing remote connections as long as the daemon is binded to the network.

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

Populate the DB,

apt -y update
apt -y full-upgrade
cat /etc/hosts
mysql -ummonit -pSOME_MARIA_PASSWORD -h mariadb mmonit
^D
mysql -ummonit -pSOME_MARIA_PASSWORD -h mariadb mmonit < /root/mmonit-3.6.2/db/mmonit-schema.mysql

Note. if you cannot reach the mariadb database, try with --protocol=TCP.

Installation & use MariaDB

Copy/paste the Linux x64 link from M/Monit download, e.g.,

cd ~/
wget https://mmonit.com/dist/mmonit-3.6.2-linux-x64.tar.gz
tar xzf mmonit-3.6.2-linux-x64.tar.gz
ln -s mmonit-3.6.2 mmonit

Switch from SQLite to MariaDB/MySQL,

cd ~/mmonit/conf/
cp -i server.xml server.xml.dist
vi server.xml
<Realm url="mysql://mmonit:wohyoNe3@mariadb:3306/mmonit"
       minConnections="5"
       maxConnections="30"
       reapConnections="300" />

Start the daemon, either from within the container,

/root/mmonit/bin/mmonit
ps auxfw | less

or from the docker host,

docker exec mmonitprod /root/mmonit/bin/mmonit
docker exec -ti mmonitprod ps auxfw | less

Ready to go

Make sure the service is listening from the docker host,

netstat -an --inet --inet6 | grep 80XX
netstat -an --inet --inet6 | grep 84XX

check the raw URL from the internal network,

http://dockerhost.example.com:80XX/index.csp
https://dockerhost.example.com:84XX/index.csp

"admin" with password "swordfish"

Setup the reverse-proxy and check with the public URL,

https://dockerhost.example.com/index.csp

"admin" with newly defined password

Maintenance & Operations

Override admin password,

bin/mmonit stop
select uname,password from users;
echo -n PASSWORD | md5sum | tr 'a-z' 'A-Z'
update users set password="HASH" where uname="admin";
bin/mmonit

Operating Docker Containers

References

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

Alternatives

https://github.com/antoniopuero/open-m-monit https://github.com/cw-ansible/cw.mmonit https://github.com/joealcorn/mmonit


Home | GitHub | Donate | Feedback