Timeperiod

Hello
I have a connection time check to mssql
with warn 0.5 crit 1 values
and during working hours these parameters are maintained
But at night, the procedure of backup is carried out and messages begin to roll.
how you can adjust the time periods, so that at certain hours on the same test there were different values of warn and crit

Altering thresholds based on time of day is not possible “as is” you can write a wrapper to connect to the API and modify the service values.

You can trigger that modification via a cron job.

thank
and you can give examples?

I think I gave you bad advice in the post I just deleted.

Yeah, I would say the easiest way to do this is define your check_period value on two different checks, or code it with variables (not the period, per se, but custom) to pass to your check as arguments. I’ve got a few things where I used Python’s datetime module to say only bug the on-call person in Slack for example.

I’d recommend you look at the API , specifically at modifying objects

https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#modifying-objects

once you have the query build for altering you can create a cron job to change to the higher threshold before the backup window
1 23 * * * /path/to/script/raise_threshold.sh
and a cron to return
1 2 * * * /path/to/script/restore_threshold.sh

The query itself depends on your own service definition.

$)COtherwise, a roundabout
way is to have 2 different checks with different time periods, where they
just don!/t notify at all outside of their range.

I just thought
about this topic.

but did not find
where to tie time periods to services.

maybe it sounds
silly))

So in your notification object, you would do something like this (example from my pagerduty config):

  if (service.vars.notification_period) {
    period = service.vars.notification_period
  } else {
    period = "24x7"
  }

Then in your service object, define vars.notification_period = the time period object of your choice.

check_period is also something you can throw under the other check variables you see on your service object, so you could just tell them to only do that during their schedule. If you’re graphing though, I’d say leave the all day one checking and not notifying.

Thank you very much
a little confused, but then figured out

Can you please share your solution for others looking in the same question? Thanks.

Cheers,
Michael

as it was supposed to do 2 periods of time and 2 tests with different crit values