New features in Icinga 2.3

by | Jan 13, 2015

The next major version of Icinga 2 will introduce a bunch of interesting features which should make it even easier to define exceptions for services (as in, all services have a check_interval of 5 minutes except for…). Version 2.3 won’t be available for another couple of weeks but here’s a quick introduction to some of its features:

Conditional Statements

More commonly known as if/else: In 2.3 it’s possible to set attributes based on whether some condition is true. Here’s an example:

object Host "localhost" {
  check_command = "hostalive"
  address = "127.0.0.1"
  vars.http_vhosts["icinga.org"] = {
    http_address = "icinga.org"
    interval = 1m
  }
  vars.http_vhosts["dev.icinga.com"] = {
    http_address = "dev.icinga.com"
  }
}
apply Service "vhost " for (vhost => config in host.vars.http_vhosts) {
  host_name = "localhost"
  check_command = "http"
  if (config.interval) {
    check_interval = config.interval
  } else {
    check_interval = 5m
  }
  assign where host.vars.http_vhosts
}

Debug Console

In order to make testing filter rules for “apply” as well as other expressions easier we have implemented a CLI-based console which can be used to evaluate arbitrary expressions and show their results:

$ icinga2 console
Icinga (version: v2.2.0-282-g9898971)
<1> => config = { http_address = "icinga.org", interval = 1m }
null
<2> => if (config.interval) { check_interval = config.interval } else { check_interval = 5m }
null
<3> => check_interval
60.0

Prototypes

All built-in data types (i.e. strings, numbers, arrays and dictionaries) now have their own methods. Here’s an example how we can use those methods to manipulate dictionaries:

<1> => vhosts = { "icinga.org" = { http_address = "icinga.org" },
"dev.icinga.com" = { http_address = "dev.icinga.com" } }
null
<2> => vhosts.remove("icinga.org")
null
<3> => vhosts
{"dev.icinga.com":{"http_address":"dev.icinga.com"}}
<4> => vhosts.len()
1.0

Using Dictionary#remove we can remove specific dictionary items which is rather useful if those dictionary keys should not be set for some hosts or services.

You May Also Like…

Releasing Icinga 2.13.5

Releasing Icinga 2.13.5

Today we are releasing Icinga 2.13.5. It addresses issues with 2.13.x-only changes such as logging startup messages to...

Subscribe to our Newsletter

A monthly digest of the latest Icinga news, releases, articles and community topics.