ubuntu 16.04
apt-get install monit
vi /etc/monit/monitrc
# set mailserver mail.bar.baz, # primary mailserver
# backup.bar.baz port 10025, # backup mailserver on port 10025
# localhost # fallback relay
#gmailに送信するための設定
set mailserver smtp.gmail.com port 587 username “gmailアドレス” password “パスワード” using tlsv1 with timeout 30 seconds
# set alert sysadm@foo.bar # receive all alerts
#alert送信先gmailアドレス
set alert fujimoto.takahiko.1955@gmail.com
#apache2の監視
check process apache2 with pidfile /run/apache2/apache2.pid
start program = "/etc/init.d/apache2 start" with timeout 60 seconds
stop program = "/etc/init.d/apache2 stop"
#mysqlの監視
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
start program = "/etc/init.d/mysql start" with timeout 60 seconds
stop program = "/etc/init.d/mysql stop"
これで/etc/init.d/monit restartでメールが来ればOK
また/etc/init.d/apache2 stopでメールが来ればOK
/etc/init.d/mysql stopでメールが来ればOK
#/homeの使用容量が設定値以上ならalert
check device home with path /home
if SPACE usage > 95% then alert
コメント