Home > Sysadmin > Icinga REST API and custom variables

Icinga REST API and custom variables

I’m currently working for a customer who wants review its Nagios configuration. Our goal is to create a script to schedule a downtime for all servers which have a custom variable. So, the first step is to find the list of this server! After digging into the REST’S API source code, here the snippet:

curl -g 'http://monitoring.example.com/icinga-web/web/api/host/filter[AND(HOST_CUSTOMVARIABLE_NAME|=|ROLES;AND(HOST_CUSTOMVARIABLE_VALUE|=|monitoring))]/columns[HOST_NAME|HOST_CURRENT_STATE])/authkey=XXXXXX/xml'

For the following hosts definition:

define host {
use generic-host
name monitoring
host_name monitoring.example.com
_roles monitoring

As you can notice, custom variables must be used in uppercase in the REST request, without the leading _.

Categories: Sysadmin Tags: ,
  1. No comments yet.
  1. No trackbacks yet.