-
Notifications
You must be signed in to change notification settings - Fork 5
Monit
<<toc>>
Monit 5.3 allows you to monitor the exit status of a program which you can then use to check your VPN connection.
Ubuntu 11.10 or earlier comes with an older version of Monit which does not have the functionality to monitor program statuses. To install Monit 5.3+ get it from the 12.04 sources
# wget http://mirror.pnl.gov/ubuntu//pool/universe/m/monit/monit_5.3.2-1_amd64.deb # sudo dpkg -i monit_5.3.2-1_amd64.deb
Or to install the older version released with Ubuntu 11.10
# sudo apt-get install monit
Edit the file at /etc/monit/monitrc
set mailserver smtp.gmail.com port 587 username "[email protected]" password "password" using tlsv1 with timeout 30 seconds set alert [email protected] # receive all alerts
First create a certificate and key and open up port 2812 if required on EC2 EC2#!enable-ssl
Then copy the key and certificate into one file:
sudo cat /etc/ssl/certs/nuntium.pem /etc/ssl/private/nuntium.key > /etc/certs/nuntium_with_key.pem
Finally add the settings below to /etc/monit/monitrc:
set httpd port 2812 and SSL ENABLE PEMFILE /etc/ssl/certs/nuntium_with_key.pem allow admin:monit # require user 'admin' with password 'monit'
check system myhost.mydomain.tld 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
Nuntium comes with a rake task to generate the monit config for the services you want to run
# cd <<nuntium_dir>> # bundle exec rake monit:generate # sudo mv nuntium /etc/monit/conf.d/
See http://ghosttx.com/2012/03/how-to-install-monit-on-ubuntu-11-10-server-to-monitor-apache-web-server-mysql-ssh/ for more info
Configure mysql to use a PID file by adding the following to /etc/mysql/my.conf under [mysqld]
pid-file = /var/run/mysqld/mysqld.pid
Restart mysql
# sudo restart mysql
Add the following to /etc/monit/conf.d/mysql:
check process mysql with pidfile /var/run/mysqld/mysqld.pid group database start "/etc/init.d/mysql start" with timeout 60 seconds stop "/etc/init.d/mysql stop" if failed host 127.0.0.1 port 3306 then restart if 5 restarts within 5 cycles then timeout
Add the following to /etc/monit/conf.d/apache
check process apache2 with pidfile /var/run/apache2.pid start program = "/etc/init.d/apache2 start" with timeout 60 seconds stop program = "/etc/init.d/apache2 stop" if cpu > 60% for 2 cycles then alert if cpu > 80% for 5 cycles then restart if totalmem > 200.0 MB for 5 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 8 cycles then stop group webserver
# sudo /etc/init.d/monit restart