How to use ignore where in service apply rule created in Icinga Director

Written by - 0 comments

Published on - Listed in Monitoring Icinga

Icinga users working on the command line (like me) are used to create apply rules with "assign where" and "ignore where" conditions.

But if you use the graphical Icinga configuration tool (Icinga Director), this works a bit differently.

A typical apply rule with assign and ignore conditions

A simple example of an apply rule using both assign and ignore conditions:

apply Service "NTP" {
  import "generic-service"
  check_command = "nrpe"
  vars.nrpe_command = "check_ntp"
  vars.nrpe_arguments = [ "", "30", "60" ]

  assign where host.address && host.vars.os == "Linux"
  ignore where host.vars.applyignore.ntp == true

This NTP service check (executed via the NRPE command in this example) is applied to all the hosts:

  • Having an IP address (host.address) defined AND
  • running on Linux as Operating System (defined in the custom variable host.vars.os)

The NTP service check will however not be rolled out (ignored) on hosts which:

  • have the custom variable host.vars.applyignore.ntp set to true

Icinga Director shows no ignore fields

If you want to create the same apply rule from above in Icinga Director, you will notice there is a "Assign where" section, but no "Ignore where" section.

Does this mean the ignore condition cannot be defined? Kind of yes, but there's another way to set this.

Note: The ignore where condition is reserved by the Director for blacklisted hosts, using the DirectorOverrideTemplate.

Apply rule with reversed condition (NOT)

The solution is to append the assign where condition to add a reversed condition, which can be added with the NOT operator.

To translate the NTP example from above, this means: Create a service check NTP and assign to hosts which:

  • have an IP address (host.address) defined AND
  • run on Linux as Operating System (host.vars.os) AND
  • don't have the custom variable host.vars.applyignore.ntp defined

In the graphical UI the apply rule will look like this:

The tricky part is how to get the AND/NOT conditions aligned, using the plus-icon and the fast-forward-icon. But after some playing around with these, you should be able to find out how to do it.

Hint: First append the AND condition with another field (plus-icon next to AND operator), then click on the fast-forward-icon next to the added empty field.

This results in the following apply rule, which can be seen in the "Preview" tab in the Director UI:

apply Service "NTP" {
    import "svc_ntp_generic"
    assign where host.address && host.vars.os == "Linux" && !(host.vars.applyignore.ntp)
    import DirectorOverrideTemplate

Note: The imported service "svc_ntp_generic" obviously defines the service check, including command, etc.

Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder