nagiosでフリーな監視をしてみよう!~nagiosの設定(5)~
nrpeの設定
(1)監視サーバ側にて、nrpeの設定を行います。
・「commands.cfg」にcheck_nrpeコマンドを最終行に追加します。
1 | # vi /usr/local/nagios/etc/objects/commands.cfg |
・「commands.cfg」ファイル変更後の内容
237 238 239 240 241 242 243 | } # 'check_nrpe' command definition define command { command_name check_nrpe command_line $USER1$ /check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } |
(2)監視対象となるサーバ側にて、nrpeの設定を行います。
・TCP5666をnrpeのサービスポートとして追加します。
1 | # echo "nrpe 5666/tcp # NRPE" >> /etc/services |
・xinetd用のnrpe設定を編集します。
1 | # vi /etc/xinetd.d/nrpe |
・「nrpe」ファイル変更前の内容
3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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」ファイル変更後の内容
3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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サーバが送信する対象のアドレスを設定します。
1 | # vi /usr/local/nagios/etc/nrpe.cfg |
・「nrpe.cfg」ファイル変更前の内容
39 40 41 42 43 44 | # 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 |
79 80 81 | # NOTE: This option is ignored if NRPE is running under either inetd or xinetd #allowed_hosts=127.0.0.1 |
nrpeが引数を受け付けるように、機能を有効にします。
95 96 97 | # Values: 0=do not allow arguments, 1=allow command arguments dont_blame_nrpe=0 |
・「nrpe.cfg」ファイル変更後の内容
39 40 41 42 43 44 45 | # 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 |
79 80 81 82 | # 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 |
95 96 97 98 | # Values: 0=do not allow arguments, 1=allow command arguments #dont_blame_nrpe=0 dont_blame_nrpe=1 |
(3)監視対象側と監視サーバにて、iptablesを有効にしている場合には、5666ポートを開放してください。
・「/etc/sysconfig/iptables」を編集します。
1 | # vi /etc/sysconfig/iptables |
・「iptables」ファイル変更前の内容
9 10 11 | -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」ファイル変更後の内容
9 10 11 12 | -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 |