#author("2019-05-01T08:14:40+00:00","default:kazuma","kazuma") #author("2019-05-01T08:16:41+00:00","default:kazuma","kazuma") [[トップページ]] *monit [#x6028982] monitについてのまとめです。 * monitのインストール [#zd5e1a95] # 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 [#r0c93307] # 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 [#le9f0edc] # 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 [#bfdefb3b] check process mysql with pidfile /var/run/mysqld/mysqld.pid start program = "/etc/init.d/mysqld start" stop program = "/etc/init.d/mysqld stop" if failed unixsocket /var/lib/mysql/mysql.sock then restart if 5 restarts within 5 cycles then timeout *設定 [#kbe369c9] ** メール送信 [#k5c44e31] set alert メールアドレス set mailserver localhost ** チェック間隔 [#xb299220] set daemon 30 <-- 30秒 *色々なコマンド [#eb6228c8] ***ステータス確認 [#vd7d4189] # 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 ***サマリー確認 [#bca0a28a] # monit summary The Monit daemon 5.14 uptime: 2m Process 'httpd' Connection failed System 'WL-KENSHO-TESTSVR01.web-life.co.jp' Running ***モニタリング再開 [#v25c1575] not monitoringとなったらモニタリングを再開する # monit monitor httpd または # monit monitor all 上記がよく解除されることがある場合はcronに設定してしまう。 */30 * * * * /usr/bin/monit monitor all ~ ~