配置文件路径/usr/local/nagios/etc/objects
类型名 包含文件 作用
基类配置文件 templates.cfg 定义基类
时间配置文件 timeperiods.cfg 定义控制时间
联系人文件 contacts.cfg 定义联系人信息和联系人组
监控文件 localhost.cfg 定义监控主机和监控的服务,主要是linux系统的主机
命令定义文件 commands.cfg 定义插件参数和如何发送短信、邮件等
1、时间定义段
在时间定义段里,可以自己定义好几个指定的时间段并给与命名。Nagios应该在什么时间内做什么工作,对于Nagios自己来说并不是直接引用时间参数,而是引用用户自己定义的时间段的命名,Nagios只会参考和引用用户定义过的时间段名。
define timeperiod{
使用define定义关键字timepriod表示该定义段内定义的是时间段。段内的定义请使用两个大括号来包括。段内的定义项一行一项,时间格式请按照以下。另外,如果要定义多个时间段的话,那么必须要写多个define timeperiod {} 段。
timeperiod_name all_days
通过timeperiod_name来指定时间段名。这里我定义了一个时间段名为all_days“全天”,然后时间设定从周一到周日全天24小时。
alias 24 Hours A Day, 7 Days A Week
通过alias来指定时间段的说明信息。
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
以上为时间格式。前面是星期名,后面是24小时制的时间格式。
}
# 'workhours' timeperiod definition
这个是Nagios默认定义的一个时间段,名字叫做workhours“工作时段”,定义的时间也是周一到周五的早上9点到晚上的17点。多样化的时间段可以丰富Nagios功能配置的灵活性。当Nagios在进行只在工作时间才有必要进行的操作而休息时间没有这种必要的时候,就可以使用该时间段进行配置参与。
define timeperiod{
timeperiod_name workhours
alias "Normal" Working Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
# 'nonworkhours' timeperiod definition
这个也是Nagios默认定义的一个时间段,名字叫做nonworkhours“非工作时段”,定义的时间为周一到周五的晚上17到早上9点以及双休日全天。当Nagios在进行只有在休息时间才进行的操作而在工作时间内不进行的情况下,就可以使用该时间段进行配置参与。
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}
# 'none' timeperiod definition
这个是Nagios默认的最后一个时间段,名字叫做none“无时间”,也没有定义的时间段。还不是很清楚这个时间段会用在什么情况呢,也许一些永远都不希望Nagios执行的操作会用此时间段参与配置吧?哈。
define timeperiod{
timeperiod_name none
alias No Time Is A Good Time
}
2.联系人定义段
在Nagios的诸多工作中都会涉及到联系人。当发生监测超出阀值,或者产程告警等情况时,Nagios都会以Email甚至更多方式来告知指定的联系人。联系人应该是系统当中存在的用户或者是Email的别名用户,以便于接收到重要的消息通知。
define contact{
使用define定义关键字contact表示该定义段内定义的是联系人段。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个联系人段的话,那么必须要写多个define contact {} 段。
contact_name nagios-admin
通过contact_name来指定联系人名,这个名应该是系统内用户名或者是Email用户别名(推荐后者)。同时,这个联系人名也将会是Nagios认可的注册联系人名。(这里我偷懒,在系统中直接useradd添加了nagios-admin这个用户)
alias Nagios Admin
通过alias来指定该联系人的说明信息。
service_notification_period all_days
设定服务事件通知时间段,后面指定时间段名。请注意,这里后面跟的参数为定义过的timeperiods的时间段名。
host_notification_period all_days
设定主机事件通知时间段,后面指定时间段名。请注意,这里后面跟的参数为定义过的timeperiods的时间段名。
service_notification_options w,u,c,r
设定触发服务事件通知的选项,这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
host_notification_options d,r
设定触发主机事件通知的选项,后面也跟上级别类型参数。
service_notification_commands notify-by-email
设定服务事件通知的命令,该命令的具体内容在command.cfg里定义。
host_notification_commands host-notify-by-email
设定主机时间通知的命令,该命令的具体内容在command.cfg里定义。
email nagios-admin@localhost
设定通知邮件的联系人的Email地址。
}
联系人组就是将若干联系人聚合起来的组。
define contactgroup{
使用define定义关键字contactgroup表示该定义段内定义的是联系人组段。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个联系人组段的话,那么必须要写多个define contactgroup {} 段。
contactgroup_name admins
通过contactgroup_name来指定联系人组名。
alias Nagios Administrators
通过alias来指定该联系人组名的简要信息。
members nagios-admin
通过members来指定组成员,组成员必须是contect里定义过的联系人。
}
3.主机定义段
主机定义段定义了Nagios监测的主机对象,Nagios只监测的在主机定义段里定义过的主机名。主机定义段里面有个一个十分有趣的地方,就是他能够定义主机类,在主机类当中定义一些公共属性,然后定义个别主机的时候并不需要把每个属性都一一定义出来,而只需要引用和继承之前的主机类,就能够继承主机类当中的公共属性,有趣的是类还能继承类。事先多定义几个不同的类,在大规模部署监测主机的时候效率将特别高。
## Generic host definition template - This is NOT a real host, just a template!
默认Nagios就定义了通用主机的大类generic-host。在这个类中定义了无论什么系统和条件的所有主机都会共有的一些属性。
define host{
使用define定义关键字host表示该定义段内定义的是主机段,也可以是主机类。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个主机段的话,那么必须要写多个define host {} 段。
name generic-host ; The name of this host template
通过name来指定主机类名,这里的generic-host就是一个主机类名。
notifications_enabled 1 ; Host notifications are enabled
设定启用主机事件通知
event_handler_enabled 1 ; Host event handler is enabled
设定启用主机事件处理程序
flap_detection_enabled 1 ; Flap detection is enabled
设定启用状态抖动监测。
failure_prediction_enabled 1 ; Failure prediction is enabled
设定启用故障预测
process_perf_data 1 ; Process performance data
设定启用进程性能数据记录
retain_status_information 1 ; Retain status information across program restarts
设定启用状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的状态数据。
retain_nonstatus_information 1 ; Retain non-status information across program restarts
设定启用非状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的非状态数据。
notification_period all_days ; Send host notifications at any time
设定事件通知的工作时间段。后面要跟上定义过的时间段名,这里用全天时间段。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
设定非注册。此项register为0值的时候Nagios会理解到该定义段是主机类而为实体主机的定义段。因此,在自定义主机类段的时候,记得也要加入这一个属性,用来向Nagios表明该段为主机类段。
}
以下再建立一个Linux主机类段linux-server。这个类同时也继承了之前的通用主机类generic-host类,也就是说类也可以继承类。这样的关系和设定将使得主机设定进一步灵活。
define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
通过use来指定要继承的主机类名。类也可以继承类。
check_period all_days ; By default, Linux hosts are checked round the clock
max_check_attempts 10 ; Check each Linux host 10 times (max)
设定监测失败后的最大尝试次数。
check_command check-host-alive ; Default command to check Linux hosts
设定监测主机存活的命令。
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 15 ; Resend notification every 15 seconds.
设定监测主机的时间间隔,单位为秒
notification_options d,u,r ; Only send notifications for specific host states
设定监测指定主机产生的事件通知的条件选项。这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
contact_groups admins ; Notifications get sent to the admins by default
指定联系人组,这里的联系人组名必须是定义过的。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
设定register表明本段定义的是一个主机类,而不是实体主机。
}
注:nagios默认还有其几个主机类,如windows-server
以下为实体主机的定义了,它的配置文件在/usr/local/nagios/etc/objects/localhost.cfg。首先必须要有localhost本地主机的定义段,否则很多基本功能都会有问题。
define host{
use linux-server
通过use来继承linux-server这个之前专为Linux主机定义的类。
host_name localhost
通过host_name来指定主机名,这里是localhost。另外必须要知道的是,这里定义的主机名,和真正监测对象的主机的主机名并不一定要完全对的上,这里定义的主机名只是一个在Naigos系统中注册的、定义的、Nagios能够识别的主机标示而已。
alias localhost
通过alias写上一些对该主机的描述。
address 127.0.0.1
通过address来指定该主机的IP地址。Nagios对监测对象的主要根据是这个IP地址。
}
4.服务定义段
默认Nagios已经定义了一个通用服务大类generic-service,这个类当中定义的属性是无论什么服务都必须的属性。
define service{
使用define定义关键字service表示该定义段内定义的是服务段,也可以是服务类。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个服务段的话,那么必须要写多个define service {} 段。
name generic-service ; The 'name' of this service template
通过name来指定服务类名,这里的generice-service是一个类名。
active_checks_enabled 1 ; Active service checks are enabled
设定启用活动监测服务。
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
设定启用被动监测服务。
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
设定启用并发活动监测服务。
obsess_over_service 1 ; We should obsess over this service (if necessary)
设定启用服务防停滞。
check_freshness 0 ; Default is to NOT check service 'freshness'
设定关闭更新监测。
notifications_enabled 1 ; Service notifications are enabled
设定启用事件通知。
event_handler_enabled 1 ; Service event handler is enabled
设定启用事件处理程序。
flap_detection_enabled 1 ; Flap detection is enabled
设定启用状态抖动监测。
failure_prediction_enabled 1 ; Failure prediction is enabled
设定启用故障预测。
process_perf_data 1 ; Process performance data
设定启用进程性能数据记录。
retain_status_information 1 ; Retain status information across program restarts
设定启用状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的状态数据。
retain_nonstatus_information 1 ; Retain non-status information across program restarts
设定启用非状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的非状态数据。
is_volatile 0 ; The service is not volatile
设定服务非易失。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
设定非注册。此项register为0值的时候Nagios会理解到该定义段是主机类而为实体主机的定义段。因此,在自定义主机类段的时候,记得也要加入这一个属性,用来向Nagios表明该段为主机类段。
}
efine service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
通过use来继承generic-service这个类。类也是能够继承类的。
check_period all_days ; The service can be checked at any time of the day
max_check_attempts 2 ; Re-check the service up to 4 times in order to determine its final (hard) state
设定监测失败后最尝试次数。
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
设定正常监测服务的间隔,单位秒。
retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined
设定监测失败后尝试的间隔,单位秒。
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
设定联系组。
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
设定监测指定服务产生的事件通知的条件选项。这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
notification_interval 15 ; Re-notify about service problems every hour
设定服务通知的间隔。
notification_period all_days ; Notifications can be sent out at any time
设定服务通知运行时间。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
设定register表明本段定义的是一个服务类,而不是具体的服务。
}
类型名 包含文件 作用
基类配置文件 templates.cfg 定义基类
时间配置文件 timeperiods.cfg 定义控制时间
联系人文件 contacts.cfg 定义联系人信息和联系人组
监控文件 localhost.cfg 定义监控主机和监控的服务,主要是linux系统的主机
命令定义文件 commands.cfg 定义插件参数和如何发送短信、邮件等
1、时间定义段
在时间定义段里,可以自己定义好几个指定的时间段并给与命名。Nagios应该在什么时间内做什么工作,对于Nagios自己来说并不是直接引用时间参数,而是引用用户自己定义的时间段的命名,Nagios只会参考和引用用户定义过的时间段名。
define timeperiod{
使用define定义关键字timepriod表示该定义段内定义的是时间段。段内的定义请使用两个大括号来包括。段内的定义项一行一项,时间格式请按照以下。另外,如果要定义多个时间段的话,那么必须要写多个define timeperiod {} 段。
timeperiod_name all_days
通过timeperiod_name来指定时间段名。这里我定义了一个时间段名为all_days“全天”,然后时间设定从周一到周日全天24小时。
alias 24 Hours A Day, 7 Days A Week
通过alias来指定时间段的说明信息。
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
以上为时间格式。前面是星期名,后面是24小时制的时间格式。
}
# 'workhours' timeperiod definition
这个是Nagios默认定义的一个时间段,名字叫做workhours“工作时段”,定义的时间也是周一到周五的早上9点到晚上的17点。多样化的时间段可以丰富Nagios功能配置的灵活性。当Nagios在进行只在工作时间才有必要进行的操作而休息时间没有这种必要的时候,就可以使用该时间段进行配置参与。
define timeperiod{
timeperiod_name workhours
alias "Normal" Working Hours
monday 09:00-17:00
tuesday 09:00-17:00
wednesday 09:00-17:00
thursday 09:00-17:00
friday 09:00-17:00
}
# 'nonworkhours' timeperiod definition
这个也是Nagios默认定义的一个时间段,名字叫做nonworkhours“非工作时段”,定义的时间为周一到周五的晚上17到早上9点以及双休日全天。当Nagios在进行只有在休息时间才进行的操作而在工作时间内不进行的情况下,就可以使用该时间段进行配置参与。
define timeperiod{
timeperiod_name nonworkhours
alias Non-Work Hours
sunday 00:00-24:00
monday 00:00-09:00,17:00-24:00
tuesday 00:00-09:00,17:00-24:00
wednesday 00:00-09:00,17:00-24:00
thursday 00:00-09:00,17:00-24:00
friday 00:00-09:00,17:00-24:00
saturday 00:00-24:00
}
# 'none' timeperiod definition
这个是Nagios默认的最后一个时间段,名字叫做none“无时间”,也没有定义的时间段。还不是很清楚这个时间段会用在什么情况呢,也许一些永远都不希望Nagios执行的操作会用此时间段参与配置吧?哈。
define timeperiod{
timeperiod_name none
alias No Time Is A Good Time
}
2.联系人定义段
在Nagios的诸多工作中都会涉及到联系人。当发生监测超出阀值,或者产程告警等情况时,Nagios都会以Email甚至更多方式来告知指定的联系人。联系人应该是系统当中存在的用户或者是Email的别名用户,以便于接收到重要的消息通知。
define contact{
使用define定义关键字contact表示该定义段内定义的是联系人段。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个联系人段的话,那么必须要写多个define contact {} 段。
contact_name nagios-admin
通过contact_name来指定联系人名,这个名应该是系统内用户名或者是Email用户别名(推荐后者)。同时,这个联系人名也将会是Nagios认可的注册联系人名。(这里我偷懒,在系统中直接useradd添加了nagios-admin这个用户)
alias Nagios Admin
通过alias来指定该联系人的说明信息。
service_notification_period all_days
设定服务事件通知时间段,后面指定时间段名。请注意,这里后面跟的参数为定义过的timeperiods的时间段名。
host_notification_period all_days
设定主机事件通知时间段,后面指定时间段名。请注意,这里后面跟的参数为定义过的timeperiods的时间段名。
service_notification_options w,u,c,r
设定触发服务事件通知的选项,这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
host_notification_options d,r
设定触发主机事件通知的选项,后面也跟上级别类型参数。
service_notification_commands notify-by-email
设定服务事件通知的命令,该命令的具体内容在command.cfg里定义。
host_notification_commands host-notify-by-email
设定主机时间通知的命令,该命令的具体内容在command.cfg里定义。
email nagios-admin@localhost
设定通知邮件的联系人的Email地址。
}
联系人组就是将若干联系人聚合起来的组。
define contactgroup{
使用define定义关键字contactgroup表示该定义段内定义的是联系人组段。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个联系人组段的话,那么必须要写多个define contactgroup {} 段。
contactgroup_name admins
通过contactgroup_name来指定联系人组名。
alias Nagios Administrators
通过alias来指定该联系人组名的简要信息。
members nagios-admin
通过members来指定组成员,组成员必须是contect里定义过的联系人。
}
3.主机定义段
主机定义段定义了Nagios监测的主机对象,Nagios只监测的在主机定义段里定义过的主机名。主机定义段里面有个一个十分有趣的地方,就是他能够定义主机类,在主机类当中定义一些公共属性,然后定义个别主机的时候并不需要把每个属性都一一定义出来,而只需要引用和继承之前的主机类,就能够继承主机类当中的公共属性,有趣的是类还能继承类。事先多定义几个不同的类,在大规模部署监测主机的时候效率将特别高。
## Generic host definition template - This is NOT a real host, just a template!
默认Nagios就定义了通用主机的大类generic-host。在这个类中定义了无论什么系统和条件的所有主机都会共有的一些属性。
define host{
使用define定义关键字host表示该定义段内定义的是主机段,也可以是主机类。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个主机段的话,那么必须要写多个define host {} 段。
name generic-host ; The name of this host template
通过name来指定主机类名,这里的generic-host就是一个主机类名。
notifications_enabled 1 ; Host notifications are enabled
设定启用主机事件通知
event_handler_enabled 1 ; Host event handler is enabled
设定启用主机事件处理程序
flap_detection_enabled 1 ; Flap detection is enabled
设定启用状态抖动监测。
failure_prediction_enabled 1 ; Failure prediction is enabled
设定启用故障预测
process_perf_data 1 ; Process performance data
设定启用进程性能数据记录
retain_status_information 1 ; Retain status information across program restarts
设定启用状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的状态数据。
retain_nonstatus_information 1 ; Retain non-status information across program restarts
设定启用非状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的非状态数据。
notification_period all_days ; Send host notifications at any time
设定事件通知的工作时间段。后面要跟上定义过的时间段名,这里用全天时间段。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
设定非注册。此项register为0值的时候Nagios会理解到该定义段是主机类而为实体主机的定义段。因此,在自定义主机类段的时候,记得也要加入这一个属性,用来向Nagios表明该段为主机类段。
}
以下再建立一个Linux主机类段linux-server。这个类同时也继承了之前的通用主机类generic-host类,也就是说类也可以继承类。这样的关系和设定将使得主机设定进一步灵活。
define host{
name linux-server ; The name of this host template
use generic-host ; This template inherits other values from the generic-host template
通过use来指定要继承的主机类名。类也可以继承类。
check_period all_days ; By default, Linux hosts are checked round the clock
max_check_attempts 10 ; Check each Linux host 10 times (max)
设定监测失败后的最大尝试次数。
check_command check-host-alive ; Default command to check Linux hosts
设定监测主机存活的命令。
notification_period workhours ; Linux admins hate to be woken up, so we only notify during the day
; Note that the notification_period variable is being overridden from
; the value that is inherited from the generic-host template!
notification_interval 15 ; Resend notification every 15 seconds.
设定监测主机的时间间隔,单位为秒
notification_options d,u,r ; Only send notifications for specific host states
设定监测指定主机产生的事件通知的条件选项。这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
contact_groups admins ; Notifications get sent to the admins by default
指定联系人组,这里的联系人组名必须是定义过的。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
设定register表明本段定义的是一个主机类,而不是实体主机。
}
注:nagios默认还有其几个主机类,如windows-server
以下为实体主机的定义了,它的配置文件在/usr/local/nagios/etc/objects/localhost.cfg。首先必须要有localhost本地主机的定义段,否则很多基本功能都会有问题。
define host{
use linux-server
通过use来继承linux-server这个之前专为Linux主机定义的类。
host_name localhost
通过host_name来指定主机名,这里是localhost。另外必须要知道的是,这里定义的主机名,和真正监测对象的主机的主机名并不一定要完全对的上,这里定义的主机名只是一个在Naigos系统中注册的、定义的、Nagios能够识别的主机标示而已。
alias localhost
通过alias写上一些对该主机的描述。
address 127.0.0.1
通过address来指定该主机的IP地址。Nagios对监测对象的主要根据是这个IP地址。
}
4.服务定义段
默认Nagios已经定义了一个通用服务大类generic-service,这个类当中定义的属性是无论什么服务都必须的属性。
define service{
使用define定义关键字service表示该定义段内定义的是服务段,也可以是服务类。段内的定义请使用两个大括号来包括。段内的定义项一行一项。另外,如果要定义多个服务段的话,那么必须要写多个define service {} 段。
name generic-service ; The 'name' of this service template
通过name来指定服务类名,这里的generice-service是一个类名。
active_checks_enabled 1 ; Active service checks are enabled
设定启用活动监测服务。
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
设定启用被动监测服务。
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
设定启用并发活动监测服务。
obsess_over_service 1 ; We should obsess over this service (if necessary)
设定启用服务防停滞。
check_freshness 0 ; Default is to NOT check service 'freshness'
设定关闭更新监测。
notifications_enabled 1 ; Service notifications are enabled
设定启用事件通知。
event_handler_enabled 1 ; Service event handler is enabled
设定启用事件处理程序。
flap_detection_enabled 1 ; Flap detection is enabled
设定启用状态抖动监测。
failure_prediction_enabled 1 ; Failure prediction is enabled
设定启用故障预测。
process_perf_data 1 ; Process performance data
设定启用进程性能数据记录。
retain_status_information 1 ; Retain status information across program restarts
设定启用状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的状态数据。
retain_nonstatus_information 1 ; Retain non-status information across program restarts
设定启用非状态信息保存功能。当Nagios重新启动的时候不会是空数据,而是先显示上次离线时最后保留的非状态数据。
is_volatile 0 ; The service is not volatile
设定服务非易失。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
设定非注册。此项register为0值的时候Nagios会理解到该定义段是主机类而为实体主机的定义段。因此,在自定义主机类段的时候,记得也要加入这一个属性,用来向Nagios表明该段为主机类段。
}
efine service{
name local-service ; The name of this service template
use generic-service ; Inherit default values from the generic-service definition
通过use来继承generic-service这个类。类也是能够继承类的。
check_period all_days ; The service can be checked at any time of the day
max_check_attempts 2 ; Re-check the service up to 4 times in order to determine its final (hard) state
设定监测失败后最尝试次数。
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
设定正常监测服务的间隔,单位秒。
retry_check_interval 1 ; Re-check the service every minute until a hard state can be determined
设定监测失败后尝试的间隔,单位秒。
contact_groups admins ; Notifications get sent out to everyone in the 'admins' group
设定联系组。
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
设定监测指定服务产生的事件通知的条件选项。这里后面跟上一些级别类型参数:
w代表warning告警;
u代表unknown未知;
c代表critical严重;
r代表recover恢复;
d代表down奔溃。
notification_interval 15 ; Re-notify about service problems every hour
设定服务通知的间隔。
notification_period all_days ; Notifications can be sent out at any time
设定服务通知运行时间。
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
设定register表明本段定义的是一个服务类,而不是具体的服务。
}