Website and certificate monitoring with Icinga

Hi.

(Hint: Click on the small arrows to display the details)

To put checks with similar arguments into an array within the host-definition of the host which executes the check, you could do something similar like

this
vars.http_statuscode_targets = [
  "https://www.microlinux.fr",
  "https://blog.microlinux.fr",
// ... your other great vhosts
  ]

The corresponding service could look like this (these are just dummy settings)

corresponding check
apply Service "HTTP Statuscode" for (http_target in host.vars.http_statuscode_targets) {
  import "generic-service"

  check_command = "check_http_statuscode" // i am just an example 
  check_interval = 2m

  name = http_target + "_statuscode_check"

  vars.http_statuscode_target = http_target // CHANGEME to the required ones

  assign where host.vars.http_statuscode_targets
}

If you want to use different arguments, you could put each check into
a dictionary which all the required settings

Using a dictionary
  vars.http_vhosts["https://www.microlinux.fr"] = {
     http_vhost = "https://www.microlinux.fr"
     http_address = "https://www.microlinux.fr"
     http_uri   = "/"
     http_ssl = true
     http_certificate = 30

  }

The corresponding check could look like this:

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

  check_command = "http"
  check_interval = 1d
  name = http_vhost + "_cert_check"
  display_name = http_vhost + " cert check"

  enable_perfdata = false

  vars += config
}

Hope this helps.

Greetings

2 Likes