notification_interval based on severity

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.
User avatar
retlaw
Posts: 3
Joined: Tue Feb 12, 2013 1:03 pm

notification_interval based on severity

Post by retlaw »

Hi,

New here, so be gentle.

I've setup the check_printer to monitor the status of supplies (toner) on a printer.
I am currently getting the notification sent once a day.

What I would like is to only receive the notifications daily if the severity is critical, and if the severity is warning receive them once a week (if I could have that be Monday, that would be a bonus).

Any ideas on how to accomplish this?

thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: notification_interval based on severity

Post by lmiltchev »

I haven't tested this, but this may be possible by doing the following:

1. Create two different timeperiods, for example:

Code: Select all

define timeperiod {
        timeperiod_name                         printer-critical
        alias                                   24 Hours A Day, 7 Days A Week
        saturday                                00:00-24:00
        friday                                  00:00-24:00
        thursday                                00:00-24:00
        wednesday                               00:00-24:00
        tuesday                                 00:00-24:00
        monday                                  00:00-24:00
        sunday                                  00:00-24:00
        }

define timeperiod {
        timeperiod_name                         printer-warning
        alias                                   printer-warning
        monday                                  00:00-24:00
        }
2. Define two different service checks (I don't know if this can be done with one check only; if anyone knows, please, let me know) that use these timeperiods.

In the first check, you might have these lines:

Code: Select all

...
service_description             Printer Status - warning
notification_period             printer-warning
notification_options            w,
...
In the second one:

Code: Select all

...
service_description             Printer Status - critical
notification_period             printer-critical
notification_options            c,
...
Again, I haven't tested it - please, let me know if it works for you.

BTW, if your check gets a warning state on Tuesday, are you going to be OK with receiving a notification in a week on Monday?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
retlaw
Posts: 3
Joined: Tue Feb 12, 2013 1:03 pm

Re: notification_interval based on severity

Post by retlaw »

I'll see what I can do with your suggestions.. maybe a feature request to have it be all in one service check?

And, YES I would be OK with waiting a week to get notified of a warning.. it's just to monitor toner levels, and we go about 4 months between replacements, and I just want to make sure that I can order it before we run out if someone took the spares without letting me know.

thanks.
User avatar
retlaw
Posts: 3
Joined: Tue Feb 12, 2013 1:03 pm

Re: notification_interval based on severity

Post by retlaw »

OK, I did that and I'll have to see if it works as expected... however, I now have two status entries for the printer supplies in the web interface, which is confusing.. so, I'm guessing my idea of a feature request is the direction I would prefer.. but then, beggars can't be choosers.

I'll report back next week (or sooner) with the results.

again, thanks
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: notification_interval based on severity

Post by lmiltchev »

Thanks for the feedback! I will try to come up with a "one-check" solution even though, at the moment, I don't see how this can be done.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: notification_interval based on severity

Post by gshergill »

Hi lmiltchev,

Could you not use a service escalation?

So the standard service just uses;

Code: Select all

...
notification_period             printer-warning #Where this is set to weekly
notification_options            w, c
...
And the escalation uses;

Code: Select all

...
first_notification	1
last_notification	0
notification_interval	1440
escalation_options            c
...
Might be a few things I'm overlooking though...
-> By setting first_notification to 1, it only happens with the first escalation_options notification?
-> It would probably send out a double notification for critical, unless you can set first_notification to 0?

Anyways, just thought I'd throw this out there, hopefully it's useful =)

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: notification_interval based on severity

Post by abrist »

gshergill wrote: Might be a few things I'm overlooking though...
-> By setting first_notification to 1, it only happens with the first escalation_options notification?
-> It would probably send out a double notification for critical, unless you can set first_notification to 0?
By setting first notification to 1 you will essentially escalate on the first alert. It will only send out a double critical if the contact is a contact on the host/service and the escalation.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: notification_interval based on severity

Post by gshergill »

Hi abrist,
By setting first notification to 1 you will essentially escalate on the first alert.
The first Alert of any kind? Or the first alert the escalation is for? i.e. setting the service to WARNING,CRITICAL and the escalation to just CRITICAL, would it only do the escalation on the first CRITICAL alert?

If so, this might be an option for notification_interval based on severity.

Kind Regards,

Gary Shergill
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: notification_interval based on severity

Post by abrist »

gshergill wrote: The first Alert of any kind? Or the first alert the escalation is for? i.e. setting the service to WARNING,CRITICAL and the escalation to just CRITICAL, would it only do the escalation on the first CRITICAL alert?
It will be the first alert that the escalation is set for. So the first time the box goes critical the escalation will fire off.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
gshergill
Posts: 231
Joined: Tue Aug 07, 2012 5:08 am

Re: notification_interval based on severity

Post by gshergill »

Hi abrist,

Code: Select all

It will be the first alert that the escalation is set for. So the first time the box goes critical the escalation will fire off.
That's great, I'd recommend giving this a go then retlaw, it could solve your question, unless lmiltchev found a better solution?

Kind Regards,

Gary Shergill
Locked