host_name:必须是主机配置文件hosts.cfg中定义的主机。
check_command:在commands.cfg文件中定义或在nrpe.cfg里面定义的命令;
max_check_attempts: 最大重试次数,一般设置为4次左右;
normal_check_interval 和retry_check_interval检查间隔的单位是分钟。
notification_interval 通知间隔指探测到故障后,每隔多长时间发送一次报警信息,单位是分钟。
notification_options:通知选项跟联系人配置文件相同。
contact_groups:配置文件contactgroup.cfg定义的组名称。
注意:check_command选项后面跟的命令一定要在commands.cfg里有定义;
例子:
vi /usr/local/nagios/etc/services.cfg
#监控主机是否存活
define service{
host_name nagios-server
service_description check-host-alive
check_command check-host-alive
max_check_attempts 5
normal_check_interval 5
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups sagroup
}
#监控主机的web服务
define service{
host_name nagios-server
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
}
#监控主机的cpu负载情况
define service{
host_name nagios-server
service_description cpu load
check_command check_nrpe!check_load
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
}
#监控主机的进程数
define service{
host_name nagios-server
service_description total-procs
check_command check_nrpe!check_total_procs
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
}