Page 1 of 1

NagiosXI API - GET objects/host is_active parameter

Posted: Wed May 22, 2019 8:35 am
by wbaars
I think I have found an issue in the NagiosXI API:

When I try to build a limited query, to filter on "is_active", the only working value is "1".
If I enter an other value, such as "0" or "ne:1" I get 0 records back, and there are inactive hosts.
Also when requesting an existing INACTIVE host, the API returns 0 records.

Is this expected behaviour?

Powershell example

Code: Select all

PS S:\> Invoke-RestMethod "https://our.nagios.server/nagiosxi/api/v1/objects/host?apikey=1232314&is_active=ne:1"

recordcount
-----------
0


PS S:\> Invoke-RestMethod "https://our.nagios.server/nagiosxi/api/v1/objects/host?apikey=1232314&is_active=1"

recordcount host
----------- ----
7424         {@{@attributes=; instance_id=1; host_name=win-hostname-example; is_active=1; config_type=1; al...


Re: NagiosXI API - GET objects/host is_active parameter

Posted: Wed May 22, 2019 2:51 pm
by scottwilkerson
Being is_active is just a binary 0 or 1, you should be able to accomplish either of these with

Code: Select all

https://our.nagios.server/nagiosxi/api/v1/objects/host?apikey=1232314&is_active=1
or

Code: Select all

https://our.nagios.server/nagiosxi/api/v1/objects/host?apikey=1232314&is_active=0

Re: NagiosXI API - GET objects/host is_active parameter

Posted: Wed May 22, 2019 2:55 pm
by scottwilkerson
I'm going to retract that......

The is_active field is always 1 because the API will only ever show active items in objects/host
(quite frankly I don't know why we are returning it)

Re: NagiosXI API - GET objects/host is_active parameter

Posted: Thu May 23, 2019 4:48 am
by wbaars
Thanks for the reply.
Too bad the API only lists active items. It would be nice to also get the inactive items.

I am trying to see if a host already exists in Nagios, and is active or inactive.
If so, when creating a new host via the API it would be nice know if there already is a host with the same name or address (or other field).

Re: NagiosXI API - GET objects/host is_active parameter

Posted: Thu May 23, 2019 4:33 pm
by scottwilkerson
I'll put in a feature request to get it added to the config/host and config/service api

Re: NagiosXI API - GET objects/host is_active parameter

Posted: Fri May 24, 2019 6:27 am
by wbaars
Thanks. I hope this feature will be added in future release of NagiosXI.

Re: NagiosXI API - GET objects/host is_active parameter

Posted: Fri May 24, 2019 6:54 am
by scottwilkerson
wbaars wrote:Thanks. I hope this feature will be added in future release of NagiosXI.
Yep.

Locking thread