M/Monit monitoring
Server
apt-get install libapache2-mod-proxy-html libxml2-dev
cd /usr/local/
wget https://mmonit.com/dist/mmonit-3.3-linux-x64.tar.gz
tar -zxvf mmonit-3.3-linux-x64.tar.gz
/etc/apache2/sites-available/monit
<VirtualHost *:80>
ServerAdmin jan@faix.cz
ServerName monit.faix.cz
ServerAlias monitoring.faix.cz
<Location />
Order deny,allow
Allow from all
</Location>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
a2enmod proxy proxy_http
a2ensite monit
service apache2 restart
/etc/hosts
127.0.0.1 localhost monit.faix.cz
/usr/local/mmonit/conf/server.xml
<Connector address="*" port="8080" processors="10" proxyScheme="http" proxyName="monit.faix.cz" proxyPort="80" />
<Engine name="mmonit" defaultHost="monit.faix.cz" fileCache="10MB">
<Host name="monit.faix.cz" appBase=".">
/etc/init/mmonit.conf
description "M/Monit system monitoring"
limit core unlimited unlimited
start on runlevel [2345]
stop on runlevel [!2345]
expect daemon
respawn
exec /usr/local/mmonit/bin/mmonit
pre-stop exec /usr/local/mmonit/bin/mmonit stop
initctl reload-configuration
start mmonit
Go to http://monit.faix.cz/.
Login as user “admin” with password “swordfish“.
server: talk.google.com
port: 5222
user: jan.faix@gmail.com
password: app specific
Client
apt-get install monit
/etc/monit/conf.d/myserver
set daemon 120
set logfile /var/log/monit.log
set idfile /var/lib/monit/id
set statefile /var/lib/monit/state
set eventqueue basedir /var/lib/monit/events slots 1000
set httpd port 2812
use address localhost
allow 0.0.0.0/0.0.0.0
allow monit:password
set mailserver localhost
set mmonit http://monit:password@monit.faix.cz/collector
check system faix.cz
if loadavg (1min) > 4 then alert
if loadavg (5min) > 2 then alert
if memory usage > 75% then alert
if swap usage > 25% then alert
if cpu usage (user) > 70% then alert
if cpu usage (system) > 30% then alert
if cpu usage (wait) > 20% then alert
check process sshd with pidfile /var/run/sshd.pid
start program "/etc/init.d/ssh start"
stop program "/etc/init.d/ssh stop"
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
check process apache with pidfile /run/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
check filesystem data with path /dev/mapper/data
start program = "/bin/mount /mnt/data"
stop program = "/bin/umount /mnt/data"
if failed permission 660 then unmonitor
if failed uid root then unmonitor
if failed gid disk then unmonitor
if space usage > 80% for 5 times within 15 cycles then alert
if space usage > 99% then stop
if inode usage > 100000000 then alert
if inode usage > 99% then stop
monit -t
service monit restart
monit monitor all
monit status