values of custom fields through APIs

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

values of custom fields through APIs

Post 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!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: values of custom fields through APIs

Post 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)?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
User avatar
jssingh
Posts: 110
Joined: Mon Apr 29, 2013 4:55 pm

Re: values of custom fields through APIs

Post 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.
Attachments
custom_output.txt
(12.02 KiB) Downloaded 359 times
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: values of custom fields through APIs

Post 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.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
estanley
Posts: 19
Joined: Thu Apr 08, 2010 9:28 am

Re: values of custom fields through APIs

Post 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
Locked