TrixBox その23

monit のインストール

asterisk のプロセスが停止しても再起動するように、プロセス管理プログラムをインストールしてみた。

# yum -y install flex
# cd /usr/local/src
# wget http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz
# tar xzvf monit-4.10.1.tar.gz
# cd monit-4.10.1
# ./configure
# make
# make install
# vi /etc/monitrc
—————————————————————
set daemon 60

set logfile /var/log/monit.log

set httpd port 2812
allow md5 /etc/httpd/htpasswd
allow localhost
allow アクセスしたいリモートホストのアドレス
allow たとえば 111.222.333.444/255.255.255.0

check process asterisk with pidfile /var/run/asterisk/asterisk.pid
start program = "/etc/init.d/asterisk start"
stop program = "/etc/init.d/asterisk stop"
if failed port 5060 type udp then restart
group asterisk

check process mysql with pidfile /var/run/mysqld/mysqld.pid
group asterisk
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed port 3306 protocol mysql then restart

check process apache with pidfile /var/run/httpd.pid
group asterisk
start program = "/etc/init.d/httpd start"
stop program = "/etc/init.d/httpd stop"
if failed port 80 protocol http request "/index.html"
with timeout 10 seconds then restart
—————————————————————
# htpasswd -cm /etc/httpd/htpasswd ユーザー名
ここで http://ホスト:2812 にアクセスしたときのユーザーのパスワードを設定する。2番目から後のユーザーを設定する場合は上記の -cm を -m のみにして再度実行
これで、 http://ホスト:2812 でプロセス管理が出来る
# chmod 700 /etc/monitrc
# vi /etc/inittab
以下を追加
—————————————————————
# Run monit in standard run-levels
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
—————————————————————
(/etc/ninittab 内で mo: が既に使用されている場合は、未使用の適当な何かに変更)
# telinit q
もしくは
# kill -1 1
もしくは
# telinit Q

設定をし直したときは
# monit reload

参考
http://www.simplegimmick.com/2007/08/monitor-processes-using-monit-1-about
http://www.tildeslash.com/monit/doc/examples.php
http://www.tildeslash.com/monit/doc/manual.php

コメントを残す

メールアドレスが公開されることはありません。