How to create custom message per service?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
vitalyk
Posts: 3
Joined: Mon Aug 31, 2015 3:01 am

How to create custom message per service?

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to create custom message per service?

Post 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.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: How to create custom message per service?

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to create custom message per service?

Post 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.
Former Nagios employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: How to create custom message per service?

Post 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. :)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: How to create custom message per service?

Post by hsmith »

@vitalyk,

Did this answer your question?
Former Nagios Employee.
me.
vitalyk
Posts: 3
Joined: Mon Aug 31, 2015 3:01 am

Re: How to create custom message per service?

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: How to create custom message per service?

Post 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?
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to create custom message per service?

Post 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!
Former Nagios employee
Locked