Page 3 of 3

Re: enable / disable an alert on a schedule?

Posted: Mon Jun 27, 2016 6:08 pm
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.

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 9:35 am
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.

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 9:52 am
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.

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 1:00 pm
by rkennedy
*poof*

@Jklre - let us know if you have any further questions.

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 1:08 pm
by eloyd
I forgot to say "easy peasy lemon squeezy." :)

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 2:22 pm
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.

Re: enable / disable an alert on a schedule?

Posted: Tue Jun 28, 2016 4:03 pm
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!