Table of Contents
To install M/Monit:
1. First, check that M/Monit is supported on your OS platform 2. Get the latest release from http://mmonit.com/download/ 3. Download and unpack the tar.gz file in a directory, any directory will do, but unpacking in /opt or /usr/local are good choices. 4. Go to the unpacked mmonit-<version> directory 5. Run M/Monit using: ./bin/mmonit 6. Point your Browser to the host where mmonit is installed (or "localhost" if running on the same machine), for example: http://localhost:8080/ and login as user "admin" with password "swordfish".
Once started, mmonit will daemonize itself and run in the background. To stop mmonit use ./bin/mmonit stop. To see all options for the mmonit program use ./bin/mmonit -h.
You can run mmonit as any user, including root. It is not necessary to create a standalone account to run mmonit.
M/Monit comes bundled and configured with SQLite as its database system. No extra setup is required. If you plan to use M/Monit to monitor more than, say 40-50 hosts, you may want to use MySQL or PostgreSQL instead as these database systems are faster and scale much better. If in doubt, start with SQLite. If you later should want to switch, you can use the migrate script in the upgrade directory to move your SQLite data over to MySQL or PostgreSQL.
Setting up M/Monit to use either MySQL or PostgreSQL is a simple two step process:
Create the M/Monit database. The database schemas can be found in mmonit/db/ Use one of the following recipes:
1) Create the mmonit database: mysqladmin create mmonit -u root -p 2) Create the mmonit user and grant access to the mmonit database: GRANT ALL ON mmonit.* to mmonit@localhost identified by '<password>' 3) Create the schema: mysql -u mmonit mmonit -p < mmonit-schema.mysql
1) Create a mmonit postgres user: createuser -U postgres -P mmonit 2) Create the mmonit database: createdb -U postgres -E utf8 -O mmonit mmonit 3) Create the schema: psql -U mmonit mmonit < mmonit-schema.postgresql
Configure M/Monit; edit the M/Monit configuration file mmonit/conf/server.xml and replace the SQLite <Realm> element with either:
This one for MySQL:
<Realm url="mysql://mmonit:email@example.com:3306/mmonit" minConnections="5" maxConnections="30" reapConnections="300" />
Or this one for PostgreSQL:
<Realm url="postgresql://mmonit:firstname.lastname@example.org:5432/mmonit" minConnections="5" maxConnections="30" reapConnections="300" />
Adjust username, password, host and port number in the connection URL as required.
The URL in the <Realm> element specify a database connection on the standard URL format. The format of the connection URL is defined as: database://[user:password@][host][:port]/database[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]... Properties depends on the database server in question. If port number is omitted, the default port number for the database server is used.
That is it. When you start M/Monit it connects to the configured database system.
You can register M/Monit as Monit service in the Monit configuration file (/etc/monitrc):
check process mmonit with pidfile /usr/local/mmonit/logs/mmonit.pid start program = "/usr/local/mmonit/bin/mmonit" as uid mmonit and gid mmonit stop program = "/usr/local/mmonit/bin/mmonit stop" as uid mmonit and gid mmonit
And reload monit configuration:
Configuration for upstart (Ubuntu/Debian):
Save this script as /etc/init/mmonit.conf
# This is an upstart script to keep mmonit running. # Put this script here: # # /etc/init/mmonit.conf # # and reload upstart configuration: # # initctl reload-configuration # # You can manually start and stop monit like this: # # start mmonit # stop mmonit # description "M/Monit system monitoring" limit core unlimited unlimited start on runlevel  stop on runlevel [!2345] expect daemon respawn exec /usr/local/mmonit/bin/mmonit pre-stop exec /usr/local/mmonit/bin/mmonit stop
Reload upstart configuration and start M/Monit:
initctl reload-configuration start mmonit