Last Updated on 2022年6月24日 by かんりにん
nagiosプラグインの環境セットアップ(コンパイル版) †
リモートホストへsnmpで値を取得する"check_snmp_*"プラグインの導入ドキュメント。
- 参考サイト:お世話になっております!
- http://nagios.manubulon.com/
http://nagios.manubulon.com/index_snmp.html - Nagios snmp plugin
http://satospo.sakura.ne.jp/blog_archives/tech/network/nagios_snmp.html
配置されるプラグイン †
check_snmp_int
インターフェースの監視
check_snmp_process
プロセス数、メモリ使用率監視(プロセス名を指定する)
check_snmp_storage
ディスク使用率の監視
インストール †
ビルド・コンパイルしてインストールするとlibexec/以下に配置される。
# ./configure --prefix=/usr/local/nagios # make # make install
プラグイン動作確認 †
perl版プラグインに同様のものがある場合も、同じオプションを使用できる。
- check_snmp_int
# ./check_snmp_int -H 192.168.0.128 -C public -n eth0 OK : eth0:UP: 1 UP
- check_snmp_process
# ./check_snmp_process -H 192.168.0.128 -C public -n http -w 3,10 -c 0,15 -m 30,100 OK : 8 process matching http(> 3, <= 10), Mem 15.9MB OK -check_snmp_storage # ./check_snmp_storage -H 192.168.0.128 -C public -m ^$/ -w 60 -c 80 OK : /: 25%used(4588MB/18723MB)t=27MB;59;78;0;98
※ルートパーティションを指定する場合に"/"のままだと
全てのパーティションにマッチングしてしまうため、 正規表現で"^/$"と指定すること。
nagios環境設定 †
1)変数定義/resource.cfg †
snmpプラグインを実行する際に指定するコミュニティをユーザー変数に登録して コマンド定義を簡略化しておく。
$USER7$に変数publicを定義。
- /usr/local/nagios/etc/resource.cfg
# define snmp version $USER7$=public
2)コマンド定義/command.cfg †
- check_snmp_int # check_snmp_int define command{ command_name check_snmp_int command_line $USER1$/check_snmp_int -H $HOSTADDRESS$ -C $USER7$ -n $ARG1 } – check_snmp_process define command{ command_name check_snmp_process command_line $USER1$/check_snmp_process -H $HOSTADDRESS$ -C $USER7$ -n $ARG1$ -w $ARG2$ -c $ARG3$ -m $ARG4$ } – check_snmp_storage # check_snmp_storage define command{ command_name check_snmp_storage command_line $USER1$/check_snmp_storage -H $HOSTADDRESS$ -C $USER7$ -m $ARG1$ -w $ARG2$ -c $ARG3$ }
3)ホスト定義 †
/usr/local/nagios/etc/object以下に監視対象サーバのホスト定義ファイルを作成し 監視対象サービスを定義する。
- check_snmp_int # Define a service to check the disk space of the root partition define service { use local-service ; Name of service template to use host_name webserver02 service_description Interface Usage eth0 check_command check_snmp_int!eth0 notifications_enabled 0 }
- check_snmp_process # Define a service to check HTTP on the remote machine. define service{ use local-service ; Name of service template to use host_name webserver02 service_description HTTP check_command check_snmp_process!http!3,10!0,15!30,100 notifications_enabled 0 }
- check_snmp_storage
※サービス定義# Define a service to check the disk space of the root partition define service { use local-service ; Name of service template to use host_name webserver02 service_description Disk Partition Usage / check_command check_snmp_storage!/!90!97 notifications_enabled 0 }
4)nagios.cfgへホスト定義ファイルを登録 †
# pwd /usr/local/nagios/etc # vi nagios.cfg
- [追記内容]
> cfg_file=/usr/local/nagios/etc/objects/
5)書式確認および再起動 †
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
→"Things look okay"が出たら再起動。
# /etc/init.d/nagios restart
nagios動作確認 †
nagios管理画面のserviceページにて、ステータスの取得・更新が行われていることを確認。