Page 1 of 1

API host record incomplete

Posted: Tue Jan 16, 2018 1:09 pm
by markmerchant
Desc:
The host record returned from the API is incomplete. There are several required
fields missing. Most notably, contacts, check_period, etc. How do I discover those
using the API?

Thx.

Keywords:
nagios xi api get host object

Code: Select all

curl --insecure -XGET "http://<naghost>/nagiosxi/api/v1/objects/host?apikey=<longkey>&host_name=hostxxx&pretty=1"

{
    "hostlist": {
        "recordcount": "1",
        "host": {
            "@attributes": {
                "id": "907"
            },
            "instance_id": "1",
            "host_name": "hostxxx",
            "is_active": "1",
            "config_type": "1",
            "alias": "City, ST",
            "display_name": "hostxxx",
            "address": "hostxxx.xxx.com",
            "check_interval": "5",
            "retry_interval": "1",
            "max_check_attempts": "3",
            "first_notification_delay": "0",
            "notification_interval": "0",
            "passive_checks_enabled": "1",
            "active_checks_enabled": "1",
            "notifications_enabled": "1",
            "notes": "",
            "notes_url": "",
            "action_url": "",
            "icon_image": "",
            "icon_image_alt": "",
            "statusmap_image": ""
        }
    }
}

Re: API host record incomplete

Posted: Tue Jan 16, 2018 2:50 pm
by npolovenko
Hello, @markmerchant. Some of the fields are not yet available. Many API features are getting added to the XI in version 5.5. Also, have you tried JSON CGIs?

Code: Select all

Navigate to this link:
http://<naghost>/nagios/jsonquery.html
Then you'd select in CGI -> Object JSON CGI
Query -> host
Select the hostname

Re: API host record incomplete

Posted: Wed Jan 17, 2018 2:24 pm
by markmerchant

Code: Select all

http://<naghost>/nagios/jsonquery.html
looks much more promising, I may be able to use that. Thx.

Re: API host record incomplete

Posted: Wed Jan 17, 2018 2:39 pm
by npolovenko
@markmerchant, You're welcome.