Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have 3 templates for services, low-priority, high-priorty and medium-priorty. Low priority services are attached to the contactgroup low, medium priorty services are attached to the contact group medium and high priority (OK you probably get the idea).

Low priority services don't notify, medium priority alerts notify by email and high priority alerts notify by email and phone. Except they don't (yet)

What I need to do is specify that any alerts generated by high-priorty services should run the notification commands notify-service-by-email and notify-service-by-phone. From reading the documentation (and my knowledge of Nagios) the only way I know to set notification commands is the service_notification_commands option in a contact, but that would mean each contact would need two definitions, one for phone and one for email. How would I get high-priority services to call the notify-service-by-phone command?

More info;

Service Templates

;High priority service (Alert by call, 1 min check period)
define service{
    name                high-priority-service
    notifications_enabled       1
    normal_check_interval       1
    contact_groups                  high
    use             generic-service
    register            0
    }

;Med priority service (Alert by email, 5 min check period)
define service{
    name                med-priority-service
    notifications_enabled       1
    normal_check_interval       5
    contact_groups                  medium
    use             generic-service
    register            0
    }

;Low priority service (No alert, 10 min check period)
define service{
    name                low-priority-service
    normal_check_interval       10
    use             generic-service
    register            0
    }

(generic-service is the default template from NAGIOS configs with a few tweaks)

Services

define service{
        use                             high-priority-service
        hostgroup_name                  generic-server-nrpe
        service_description             SSH
        check_command                   check_ssh
        }

Contact groups

define contactgroup{
        contactgroup_name       low
        alias                   Low Priority Notifications
        members                 sam,[...]
        }

define contactgroup{
        contactgroup_name       medium
        alias                   Medium Priority Notifications
        members                 sam,[...]
        }

define contactgroup{
        contactgroup_name       high
        alias                   High Priority Notifications
        members                 sam,[...]
        }

Contacts

define contact{
        name                            generic-contact
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f,s
        host_notification_options       d,u,r,f,s
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        register                        0
        }

define contact{
    contact_name    sam
    use             generic-contact
    alias           Sam
    email           sam[...]
    address1        +44[...]
    }
share|improve this question
    
I've post an answer here: serverfault.com/a/480587/59925 –  quanta Feb 20 '13 at 9:11
add comment

1 Answer

It seems that you need to define your contacts twice. One definition to be notified only by email and another definition to be notified by both email and phone.

define contact{
        name                            generic-contact-high
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f,s
        host_notification_options       d,u,r,f,s
        service_notification_commands   notify-service-by-email,notify-service-by-phone
        host_notification_commands      notify-host-by-email
        register                        0
        }

define contact{
        name                            generic-contact-med
        service_notification_period     24x7
        host_notification_period        24x7
        service_notification_options    w,u,c,r,f,s
        host_notification_options       d,u,r,f,s
        service_notification_commands   notify-service-by-email
        host_notification_commands      notify-host-by-email
        register                        0
        }

Your contacts should be defined according to these two types of contacts:

define contact{
    contact_name    sam-high
    use             generic-contact-high
    alias           Sam
    email           sam[...]
    address1        +44[...]
    }

define contact{
    contact_name    sam-med
    use             generic-contact-med
    alias           Sam
    email           sam[...]
    address1        +44[...]
    }
share|improve this answer
    
Is there no other way to do it? Our actual Nagios has about 40 contacts in (yes I could automate it but it's annoying). If not, is it possible to pass the contact group used through to the command? There is a macro but it doesn't work properly (Always returns the first contact-group defined rather than the one associated with the alert) –  sam Dec 7 '11 at 20:33
    
To be honest, I did not try such a macro. So, I am not sure :( –  Khaled Dec 7 '11 at 20:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.