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.
Jklre
Posts: 163
Joined: Wed May 28, 2014 1:56 pm

enable / disable an alert on a schedule?

Post by Jklre »

So I'm wondering if there is a way to enable / disable an alert with a cron job?

I have an inverse alert that will send an email if there is no ftp traffic between us and our vendors. The problem is its normal for there to be 0 traffic on Saturday and Sunday. I know there is currently no ability to set a schedule for any of these alerts and I cant use any time stamps in the messages because this is an inverse alert and its looking for the lack of messages.

So i was thinking of scheduling 2 cron jobs to run once a week. One on Late friday (to disable the alert) and the other one to run late sunday (to enable the alert)

now to figure out how to do it.
Could i just curl to the following URL's? but i know there is an authentication peace I would need to do also.

http://servername/nagioslogserver/alert ... 2tlDGI51B8

http://servername/nagioslogserver/alert ... zpOD3uM55s


Thanks in advance.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: enable / disable an alert on a schedule?

Post by hsmith »

Let me reach out to the development team and find out if there is an easy way to do this. I don't believe there is, but I want to be sure. I can think of some horribly tacky methods, but let's not go there yet..
Former Nagios Employee.
me.
Jklre
Posts: 163
Joined: Wed May 28, 2014 1:56 pm

Re: enable / disable an alert on a schedule?

Post by Jklre »

hsmith wrote:Let me reach out to the development team and find out if there is an easy way to do this. I don't believe there is, but I want to be sure. I can think of some horribly tacky methods, but let's not go there yet..
I like tacky. If nothing else works. :-)
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: enable / disable an alert on a schedule?

Post by scottwilkerson »

If you are using Nagios XI as well, you could send the notification to the XI server and use a custom notification timeperiod that is just a Monday-Friday, this would then not send messages on the weekends.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Jklre
Posts: 163
Joined: Wed May 28, 2014 1:56 pm

Re: enable / disable an alert on a schedule?

Post by Jklre »

scottwilkerson wrote:If you are using Nagios XI as well, you could send the notification to the XI server and use a custom notification timeperiod that is just a Monday-Friday, this would then not send messages on the weekends.

Like send it via NRDP and create a dummy service for this to alert off of?
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: enable / disable an alert on a schedule?

Post by hsmith »

I believe that is what he was getting at, yeah. I never even thought about that, even though it requires another product. My horrible tacky idea was some madness with cron and iptables/firewalld to block emails from being sent..
Former Nagios Employee.
me.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: enable / disable an alert on a schedule?

Post by ssax »

Correct, setup the NRDP server in Log Server under Alerting > Nagios Servers (NRDP) then create an alert and select Nagios (send using NRDP) and it will allow you to specify the hostname/servicename. If you don't set it up in XI it will come into Admin > Unconfigured Objects and you can set it up from there.
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 »

Am I missing something here? can't you just use a timeperiod on the service definition to not have it check over the weekend? Or on the notification to not have it notify over the weekend? Or couldn't you write to the local nagios.cmd with a DISABLE_SVC_CHECK command (and subsequent ENABLE_SVC_CHECK) when you need it back on? https://old.nagios.org/developerinfo/ex ... mmand_id=6. You can do that last one via NRDP as well with a curl request.

None of these are tacky, and it would take about 3 minutes to write the scripts and cron entries to do the nagios.cmd stuff.
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:Am I missing something here? can't you just use a timeperiod on the service definition to not have it check over the weekend? Or on the notification to not have it notify over the weekend? Or couldn't you write to the local nagios.cmd with a DISABLE_SVC_CHECK command (and subsequent ENABLE_SVC_CHECK) when you need it back on? https://old.nagios.org/developerinfo/ex ... mmand_id=6. You can do that last one via NRDP as well with a curl request.

None of these are tacky, and it would take about 3 minutes to write the scripts and cron entries to do the nagios.cmd stuff.
The above would work with Nagios, but I believe this thread is referring to NLS.
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 »

Hahahah. Yes, of course, you are correct. :-)

So, my solution would be to send the alerts to an email address that used procmail, and have procmail drop the message into /dev/null if it's on a weekend. Otherwise, it would deliver normally (possibly forwarding to the real destination).

You can do that locally on the NLS box.
Last edited by eloyd on Tue Jun 21, 2016 12:56 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!
Locked