Page 1 of 1

Multiple Thresholds for Different Time Periods

Posted: Wed Jan 15, 2020 1:26 am
by louissiong
Hi Nagios,

At present, there is a requirement for us to create a service in Nagios Xi with different thresholds
over varied timeframes. The objective is to find out the 'Active Connections' of our transport system
which tend to fluctuate widely over time. Eg. we need to set critical threshold as 700 from 0000 to 0100
from Mon to Fri and 1200 from 0500 onward. The threshold values will change on an hourly basis whether
weekdays or weekends. Should it exceed the threshold, Nagios will trigger alerts.
On exploring the functions in CCM Services and Time Periods, we realize there are no options and features
that allow us to perform such tasks.

Please give us your valuable advice. Thanks a lot.



Regards,
Louis

Re: Multiple Thresholds for Different Time Periods

Posted: Wed Jan 15, 2020 9:42 am
by scottwilkerson
Unfortunately, the only way to accomplish this is to create 2 separate services for the same check, setting the timeperiod and thresholds for each to match the requirements.

Re: Multiple Thresholds for Different Time Periods

Posted: Fri Jan 17, 2020 3:27 am
by louissiong
Oh I see. Is there a better method as I am afraid we are likely to create many more services ?
Can we just add a time option in the argument option ? Thanks

Re: Multiple Thresholds for Different Time Periods

Posted: Fri Jan 17, 2020 7:22 am
by scottwilkerson
louissiong wrote:Oh I see. Is there a better method as I am afraid we are likely to create many more services ?
Can we just add a time option in the argument option ? Thanks
If you created a custom wrapper plugin you could have the wrapper plugin determine the current time and run the real plugin with the threshold values you want, that would be a possibility you could custom create.

Re: Multiple Thresholds for Different Time Periods

Posted: Wed Jan 22, 2020 3:38 am
by louissiong
Thanks. Will you be able to shed some light on how we can proceed with this wrapper plugin ?
Any document that we can reference from or sample scripts ?

Re: Multiple Thresholds for Different Time Periods

Posted: Wed Jan 22, 2020 7:42 am
by scottwilkerson
I can't write it for you, but the logic would looks something like this

Code: Select all

if time is from 0000 to 0100 AND day of week is Mon to Fri 
  critical=700
elif time is from 0500 to 2359 AND day of week is Mon to Fri 
  critical=1200
else
  critical=normal value

/path/to/plugin -c $critical
Here' s a doc showing how to add the plugin to XI and add a command that you can assign
https://assets.nagios.com/downloads/nag ... ios-XI.pdf