タグ: chkconfig

Zabbix の起動スクリプト

zabbixを起動時に自動的にスタートさせたいのでスクリプトを /etc/init.d/ に仕込む。
だいたいのことは英語だけど Zabbix Wiki に書いてあるのでこの通りに進めてみる。

CentOS用と銘打ったファイルは用意されていないのでfedora用で代用する。

fedora配下には [ core ] ディレクトリと [ core5 ] ディレクトリがあってどっちを使ったらいいのかよく分からない。
多分、CentOS5系は [ core5 ] 、それ以外は [ core ] ってことだと思う。
「それ以外」っていうのも、、、今の段階でCent4系ってことはないだろうから、Cent6系ってことかな。

lsb_release -a

すると

LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final

とのことなので、[ core5 ]ディレクトリの方で。

では、気を取り直して
/インストールディレクトリ/misc/init.d/fedora/core5/
にある
zabbix_server と zabbix_agentd
をコピーします。

cp /インストールディレクトリ/misc/init.d/fedora/core5/zabbix_* /etc/init.d/

サーバに入れるときは両方だけど、Agent側(監視される側)は [ zabbix_agentd ] だけでよし。

中を見てみると21行目辺りに

ZABBIX_BIN="/usr/local/sbin/zabbix_server"

という行があるので、これがzabbix server を起動させる時のパスと同じかどうか確認しておく。

chkconfig で色々できるように

chkconfig --add zabbix_server
chkconfig --add zabbix_agentd

で chkconfig に今回のzabbixを加える。

chkconfig --list | grep zabbix_server

で確認すると、

zabbix_server   0:off   1:off   2:off   3:off   4:off   5:off   6:off

とか返してくれるので

chkconfig --level 35 zabbix_server on
chkconfig --level 35 zabbix_agentd on

で、ランレベル3と5をONに設定。

[root@localhost /]# chkconfig --list | grep zabbix_server
zabbix_server   0:off   1:off   2:off   3:on    4:off   5:on    6:off
[root@localhost /]# chkconfig --list | grep zabbix_agentd
zabbix_agentd   0:off   1:off   2:off   3:on    4:off   5:on    6:off

これで再起動とかしても自動的に立ち上がってくれるはず。

[root@localhost /]# /etc/init.d/zabbix_server restart
Zabbix Server を停止中:                                    [  OK  ]
Zabbix Server を起動中:                                    [  OK  ]

[root@localhost /]# /etc/init.d/zabbix_agentd restart
Zabbix Agent を停止中:                                     [  OK  ]
Zabbix Agent を起動中:                                     [  OK  ]

[root@localhost /]# /etc/init.d/zabbix_server status
zabbix_server (pid 25364 25362 25360 25358 25356 25354 25352 25351 25349 25347 25345 25343 25340 25339 25337 25335 25333 25331 25329 25323 25322 25321 25320 25317 25316 25315 25311) を実行中...

[root@localhost /]# /etc/init.d/zabbix_agentd status
zabbix_agentd (pid 25423 25422 25421 25420 25419 25418 25417 25415) を実行中...

おお~出来た~