Nagios とパトライトの連携
先日の記事「パトライトへの SNMPトラップ送信」で紹介したパトライトと Nagios の連携設定メモです。
Nagios はインストールし監視デバイスの登録済状態とします。
【事前準備】
Nagios の通知は、command にあらかじめ定義済の notify-by-email や notify-by-print を呼び出すようになっています。
同じ仕組みを利用して、notify-by-pat のような定義を追加して連携できます。
- command.cfg
host_notification_commands や service_notification_commands へ先程定義した notify-host-by-pat や notify-service-by-pat を追加します。
私の環境では、contacttemplates.cfg へ追加しました。
次にshell script です。
アラート種別が「CRITICAL」はパトライトへ通知、種別「OK」または「UP」はパトライトをクリア(リセット)の動きです。
「WARRNING」は通知しない仕組みです。
===== ここから =====
どうでしょうか?
うまく出来ましたか?
Nagios はインストールし監視デバイスの登録済状態とします。
【事前準備】
Nagios の通知は、command にあらかじめ定義済の notify-by-email や notify-by-print を呼び出すようになっています。
同じ仕組みを利用して、notify-by-pat のような定義を追加して連携できます。
- command.cfg
# vi command.cfg- contactへの設定
define command {
command_name notify-host-by-pat
command_line /usr/local/bin/send-by-pat.sh $HOSTSTATE$
}
define command {
command_name notify-service-by-pat
command_line /usr/local/bin/send-by-pat.sh $SERVICESTATE$
}
host_notification_commands や service_notification_commands へ先程定義した notify-host-by-pat や notify-service-by-pat を追加します。
私の環境では、contacttemplates.cfg へ追加しました。
次にshell script です。
アラート種別が「CRITICAL」はパトライトへ通知、種別「OK」または「UP」はパトライトをクリア(リセット)の動きです。
「WARRNING」は通知しない仕組みです。
===== ここから =====
#!/bin/sh
#
#
LANG=C
#
CriticalTrap=".1.3.6.1.6.3.1.3.1"
ClearTrap=".1.3.6.1.6.3.1.2.1"
PatHost="xxx.xxx.xxx.xxx"
SnmpCmd="/usr/bin/snmptrap -v 2c -c public "
#
State="$1"
#
case "$State" in
"CRITICAL")
${SnmpCmd} ${PatHost} '' ${CriticalTrap}
;;
"OK" | "UP")
${SnmpCmd} ${PatHost} '' ${ClearTrap}
;;
default)
;;
esac
exit 0
どうでしょうか?
うまく出来ましたか?
コメント