Dynamic TimePeriods - best practice


Need a best practice advise: Is it possible to create time periods dynamically for a check_period attribute?

vars.check_something[“Test”]= { period = “08:00-17:00” }

Would use in service iterating through this dict freshly created TimePeriod that would do Mon-Fri 08:00-17:00.

I Know IC2 is not designed for one off checks, but I have lot of services that need to be checked out only once a daily or in specific timeframe ex. between specific hours. I saw somewhere that recommended way is to trigger check via external script ex. call it via CRON and notify IC2 about the result using passive check result. However I’m trying to keep all of my config in one place (no random cross etc.) and want to avoid creating a static time period for every single check. If can create it dynamically based on variable inside my dict (using apply for -> rules) then it would be great.


You could use generated TimePeriod objects (e.g. from an external script creating the static objects) and based on conditions, you’ll assign them to the check_period attribute then.

object Host "..." {

  vars.check_something["test"] = { period = "8x5" }

apply Service "something" for (n => config in host.vars.check_something) {

  if (config.period != "") {
    check_period = config.period

  vars += config