Page 1 of 1

values of custom fields through APIs

Posted: Mon May 12, 2014 6:23 pm
by jssingh
Hi,

I created a custom field in a host definition that I wanted to be able to access through the APIs. However, using the object query for the host it merely tells me that the custom field exists, not the value of it. Am I not doing the query correctly? Or is this something that can be added?

Here is (part of) the host definition:

Code: Select all

define host {
    use                             generic-host
    host_name                       pleiades1
    ...
    _domain                         pleiades
}
if I use the query:

Code: Select all

cgi-bin/objectjson.cgi?query=host&hostname=pleiades1
the only reference to the custom field is at the end of this. As you can see it tells me DOMAIN exists, but not the value of it.

Code: Select all

{
  "format_version": 0,
  "result": {
    "query_time": 1399936372000,
    "cgi": "objectjson.cgi",
    "query": "host",
    "query_status": "beta",
    "program_start": 1399935899000,
    "last_data_update": 1399935899000,
    "type_code": 0,
    "type_text": "Success",
    "message": ""
  },
  "data": {
    "host": {
      "name": "pleiades1",
      "name": "pleiades1",
      ...
      "custom_variables": [
        "DOMAIN"
      ]
    }
  }
}
I removed a lot of the output because it was so long and you have to scroll to the end to see the custom variables, but if you need to see all of it, let me know.

thanks!

Re: values of custom fields through APIs

Posted: Tue May 13, 2014 12:46 pm
by abrist
I just sent an email to Eric about this. What version of nagios are you running? Could you attach a text file with the full output (scrub the sensitive bits)?

Re: values of custom fields through APIs

Posted: Tue May 13, 2014 3:56 pm
by jssingh
Thanks.

It's version 4.0.4. The whole output from the query is attached. Let me know if you need any more information.

Re: values of custom fields through APIs

Posted: Tue May 13, 2014 4:25 pm
by abrist
Thanks. I have verified that the current cgis do not include the 'value' for custom vars. I will open an internal bug report.

Re: values of custom fields through APIs

Posted: Mon May 26, 2014 11:12 am
by estanley
Janice,

I have just committed and pushed an update to the code so that the values of custom variables are now displayed in the object JSON CGI. The commit id is 4f40874 and it will be in the next release.

Thanks for the reports and for using the API. Let us know if you find anything else.

Eric