How to reactivate notifications via cron

I need a way to make sure notifications are enabled when office time is over. we used shinken monitoring before icinga2 and i was able to setup a cron job to reenable all notifications (the global setting - not for a host or service).

How to do this in icinga2 ? I did not find any api call to make this possible.

Sounds like you should be applying downtime in your notification scripts.

https://icinga.com/docs/icinga2/latest/doc/08-advanced-topics/#downtimes

Regards,

Antony.

But this does not gurantee that another admin level person can deactivate notifications gobally, so this is not really the solution for our problem.

Its the same for checking a service at a specific time:

Answer from collegue: “Please use active checks that are scheduled by cron.”

No: i do not want to allow connections from the host to check to our icinga maste., I just want to execute the check “check_rkhunter” at 11 o’clock on all linux systems.

But this does not gurantee that another admin level person can deactivate
notifications gobally, so this is not really the solution for our problem.

Oh, I thought you were looking for something pre-programmed, that same as cron
jobs are.

In that case maybe the API is what you need:

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

“There are several actions available for Icinga 2 provided by the /v1/actions
URL endpoint… scheduling downtimes from external scripts or cronjobs…”

Its the same for checking a service at a specific time:

Answer from collegue: “Please use active checks that are scheduled by
cron.”

No: i do not want to allow connections from the host to check to our icinga
maste., I just want to execute the check “check_rkhunter” at 11 o’clock on
all linux systems.

I don’t believe Icinga supports the concept of running a specific check at a
specific time. It expects all checks to be run at the intervals you specify
(excluding downtime), but exactly when they run is determinated by an internal
scheduler, which tries to balance out the load of running all the checks
needed.

I think the closest you can get to this would again be via the API:

https://icinga.com/docs/icinga2/latest/doc/12-icinga2-api/#reschedule-check

“Reschedule a check for hosts and services. The check can be forced if
required… next_check Timestamp Optional. The next check will be run
at this time. If omitted, the current time is used.”

Regards,

Antony.

1 Like

Wonderful, In the docs you presented is exactly what i needed.

For thie checking at a specifric time, I just used timeframes when to execute the checks and this workaround is working. But the problem for me with this workaround is that I will get alerts during the timefream. From administration and operations perspective, on point in time is better as many points in a timeframe cause it breaks my workflow if I will have to acknolege alerts via opsgenie from time to time.

Apart from this, some checks did not get executed from time to time, which is quiete suboptimal when in an audit :wink:

Anyway … many thank s for your help. I will try to give someting back to the community.

You can set downtimes via the API as well.

Antony.