Archive

Archive for July, 2013

Icinga REST API and custom variables

July 9th, 2013 No comments

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
address 1.2.3.4
_roles monitoring
}

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

Categories: Sysadmin Tags: ,