nagiosでフリーな監視をしてみよう!~nagiosの設定(5)~
nrpeの設定
(1)監視サーバ側にて、nrpeの設定を行います。
・「commands.cfg」にcheck_nrpeコマンドを最終行に追加します。
# vi /usr/local/nagios/etc/objects/commands.cfg
・「commands.cfg」ファイル変更後の内容
}
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
(2)監視対象となるサーバ側にて、nrpeの設定を行います。
・TCP5666をnrpeのサービスポートとして追加します。
# echo "nrpe 5666/tcp # NRPE" >> /etc/services
・xinetd用のnrpe設定を編集します。
# vi /etc/xinetd.d/nrpe
・「nrpe」ファイル変更前の内容
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1
}
・「nrpe」ファイル変更後の内容
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 127.0.0.1 192.168.100.74
}
・nrpeサーバが送信する対象のアドレスを設定します。
# vi /usr/local/nagios/etc/nrpe.cfg
・「nrpe.cfg」ファイル変更前の内容
# SERVER ADDRESS # Address that nrpe should bind to in case there are more than one interface # and you do not want nrpe to bind on all interfaces. # NOTE: This option is ignored if NRPE is running under either inetd or xinetd #server_address=127.0.0.1
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd #allowed_hosts=127.0.0.1
nrpeが引数を受け付けるように、機能を有効にします。
# Values: 0=do not allow arguments, 1=allow command arguments dont_blame_nrpe=0
・「nrpe.cfg」ファイル変更後の内容
# SERVER ADDRESS # Address that nrpe should bind to in case there are more than one interface # and you do not want nrpe to bind on all interfaces. # NOTE: This option is ignored if NRPE is running under either inetd or xinetd #server_address=127.0.0.1 server_address=0.0.0.0
# NOTE: This option is ignored if NRPE is running under either inetd or xinetd #allowed_hosts=127.0.0.1 allowed_hosts=127.0.0.1,192.168.100.75
# Values: 0=do not allow arguments, 1=allow command arguments #dont_blame_nrpe=0 dont_blame_nrpe=1
(3)監視対象側と監視サーバにて、iptablesを有効にしている場合には、5666ポートを開放してください。
・「/etc/sysconfig/iptables」を編集します。
# vi /etc/sysconfig/iptables
・「iptables」ファイル変更前の内容
-A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited
・「iptables」ファイル変更後の内容
-A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 5666 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited