How to disable local ssh check for icinga when run in docker container

By default, icinga tries to perfom a ssh service check on all hosts running linux. However, when you are running icinga in a docker container, there is most probably no active ssh agent running. In order to prevent icinga always showing an error, insert

  ignore where (host.address == "127.0.0.1") || (host.address == "localhost")

into the ssh service section in /etc/icinga2/conf.d/services.conf.

The result should look like this:

/*
 * Apply the ssh service to all hosts
 * with the address attribute defined and
 * the custom attribute os set to Linux.
 */
apply Service “ssh” {
  import “generic-service”
  check_command = “ssh”
  assign where (host.address || host.address6) && host.vars.os == “Linux”   ignore where (host.address == “127.0.0.1”) || (host.address == “localhost”) }

It is also possible to query a specific variable:

/*
 * Apply the `ssh` service to all hosts
 * with the `address` attribute defined and
 * the custom attribute `os` set to `Linux`.
 */
apply Service "ssh" {
  import "generic-service"
  check_command = "ssh"
  assign where (host.address || host.address6) && host.vars.os == "Linux"   ignore where (host.address == "127.0.0.1") || (host.vars.ssh == "false") }

So setting vars.ssh = “false” in any host disables the ssh check for a particular host.