---
title: "Nagios---define service"
author: "bwhzhl"
date: "2011-05-06T12:59:05Z"
tags: []
categories: ["操作系统"]
slug: "nagios-define-service"
draft: false
lastmod: "2011-05-06T12:59:05Z"
id: 1032999
url: "https://permiss.iteye.com/blog/1032999"
---

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表明该段为主机类段。  
         }

\# Local service definition template - This is NOT a real service, just a template!  
这里Nagios还默认定义了一个针对“本地系统监测服务”的类。

define 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表明本段定义的是一个服务类，而不是具体的服务。  
}