We need *your* feedback!

Dear Icinga 2 users!

Independent of the upcoming v2.11 we’d like to extend our config parser unit tests.

We already have some test cases, but IMO not enough fragile ones, i.e. 42 - 23 * 0.5 which is 30.5, but in case of… an accident in the operator precedence it could silently become 9.5.

Do you have some config snippets running in production which are “less boring” than enable_active_checks = false? Please post them as an answer here. They don’t have to be good practice and nobody will criticize you. They just have to conform to either our docs or common sense and to produce a well-defined result.

Thank you in advance!

AK

My http check with automate certifacte check if ssl is used.

apply Service "http " for (http_vhost => config in host.vars.http_vhosts) {
  import "generic-service"

  check_command = "http"

  vars.http_extendedperfdata = true

  vars += config

  assign where host.vars.http_vhosts != ""
}

/**
 * Function to itarete thru dictionary and check if http_ssl is true
 */
globals.check_https_cert = function(host) {
  /* ensure that other hosts without the custom attribute do not match */
  if (typeof(host.vars.http_vhosts) != Dictionary) {
    return false
  }

  /* iterate over the vars_http_hosts dictionary */
  for (key => val in host.vars.http_vhosts) {
    /* if the value is a dictionary and if contains the app_type being the requested type */
    if (typeof(val) == Dictionary && val.http_ssl) {
      return true
    }
  }

  /* nothing matched */
  return false
}

apply Service "Website Certificate" for (http_vhost => config in host.vars.http_vhosts) {
  import "generic-service"

  display_name = "Website Certificate " + http_vhost

  check_command = "ssl_cert"
  enable_perfdata = true

  vars += config

  vars.ssl_cert_address = vars.http_vhost
  vars.ssl_cert_sni = vars.http_vhost
  vars.ssl_cert_warn = 10
  vars.ssl_cert_critical = 5
  assign where check_https_cert(host)
}
2 Likes