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.

When a host goes down we get "** PROBLEM Host Alert: Wright is DOWN" and we get "**Problem Service Alert: Wright/$ is $".

I know this is related to how our notification settings are set, but I cannot figure out how to continue sending service alerts when the host has problems, but not when the host is down.

How do I enable service alerts when the host is up, and disable service alerts when the host is down?

Another possibly useful bit of information is I'm using NConf to manage configuration files.

Sample Host Alert email:

***** Nagios *****

Notification Type: PROBLEM
Host: wright
State: DOWN
Address: wright
Info: CRITICAL - Host Unreachable (wright)

Date/Time: Wed Jul 31 15:00:14 MDT 2013

Sample Service Alert email:

    ***** Nagios *****

Notification Type: PROBLEM

Service: $
Host: wright
Address: wright
State: $

Date/Time: Wed Jul 31 15:00:14 MDT 2013

Additional Info:

$

Wright host definition:

define host {
                host_name                             wright
                alias                                 wright
                address                               wright
                max_check_attempts                    5
                check_interval                        1
                retry_interval                        1
                first_notification_delay              1
                notification_interval                 240
                notification_options                  d,u,r,f,s
                active_checks_enabled                 1
                passive_checks_enabled                1
                notifications_enabled                 1
                icon_image_alt                        windows - Desktop
                icon_image                            base/win40.gif
                statusmap_image                       base/win40.gd2
                check_command                         check-host-alive
                check_period                          24x7
                notification_period                   workhours
                contact_groups                        IT-Dept
}

UPDATE

I've added the requested information below:

define command {
                command_name                          notify-host-by-email
                command_line                          /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

define command {
                command_name                          notify-service-by-email
                command_line                          /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

and my contact group config:

define contactgroup {
                contactgroup_name                     IT-Dept
                alias                                 IT-Dept
                members                               IT Department,Personal - Email
}
share|improve this question
    
Add the host notification command to the question; that's where the problem is. –  Keith Aug 1 '13 at 20:32
    
add the contactgroup definition for 'IT-Dept', all contactgroup members of it, and then as well all the referenced host_notification_commands and service_notification_commands. your output looks like macros used in the wrong place. –  dnsmichi Aug 5 '13 at 16:06
    
The "$ is $" only happens when the node is offline. If the node is online but triggers a service notification it works as expected with the correct values in the emails. –  tbenz9 Aug 9 '13 at 18:45
add comment

1 Answer

You have an error in your host notification command definition. I suspect what has happened is that you have either incorrectly quoted the options, or more likely you have missed the trailing '$' from the variable names -- Nagios variables should be expressed as $VARNAME$ with a trailing $.

EG:

# 'host-notify-by-email' command definition
define command{
        command_name    host-notify-by-email
        command_line    /usr/bin/printf "%b" "Subject: [Nagios] Host $HOSTSTATE$ alert for $HOSTNAME$\nTo: $CONTACTEMAIL$\nFrom: Nagios System <nagios-system@nagios.auckland.ac.nz>\n\nHost: $HOSTALIAS$ $HOSTSTATE$\nNotification Type: $NOTIFICATIONTYPE$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nDate/Time: $SHORTDATETIME$\nAdditional Info: $HOSTOUTPUT$\n" | /usr/sbin/sendmail -f nagios-system@nagios.auckland.ac.nz -F "Nagios System" -t
}
share|improve this answer
    
I've updated the question with the information you requested. When comparing it to your example I don't see anything that stands out. Thanks for your help so far. –  tbenz9 Aug 9 '13 at 18:43
    
Your problems seem to be with $SERVICEDESC$ and $SERVICESTATE$ not getting expanded by Nagios, so being passed to the shell. These are only available in service alerts. Is it possible that you are incorrectly using the 'notify-service-by-email' notification method as a host notification by accident? Check your service-notification-commands and host-notification-commands definitions in your user definitions. –  Steve Shipway Oct 15 '13 at 3:49
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.