NSCA の変更点
Nagios Service Check Acceptor.~
大規模ネットワークでの負荷分散や ファイアーウォール越えのためにあります。
~
DMS(Distributing Monitoring Server, 分散監視サーバー)~
CMS(Central Monitoring Server, 中央監視サーバー)
CMS←DMS⇔監視対象
↑
DMS⇔監視対象
~
処理の流れは以下ような感じです。
|DMS|CMS|h
|SIZE(10):|SIZE(10):|c
|サービスチェック終了→ocspコマンド実行→send_nscaが送信→|nscaが受信→外部コマンドファイルに書き出す→Nagiosが外部コマンドファイルを読む|
~
以下
|~DMS|172.16.0.1|
|~CMS|192.168.0.1|
と仮定。
~
[[ダウンロード>http://www.nagios.org/download/extras.php]]
*インストール
まず、両者に共通して必要な暗号化ライブラリを入れます。~
[[ダウンロード>http://mcrypt.hellug.gr/lib/index.html]]~
~
インストール
tar zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make install
共有ライブラリを検索するパスを設定
vi /etc/ld.so.conf
>
/usr/local/lib
ldconfig
*DMS((Distributing Monitoring Server, 分散監視サーバー))へのインストール
Nagiosの設定
vi /usr/local/nagios/etc/nagios.cfg
>
enable_notifications=0
>
obsess_over_services=1
>
ocsp_command=submit_check_result
|~enable_notifications|通知の有無|
|~obsess_over_services|サービスに付きまとうか(笑)|
|~ocsp_command|ocspコマンド|
インストール
tar zxvf nsca-2.4.tar.gz
cd nsca-2.4
./configure
make all
cp src/send_nsca /usr/local/nagios/bin/
cp send_nsca.cfg /usr/local/nagios/etc/
chown nagios:nagios /usr/local/nagios/etc/send_nsca.cfg
send_nscaの設定
vi /usr/local/nagios/etc/send_nsca.cfg
>
passwd=任意
>
encryption_method=任意
|~passwd|パスワード|
|~encryption_method|暗号化方法|
ocspコマンドを定義する。
vi /usr/local/nagios/etc/checkcommands.cfg
>
define command{
command_name submit_check_result
command_line /usr/local/nagios/libexec/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$OUTPUT$'
}
vi /usr/local/nagios/libexec/submit_check_result
>
#code(bash,nonumber,nooutline){{
#!/bin/sh
# Arguments:
# $1 = host_name (Short name of host that the service is
# associated with)
# $2 = svc_description (Description of the service)
# $3 = state_string (A string representing the status of
# the given service - "OK", "WARNING", "CRITICAL"
# or "UNKNOWN")
# $4 = plugin_output (A text string that should be used
# as the plugin output for the service checks)
#
# Convert the state string to the corresponding return code
return_code=-1
case "$3" in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
# pipe the service check info into the send_nsca program, which
# in turn transmits the data to the nsca daemon on the central
# monitoring server
/bin/echo -e "$1\t$2\t$return_code\t$4\n" | /usr/local/nagios/bin/send_nsca -H 192.168.0.1 -c /usr/local/nagios/etc/send_nsca.cfg
}}
// chown nagios:nagios /usr/local/nagios/libexec/submit_check_result
chmod a+x /usr/local/nagios/libexec/submit_check_result
// chown /usr/local/nagios/bin/nagios:nagios send_nsca
*CMS((Central Monitoring Server, 中央監視サーバー))へのインストール
Nagiosの設定~
accept_passive_service_checks=1になっているか確認。
vi /usr/local/nagios/etc/nagios.cfg
>
check_external_commands=1
//>
// command_check_interval=3s
|~check_external_commands|外部コマンドをチェックするか|
//-command_check_interval:外部コマンドのチェック間隔
各ホストの設定をCMS側でもする。adressは不要。
vi /usr/local/nagios/etc/hosts.cfg
ホストに対するサービスの項目にactive_checks_enabled 0を追加。~
一般設定がDMS用とCMSが直接監視する用とに分けてあれば、~
分散監視用一般設定に書いても&color(#FF0000){OKでした!};
vi /usr/local/nagios/etc/services.cfg
>
active_checks_enabled 0
|~active_checks_enabled|アクティブチェックが有効か無効か|
-もし、CMSが直接監視するホストを持たなければ、上記の代わりに
vi /usr/local/nagios/etc/nagios.cfg
>
execute_service_checks=0
|~execute_service_checks|起動した時にサービスチェックを実行するかどうか|
記録ディレクトリの準備
mkdir /usr/local/nagios/var/rw
インストール
tar zxvf nsca-2.4.tar.gz
cd nsca-2.4
./configure
make all
cp src/nsca /usr/local/nagios/bin/
cp nsca.cfg /usr/local/nagios/etc/
chown nagios:nagios /usr/local/nagios/etc/nsca.cfg
nscaの設定
vi /usr/local/nagios/etc/nsca.cfg
>
aggregate_writes=1
>
append_to_file=1
>
passwd=任意
>
decryption_method=任意
>
|~aggregate_writes|まとめて送られてきたデータをそのまま書き込む|
|~append_to_file|外部コマンドファイルに書き込む|
|~passwd|パスワード|
|~decryption_method|暗号化方法|
サービスポート一覧に登録
vi +534 /etc/services
>
nsca 5667/tcp # NSCA
xinetdに登録
vi /etc/xinetd.d/nsca
>
# default: on
# description: NSCA
service nsca
{
flags = REUSE
socket_type = stream
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nsca
server_args = -c /usr/local/nagios/etc/nsca.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 172.16.0.1
}
/etc/rc.d/init.d/xinetd restart
tail /var/log/messages
~
~
~
tail /var/log/messages
で
libwrap refused connection to nsca from
というエラーが出るときは、hosts.denyをチェック。
nsca: ALL EXCEPT 172.16.0.1
などとする。
*ポート
TCP 5667
*参考
-http://nagios.x-trans.jp/Nagios-doc/JAPANESE/distributed.html
-http://www.e-ryoichi.net/admin/netsaint_advanced/dm_nsca.html
-http://anabuki.dip.jp/tips/nagios/nsca.htm
-http://anabuki.dip.jp/tips/nagios/distribut.htm
*Amazon
#amazon(4774145823,left)
#amazon(3897218801,left)
#amazon(4873112044,left)
#amazon(4797820217,left)
#amazon(4774165433,left)
#amazon(4774178659,left)