Notification configuration depending on SLA variable from host or service

I have a problem with one check. The notifications for this check are not sent. And I do not really understand why.

We defined a SLA variable in every and in some check applies.

Example:

object Host "icinga" {
	import "linux"
	address = "1.2.3.4"
  vars+= {
    sla = "24x7"
  	snmp3_raid = "true"
  	check_ipmi = "true"
  	snmp3_apt = "true"
    snmp3_extend = [
      "check_sms_spool_dir",
      "check_sms_logfile"
    ]
  }
}


apply Service "snmp3_extend" for (snmp3_extend in host.vars.snmp3_extend) {
  max_check_attempts = 5
  check_command = "check_snmp3_extend"
  vars += {
    "snmp3_service" = snmp3_extend
  }
  assign where typeof(host.vars.snmp3_extend) == typeof([])
}

In the frontend I can see the check. And the check is going critical if something is wrong. Everything is fine in the GUI. But: There is no alert send.

In the notification applies we also have some SLA definitions:

apply Notification "sms-24x7" to Service {
  import "sms-service-notification"
	period = "24x7"
  user_groups = [ "cert" ]
  assign where ((service.vars.enable_notifications ==  "true") && ((service.vars.sla == "24x7") || ((service.vars.sla == "") && (host.vars.sla == "24x7"))) )
}

But there is no notification for any “snmp3_extend”-Checks.

Someone a hint?

Can you explain that expression in your own words?

Assign notification rule where:

Variable “enable notifications” is true AND where service variable SLA contains 24x7 OR where variable SLA is empty and host variable contains 24x7.

What I want is:

  • Enable-Notifications must be true to have notifications
  • Use the informations from Service SLA and if this variable is empty then use the informations from Host SLA as fallback.

Puh. Ok.

true should be of the boolean type, not a string. Yours will never evaluate in a way that assign where matches.

Hi,

thanks four your note. That´s totally true, boolean is much more better.
And thanks for your help. I think I found now the error.

I allow to quote myself:

apply Service "snmp3_extend" for (snmp3_extend in host.vars.snmp3_extend) {
  max_check_attempts = 5
  check_command = "check_snmp3_extend"
  vars += {
    "snmp3_service" = snmp3_extend
  }
  assign where typeof(host.vars.snmp3_extend) == typeof([])
}

There is no “enable_notifications = true” in the variables. -.-

@dnsmichi but now I have an second problem…

As you can see, the “snmp3_extend” checks can exists multiple times on a host. Configured via an array.

snmp3_extend = [
  "check_sms_spool_dir",
  "check_sms_logfile"
]

What now would be cool to have is, that I can configure the notifications for every of this array value. As example:

check_sms_spool_dir --> should be notified
check_sms_logfile --> should not be notified
third snmp3 extend plugin: should be notified

Do you see any chance to configure that??

I think, a quick and dirty way could be have two “snmp3_extend” checks. “snmp3_extend_notify” and “snmp3_extend_no_notify”. This checks are using the same command but at one “enable notifications” is true and at the second one it is false.

Do you have a better idea?