bin
|
Nagios
執行程序所在目錄,這個目錄只有一個文件
nagios
|
etc
|
Nagios
配置文件位置,初始安裝完後,只有幾個
*.cfg-sample
文件
|
sbin
|
Nagios Cgi
文件所在目錄,也就是執行外部命令所需文件所在的目錄
|
Share
|
Nagios
網頁文件所在的目錄
|
Var
|
Nagios
日誌文件、
spid
等文件所在的目錄
|
#setting for nagios
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin"> //
Cgi
文件所在目錄
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd //
驗證文件路徑
Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share"> //
nagios
頁面文件目錄
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd //
驗證文件路徑
Require valid-user
</Directory>
|
cfg_file=/usr/local/nagios/etc/contactgroups.cfg //
聯繫組配置文件路徑
cfg_file=/usr/local/nagios/etc/contacts.cfg //
聯繫人配置文件路徑
cfg_file=/usr/local/nagios/etc/hostgroups.cfg //
主機組配置文件路徑
cfg_file=/usr/local/nagios/etc/hosts.cfg //
主機配置文件路徑
cfg_file=/usr/local/nagios/etc/services.cfg //
服務配置文件路徑
cfg_file=/usr/local/nagios/etc/timeperiods.cfg //
監視時段配置文件路徑
|
authorized_for_system_information=nagiosadmin,sery
authorized_for_configuration_information=nagiosadmin,sery
authorized_for_system_commands=sery //
多個用戶之間用逗號隔開
authorized_for_all_services=nagiosadmin,sery
authorized_for_all_hosts=nagiosadmin,sery
authorized_for_all_service_commands=nagiosadmin,sery
authorized_for_all_host_commands=nagiosadmin,sery
|
#host-notify-by-sms //
發送短信報警
define command {
command_name host-notify-by-sms
command_line /usr/local/bin/sms_send "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$' " $CONTACTPAGER$
}
#service notify by sms //
發送短信報警
define command {
command_name service-notify-by-sms
command_line /usr/local/bin/sms_send "'$HOSTADDRESS$' $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$" $CONTACTPAGER$
}
|
define timeperiod{
timeperiod_name 24x7
alias 24 Hours A Day, 7 Days A Week
sunday 00:00-24:00
monday 00:00-24:00
tuesday 00:00-24:00
wednesday 00:00-24:00
thursday 00:00-24:00
friday 00:00-24:00
saturday 00:00-24:00
}
|
define contact {
contact_name sa //
不要有空格
alias system administrator
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands service-notify-by-sms,service-
notify-by-email //
這個命令讀配置文件
miscommands.cfg
host_notification_commands host-notify-by-email,host-noti
fy-by-sms //
這個命令讀配置文件
miscommands.cfg
email [email]sery@163.com[/email]
pager 13333333333 //
手機號,收報警短信
} //
不要把這個符號寫掉了
define contact {
contact_name sery
alias system administrator
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands service-notify-by-sms,service-
notify-by-email
host_notification_commands host-notify-by-email,host-noti
fy-by-sms
email [email]sery@sohu.com[/email]
pager 13312345678
}
|
define contactgroup {
contactgroup_name sagroup //
不要用空格
alias system administrator group
members sa,sery //
本例有
2
個成員
}
|
#define monitor host
############################################
# Wangjing IDC servers #
############################################
define host {
host_name nagios-server
alias nagios server
address 61.x..x.49
contact_groups sagroup //
多個聯繫組用逗號分隔,數據來源於
contactgroups.cfg
check_command check-host-alive
max_check_attempts 5
notification_interval 10 //
值可調,大小什麼值合適需本身測定
notification_period 24x7
notification_options d,u,r
}
define host {
host_name 24-25
alias server 24-25
address 202.X.24.25
contact_groups sagroup
check_command check-host-alive //
down
機就發報警通知
max_check_attempts 5
notification_interval 10
notification_period 24x7
notification_options d,u,r
}
|
#service definition
###########################################
# Wangjing IDC servers service for host-live #
###########################################
define service {
host_name nagios-server //
來源:
hosts.cfg
service_description check-host-alive
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup //
來源:
contactgroups.cfg
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive //
檢查主機是否存活
}
define service {
host_name 74-210
service_description check_tcp 80
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_tcp!80 //
檢查
tcp 80
端口服務是否正常
}
|
define hostgroup {
hostgroup_name sa-servers
alias sa servers
members nagios-server,24-25,24-26 //
用逗號間隔多個主機
}
|
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
|
[root@netmonitor nagios]# bin/nagios -v etc/nagios.cfg
Nagios 2.5
Copyright (c) 1999-2006 Ethan Galstad ([url]http://www.nagios.org[/url])
Last Modified:
License: GPL
Reading configuration data...
Error: Could not find any host matching 'nagios-server'
Error: Could not expand member hosts specified in hostgroup (config file '/usr/local/nagios/etc/hostgroups.cfg', starting on line 2)
………………………
|