2012-04-23 53 views
1

我想配置Nagios在HostA或HostA上的任何服务出现问题时向UserA发送警报。第一部分 - 当HostA出现问题时 - 很直接,但是当给定主机(或主机组)上的任何服务出现问题时,我无法看到如何向给定用户发送警报。需要明确的是:主机和服务的Nagios通知

如果hostA上的所有服务有问题,通知用户A
如果主机B上的任何服务有问题,通知用户B

任何指针或想法?

+1

[Nagios服务通知为特定主机]可能的重复(http://stackoverflow.com/questions/19412129/nagios-service-notifications-for-specific-hosts) – jwg 2016-02-29 10:26:47

+0

有一个这个问题的一个愚蠢有一个更好的答案:http://stackoverflow.com/questions/19412129/nagios-service-notifications-for-specific-hosts?rq=1 – jwg 2016-02-29 10:27:07

回答

0

在服务定义中,您需要设置contact_groups(并在其他地方定义组)。下面是一个示例:

define service{ 
    name       A-service ; The 'name' of this service template 
    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 
    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 
    retain_nonstatus_information 1  ; Retain non-status information across program restarts 
    notification_interval   0  ; Only send notifications on status$ 
    is_volatile      0 
    check_period     24x7 
    normal_check_interval   5 
    retry_check_interval   1 
    max_check_attempts    4 
    notification_period    24x7 
    notification_options   w,u,c,r 
    contact_groups     A_only ; >>>Here's the magic you need<<< 
    register      0  ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SE$ 
} 
# for contact config file 
define contactgroup{ 
    contactgroup_name  A_only 
    alias     APeople 
    members     APerson1, APerson2 
} 

对于B组,将A_only更改为B_only并创建一个新的联系人组。

+0

这是行不通的。这意味着所有相同的服务需要定义两次,一次为A主机,一次为B主机。 – jwg 2016-02-29 08:45:48