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.
enable / disable an alert on a schedule?
Re: enable / disable an alert on a schedule?
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.
me.
Re: enable / disable an alert on a schedule?
I like tacky. If nothing else works.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..
-
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?
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.
Re: enable / disable an alert on a schedule?
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?
Re: enable / disable an alert on a schedule?
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.
me.
Re: enable / disable an alert on a schedule?
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.
Re: enable / disable an alert on a schedule?
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.
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.
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Re: enable / disable an alert on a schedule?
The above would work with Nagios, but I believe this thread is referring to NLS.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.
Former Nagios Employee
Re: enable / disable an alert on a schedule?
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.
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.
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!