Raspberry-Pi で WiFi スキャンをさせたいけど、警告を出すために raspberry-pi 側に nagios4 のような本格的な監視システムを入れるのは資源のムダに思えたので、軽量な監視とすべく、リモート監視用の nagios-nrpe-server を使ってみた。
メインサーバ port=5666 リモート 監視プラグイン
nagios4 ----> check_nrpe ------------> nrpe ----> check_root
nagios-nrpe-plugin nagios-nrpe-server
nrpe は リモートの監視プラグインを check_nrpe と nagios-nrpe-server が経由して呼出してくれる。
リモートの監視側
nagios-nrpe-server をインストールして、監視サーバからの接続を許可する。インターネット経由で監視するなら、5666 ポートが通るようにファイアウォールの設定が必要。
((( 必要パッケージのインストール )))
$ sudo aptitude install nagios-nrpe-server
((( /etc/nagios/nrpe.cfg )))
# 監視サーバからの接続を許可
allowed_hosts=127.0.0.1,::1,192.168.xx.00/24
~~~~~~~~~~~~~~~~~(追加)
((( /etc/nagios/nrpe.d/enabled.cfg )))
# 監視するためのチェック処理を登録。nrpe.cfg から nrpe.d/*.cfg に設定を移動
command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_load]=/usr/lib/nagios/plugins/check_load $ARG1$
((( /etc/default/nagios-nrpe-server )))
# 自宅内のような閉じた中でSSLが不要の場合
NRPE_OPTS="-n"
((( nagios-nrpe-server を再起動 )))
$ sudo systemctl restart nagios-nrpe-server
メインの監視サーバ側
nrpe用のプラグインをインストールすると、/etc/nagios-plugins/config/check_nrpe.cfg や /usr/lib/nagios/plugins/check_nrpe を入れてくれる。
((( 監視側にnrpe用のプラグインを追加 )))
$ sudo aptitude install nagios-nrpe-plugin # nagios or icinga はインストール済み
((( nrpe の入ったリモートが呼び出せるか確認 )))
$ /usr/lib/nagios/plugins/check_nrpe -H リモート -c check_root
DISK OK - free space: / 21321 MB (74% inode=86%);| /=7363MB;23944;26937;0;29930
((( /etc/nagios-plugins/config/check_nrpe.cfg )))
# nagios/icingaなどのcommand設定の確認
# this command runs a program $ARG1$ with no arguments and enables SSL support
define command {
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
# this command runs a program $ARG1$ with no arguments and disables SSL support
define command {
command_name check_nrpe_nossl
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -n
}
((( nagios4 のサービス監視に check_nrpe を呼出す設定を追加 )))
define service{
use local-service
host_name リモート
service_description DISK
check_command check_nrpe!check_root
# check_command check_nrpe_nossl!check_root # SSLなしで設定した場合
}
((( nagios4 を再起動 )))
$ sudo systemctl restart nagios4
nagios4 で監視ができるようになったので、温湿度センサーや空気品質センサーの確認も nrpe 経由に変更してみた。
