Page 1 of 1

Customize Email Alerts

Posted: Thu May 26, 2011 11:25 am
by SeanFromIT
I changed notify-service-by-email command and applied configuration but I'm not noticing the change in the alert emails. Is there somewhere else you need to make a change in XI to change the email alert template? We also use a custom macro specified via Free variable definitions in Misc tab of a service. Do I need to change xi_service_notification_handler somehow to reflect this?

Re: Customize Email Alerts

Posted: Thu May 26, 2011 1:49 pm
by agriffin
What did you change about the notify-service-by-email command? Did you read the notes concerning custom variables:
  • Custom variable names must begin with an underscore (_) to prevent name collision with standard variables
  • Custom variable names are case-insensitive
  • Custom variables are inherited from object templates like normal variables
  • Scripts can reference custom variable values with macros and environment variables

Re: Customize Email Alerts

Posted: Thu May 31, 2012 9:59 am
by SeanFromIT
Did you change something about how you handle these between R1.9 and R2.4? I restored xi_service_notification_handler after the upgrade but custom variables still aren't coming through on emails.

Re: Customize Email Alerts

Posted: Thu May 31, 2012 10:33 am
by scottwilkerson
Can you post the command you have for xi_service_notification_handler as well as what custom variables you are trying to use.

Thanks

Re: Customize Email Alerts

Posted: Thu May 31, 2012 10:36 am
by SeanFromIT
command: notify-service-by-email

/usr/bin/printf "%b" "***** Nagios Monitor XI Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nCONTACT: $_SERVICECONTACTINFO$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$ ($HOSTALIAS$)\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$

command: xi_service_notification_handler

/usr/bin/php /usr/local/nagiosxi/scripts/handle_nagioscore_notification.php --notification-type=service --contact="$CONTACTNAME$" --contactemail="$CONTACTEMAIL$" --type=$NOTIFICATIONTYPE$ --escalated="$NOTIFICATIONISESCALATED$" --author="$NOTIFICATIONAUTHOR$" --comments="$NOTIFICATIONCOMMENT$" --host="$HOSTNAME$" --hostaddress="$HOSTADDRESS$" --hostalias="$HOSTALIAS$" --service="$SERVICEDESC$" --hoststate=$HOSTSTATE$ --hoststateid=$HOSTSTATEID$ --servicestate=$SERVICESTATE$ --servicestateid=$SERVICESTATEID$ --lastservicestate=$LASTSERVICESTATE$ --lastservicestateid=$LASTSERVICESTATEID$ --servicestatetype=$SERVICESTATETYPE$ --currentattempt=$SERVICEATTEMPT$ --maxattempts=$MAXSERVICEATTEMPTS$ --serviceeventid=$SERVICEEVENTID$ --serviceproblemid=$SERVICEPROBLEMID$ --serviceoutput="$SERVICEOUTPUT$" --longserviceoutput="$LONGSERVICEOUTPUT$" --datetime="$LONGDATETIME$" --servicecontactinfo="$_SERVICECONTACTINFO$"

Service Alert Subject:
%type% Service Alert - %host%/%service% is %servicestate%

Service Alert Message:
***** Nagios XI Alert *****

Notification Type: %type%

CONTACT: %servicecontactinfo%

Service: %service%
Host: %host% (%hostalias%)
Address: %hostaddress%
State: %servicestate%
Info:
%serviceoutput%
Date/Time: %datetime%

Nagios URL: %xiserverurl%

Re: Customize Email Alerts

Posted: Thu May 31, 2012 10:44 am
by scottwilkerson
Just to clarify, in the free variables in your service is the variable named _CONTACTINFO ?

Re: Customize Email Alerts

Posted: Thu May 31, 2012 10:46 am
by SeanFromIT
Yep

Update: Nevermind. It's working. _CONTACTINFO wasn't defined for the service check they were complaining about.