enable / disable an alert on a schedule?

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: enable / disable an alert on a schedule?

Post by eloyd »

Well, you'll have to mix and match whatever your solution is until Log Server has some sort of alert time settings. Good luck!

You could also have NLS use the "Execute Script" alert mechanism and have it determine whether or not to send something via NRDP. If that's what you're after, that would be pretty trivial.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: enable / disable an alert on a schedule?

Post by rkennedy »

eloyd wrote:Well, you'll have to mix and match whatever your solution is until Log Server has some sort of alert time settings. Good luck!

You could also have NLS use the "Execute Script" alert mechanism and have it determine whether or not to send something via NRDP. If that's what you're after, that would be pretty trivial.
It wouldn't be too difficult. Have it execute a script, check the current time, and forward on to execute another script as needed if the time is within x defined time period.
Former Nagios Employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: enable / disable an alert on a schedule?

Post by eloyd »

The following is likely not to work, as it's just off the top of my head. Create a file called something memorable (such as /usr/local/bin/notify.sh):

Code: Select all

#!/bin/sh
# We're passing in parameters as: %count% %status% "%output%"
count="$1"
status="$2"
output="$3"

# These need to change:
nagiosXI="http://nagios.server.com/nrdp/"
token="MyNRDPtoken"
host="hostname"
service="servicename"

do_alert() {
  /usr/local/nrdp/clients/send_nrdp.php --url=http://${nagiosXI} --token=${token} --host="${host}" --service="${service}" --state="${status}" --output="${output}"
}

# Need to convert text to Nagios result codes
case "$status" in
  ok) status=0;;
  warning) status=1;;
  critical) status=2;;
  *) status=3;;
esac

# Figure out if it's a weekend or not
dayOfWeek=`date +%a`
case "$dayOfWeek" in
  Mon|Tue|Wed|Thu|Fri) do_alert;;
  Sat|Sun) exit;;
esac
Now go create an alert that uses "Execute Script" as the type "/path/to/notify.sh" from above. Set the arguments to be:

Code: Select all

%count% %status% "%output%"
And poof, you're done.
Last edited by eloyd on Tue Jun 28, 2016 1:08 pm, edited 1 time in total.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: enable / disable an alert on a schedule?

Post by rkennedy »

*poof*

@Jklre - let us know if you have any further questions.
Former Nagios Employee
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: enable / disable an alert on a schedule?

Post by eloyd »

I forgot to say "easy peasy lemon squeezy." :)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Jklre
Posts: 163
Joined: Wed May 28, 2014 1:56 pm

Re: enable / disable an alert on a schedule?

Post by Jklre »

eloyd wrote:I forgot to say "easy peasy lemon squeezy." :)

This would definitely be a creative solution I will look into. Right now I have the re-occurring downtime set and hopefully that will prevent this alert from firing and me being woken up on the weekends :-) Ill let you guys know how it goes. thanks again.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: enable / disable an alert on a schedule?

Post by rkennedy »

Sounds good - we'll let @eloyd say "easy peasy lemon squeezy." after it works! :)

Leaving this open for now, let us know how the testing goes!
Former Nagios Employee
Locked