Page 1 of 2
How to customize Notification Messages of contacts
Posted: Thu Jun 21, 2012 1:35 pm
by Jdawg2002
Hi,
I know how users can modify their own notification messages in their 'my account' --> 'notification messages' section. However, I have several different contacts set up; these are email/pager addresses without corresponding users who login to Nagios, but their email account/phones receive notifications. I need to modify/customize the notification messages that are sent. How do I do this for each contact?
Thanks,
Jason
Re: How to customize Notification Messages of contacts
Posted: Thu Jun 21, 2012 3:11 pm
by lmiltchev
What exactly do you want to change?
Contacts cannot modify/customize the notification messages. Small changes are possible if you create a "custom" notification handler for each contact. I don't recommend this, because you can easily mess up your notifications if you don't know what you are doing.
However, a simple example would be to go to:
Core Config Manager->Commands->Commands->type "notify" in the "Search" bar.
You will see the two commands that are used to notify contacts. Use the "Copy" action button to copy one of them, for example, "notify-host-by-email", rename the new command to let's say "notify-host-by-email-contact1", modify it, save, and apply configuration. For instance, you can add "-- -f
[email protected]". This way, the proper e-mail will be shown in the "From" field.
Do the same for the "notify-service-by-email".
Next, go to: Core Config Manager->Alerting->Contacts-><your-contact>->Modify and define:
Host Command = the newly created "notify-host-by-email-contact1" command
Service Command = the newly created "notify-service-by-email-contact1" command
Save and Apply Configuration.
Even though, this may work (for small changes), I would not recommended. You are better off creating users, instead of contacts and using the default notification even handlers. It gives you a lot more options and flexibility. Please, read our documentation on contacts and users here:
http://assets.nagios.com/downloads/nagi ... ntacts.pdf
Hope this helps.
Re: How to customize Notification Messages of contacts
Posted: Thu Jun 21, 2012 6:27 pm
by Jdawg2002
Thanks,
There are few reasons for us to modify notification messages. The default message is fine for notifications sent to user's email. However, for notifications sent to mobile devices as text messages, the notification is too long, and comes in as 2 or even 3 separate text messages to our user's phones. So, with Nagios Core, we modified the notification to remove the IP and combine some of the lines and remove the breaks - this shortens the message.
Also, we have some users who will get 'escalated' alert notifications (when noone acknowledges/fixes/suppresses) the first 10 or so notifications. Then, it is 'escalated' to a manager. This escalated user does not have a login to Nagios(nor do they want a login) and is simply a contact. Sometimes, this escalated user's role might need different information contained in the notification alert.
Re: How to customize Notification Messages of contacts
Posted: Fri Jun 22, 2012 8:51 am
by lmiltchev
This makes sense. I would suggest then to creating a custom notification commands for your contacts, tweaking them according to their needs, testing them to make sure they will work fine, and then replacing the "notify-host-by-email" and "notify-service-by-email" commands with the custom ones under "Contact Management".
Re: How to customize Notification Messages of contacts
Posted: Wed Dec 03, 2014 2:13 pm
by mberkley
lmiltchev wrote:What exactly do you want to change?
Contacts cannot modify/customize the notification messages. Small changes are possible if you create a "custom" notification handler for each contact. I don't recommend this, because you can easily mess up your notifications if you don't know what you are doing.
Core Config Manager->Commands->Commands->type "notify" in the "Search" bar.
You will see the two commands that are used to notify contacts. Use the "Copy" action button to copy one of them, for example, "notify-host-by-email", rename the new command to let's say "notify-host-by-email-contact1", modify it, save, and apply configuration. For instance, you can add "-- -f
[email protected]". This way, the proper e-mail will be shown in the "From" field.
Save and Apply Configuration.
Hope this helps.
We are having the same issue. Where do we add the "-- -f
[email protected]" in the command. Do we append it to the end of the command, or top of the command? Help..
Re: How to customize Notification Messages of contacts
Posted: Wed Dec 03, 2014 3:10 pm
by lmiltchev
You would normally append "-- -f
[email protected]" to the end of the commands, but this is only for sendmail... If you are using mailx, I believe you need to use "-r". What is the output of the following command?
Re: How to customize Notification Messages of contacts
Posted: Wed Dec 03, 2014 3:34 pm
by mberkley
lmiltchev wrote:You would normally append "-- -f
[email protected]" to the end of the commands, but this is only for sendmail... If you are using mailx, I believe you need to use "-r". What is the output of the following command?
It outputs:
/etc/alternatives/mta -> /usr/sbin/sendmail.postfix
Re: How to customize Notification Messages of contacts
Posted: Wed Dec 03, 2014 5:28 pm
by abrist
Ah, postfix. We still need to see what you are currently using to send mail in the notify-*-by-email commands. What is the output of:
Code: Select all
grep -2 by-email /usr/local/nagios/etc/commands.cfg
Re: How to customize Notification Messages of contacts
Posted: Wed Dec 03, 2014 6:08 pm
by mberkley
grep -2 by-email /usr/local/nagios/etc/commands.cfg
define command {
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Hyatt NOC Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nNote: To acknowledge this issue please log in to Nagios XI at
http://FOOBAR/nagiosxi/" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ Alert: $HOSTNOTIFICATIONNUMBER$**" $CONTACTEMAIL$
}
--
define command {
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Hyatt NOC Alert *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nNote: To acknowledge this issue please log in to Nagios XI at
http://FOOBAR/nagiosxi/" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ Alert: $SERVICENOTIFICATIONNUMBER$**" $CONTACTEMAIL$
}
Re: How to customize Notification Messages of contacts
Posted: Thu Dec 04, 2014 11:25 am
by lmiltchev
If you haven't configured postfix, you could try following the steps, outlined here:
http://www.postfix.org/BASIC_CONFIGURATION_README.html