トップページ

monit

monitについてのまとめです。

monitのインストール

# yum install epel-release
# yum install monit
# chkconfig monit on
# chkconfig monit --list
monit          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
# monit -t
Control file syntax OK
# service monit start

httpd

# cd /etc/monit.d
# vim httpd.rc
---
check process httpd
     with pidfile "/var/run/httpd/httpd.pid"
     start program "/etc/init.d/httpd start"
     stop program "/etc/init.d/httpd stop"
     if failed
        host サイトURL(もし名前解決できないテスト用のURLだった場合はhostsに記載しておく)
        port 80
        protocol http
     then restart
     if 5 restarts within 5 cycles then timeout
---
# monit -t
Control file syntax OK
# service monit restart
monit を停止中:                                            [  OK  ]
monit を起動中:                                            [  OK  ]
# monit status
The Monit daemon 5.14 uptime: 0m

Process 'httpd'
 status                            Running
 monitoring status                 Monitored
 pid                               16903
 parent pid                        1
 uid                               0
 effective uid                     0
 gid                               0
 uptime                            3m
 children                          8
 memory                            11.4 MB
 memory total                      66.1 MB
 memory percent                    0.3%
 memory percent total              2.2%
 cpu percent                       0.0%
 cpu percent total                 0.0%
 port response time                0.003s to [サイトURLがここに表示]:80 type TCP/IP protocol HTTP
 data collected                    Wed, 16 Dec 2015 17:40:48

postfix

# cd /etc/monit.d
# vim postfix.rc
---
check process postfix with pidfile /var/spool/postfix/pid/master.pid
 group mail
 start program = "/etc/init.d/postfix start"
 stop program = "/etc/init.d/postfix stop"
 if failed port 25 protocol smtp then restart
 if 5 restarts within 5 cycles then timeout
--- 
# monit -t
Control file syntax OK
# service monit restart
monit を停止中:                                            [  OK  ]
monit を起動中:                                            [  OK  ]
# monit summary
Process 'postfix'                   Running

MySQL

check process mysql with pidfile /var/run/mysqld/mysqld.pid
 group mysql
 start program = "/etc/init.d/mysqld start"
 stop program = "/etc/init.d/mysqld stop"
 if failed port 3306 protocol smtp then restart
 if 5 restarts within 5 cycles then timeout

設定

メール送信

set alert メールアドレス
set mailserver localhost

チェック間隔

set daemon 30  <-- 30秒

色々なコマンド

ステータス確認

# monit status
The Monit daemon 5.14 uptime: 1m

Process 'httpd'
 status                            Not monitored
 monitoring status                 Not monitored
 data collected                    Wed, 16 Dec 2015 17:13:43

サマリー確認

# monit summary
The Monit daemon 5.14 uptime: 2m

Process 'httpd'                     Connection failed
System 'WL-KENSHO-TESTSVR01.web-life.co.jp' Running

モニタリング再開

not monitoringとなったらモニタリングを再開する

# monit monitor httpd
または
# monit monitor all




トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS