■とりあえずRPMでインストールすると・・・
/etc/nagios/ 設定ファイル類
/usr/lib/nagios/ cgi、plugin
/usr/share/nagios/ HTMLのディレクトリ
■pluginは/usr/lib/nagios/plugin/の下に全部置くこと
RedHat9ではpluginのRPMはインストールに失敗するので、
tarballを使う方がよい。
pluginとnagiosのバージョンは別物。
■httpd.confに下記の設定をして、http://servername/nagios/を開く
Alias /nagios/ /usr/share/nagios/Options None AllowOverride AuthConfig Order allow,deny Allow from all ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi/
Options ExecCGI AllowOverride AuthConfig Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /etc/nagios/htpasswd.users require valid-user
■設定
/etc/nagios の下に設定ファイル類がある
contacts.cfg
hosts.cfg
services.cfg
の順に編集する。
cgi.cfgで、authなどを有効にしたりする。
設定を確認するには# nagios -v nagios.cfgとする。 OKであれば、
# /etc/init.d/nagios reloadとする。
■contacts.cfg の例
define contact{
contact_name admin ; htpasswdで登録したユーザーと同じにする
alias admin ; 日本語euc可能
service_notification_period 24x7 ; サービス異常時の通知時間帯
host_notification_period 24x7 ; ホスト異常時の通知時間帯
service_notification_options w,u,c,r ; warning,unknown,critical,recover,none
host_notification_options d,u,r ; のステータスの略文字である。
service_notification_commands notify-by-email,notify-by-epager
host_notification_commands host-notify-by-email,host-notify-by-epager
email webmaster@example.local ; 通知先
pager hoge@xxx.ne.jp ; 携帯など
}
define contactgroup{ ; 一応、グループも登録する必要がある
contactgroup_name admins
alias admins
members admin
}
■hosts.cfg の例
# # まずテンプレートを定義する。 # これは[register 0]によりテンプレとみなされる。 # define host{ name generic-host notifications_enabled 1 ; 通知の有無 0で無効、1で通知 event_handler_enabled 1 ; イベントハンドラの有無 flap_detection_enabled 1 ; 状態反転の検出 process_perf_data 1 ; パフォーマンスデータの統計 retain_status_information 1 ; nagiosの再起動時にも状態を保存する retain_nonstatus_information 1 ; 状態以外の情報も保存するcheck_command check-host-alive; これで1回pingを打つ max_check_attempts 10 ; 10回pingが帰ってこなかったらエラー notification_interval 120 ; 通知間隔 notification_period 24x7 ; 通知時間帯 notification_options d,u,r ; 通知レベル
register 0 ; 0でテンプレとなる }
define host{ use generic-host host_name www.example.local alias www.example.local addresss 192.168.0.5 parents PPPoE_Router ; hostからnagiosをみて1metric前のルータ }
■services.cfg の例
define service{
name generic-service
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
contact_groups admins
register 0
}
#
# www.example.local
#
define service{
use generic-service
host_name www.example.local
service_description PING
check_command check_ping!20.0,20%!50.0,60%
}
