Page 1 of 1
How to create custom message per service?
Posted: Mon Oct 19, 2015 5:45 am
by vitalyk
Hi,
I was asked to define a custom email notification for certain services. (Like "there is no new users for XX minutes")
I looked for a was to associate a notification with a service, without success.
The only way I found for customize notification it's associate custom notification with a contact group, this method seems me very ugly.
TIA,
Vitaly
Re: How to create custom message per service?
Posted: Mon Oct 19, 2015 10:00 am
by tmcdonald
Notification commands are assigned to contacts, and contacts are assigned to hosts and services, so you are correct that this is the way to do it.
One other way to do it is to use event handlers instead of notifications, but that is even uglier and requires more work.
Re: How to create custom message per service?
Posted: Mon Oct 19, 2015 10:14 am
by eloyd
To expand a bit, why do you want to know that there are no new users for XX minutes? Is this a problem or a good thing? You could send things to Nagios Log Server and have NLS parse logs for events and then create queries that look for these sorts of strings (like new users being created). Then you could alert based on whether there are too many or too few users being created in a given timeframe.
It's a lot easier, I think.
On the other hand, I write event handlers to do all sorts of fun things and you can get pretty crazy with the cheeze whiz this way. But it's very flexible and you can basically use event handlers to usurp Nagios's notifications if you want and write your own this way.
Re: How to create custom message per service?
Posted: Mon Oct 19, 2015 10:20 am
by tmcdonald
To expand further, this could also be done on a per-plugin basis if you know how to modify plugins, then you would just change the status output to be whatever you wanted and it would just work. Probably less painful than the event handler route, but it would require more coding knowledge.
Re: How to create custom message per service?
Posted: Mon Oct 19, 2015 10:28 am
by eloyd
To expand
even more you would write a wrapper plugin that simply calls the real plugin with all the right parameters passed to it, then uses a massive sed script to change all the outputs to something else.

Re: How to create custom message per service?
Posted: Mon Oct 19, 2015 4:33 pm
by hsmith
@vitalyk,
Did this answer your question?
Re: How to create custom message per service?
Posted: Tue Oct 20, 2015 8:09 am
by vitalyk
Dear All - thank you for your answers, they answer my question.
(To say the truth, Nagios way to associate notifications with contacts seems me really weird. IMHO, it should be associated with events/services).
But yes, from practical point of view, I have a way to do what I need.
Re: How to create custom message per service?
Posted: Tue Oct 20, 2015 8:59 am
by eloyd
Basically, Nagios expects that you are defining contacts (people) that want to be notified about a service. That person then can be notified in different ways, based on how and when they want to be notified (pager, email, SMS, Asterisk, pushbullet, etc).
Does that help?
Re: How to create custom message per service?
Posted: Tue Oct 20, 2015 4:27 pm
by tmcdonald
It can be weird at times, but it makes sense once you get used to it. This way you don't have to configure a different custom email template for every single service. We like reusability!