[ZBX-7420] Unable to select inventory from api Created: 2013 Nov 21  Updated: 2017 May 30  Resolved: 2014 Apr 15

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A)
Affects Version/s: 2.2.0
Fix Version/s: None

Type: Incident report Priority: Minor
Reporter: Mike Assignee: Unassigned
Resolution: Fixed Votes: 5
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 5x


Issue Links:
Duplicate
is duplicated by ZBX-7439 API host.get doesn't return any inven... Closed

 Description   

When using the zabbix API the inventory is no longer being returned only the hostid is available.

e.g

[inventory] = > stdClass Object
(
[hostid] => xxxxx
)

nothing else is returned in the inventory



 Comments   
Comment by richlv [ 2013 Nov 21 ]

apparently, you are using some library to access the zabbix api. please show exact json sent and received.
also, in which version that same json worked the way you expect it to ?

Comment by Mike [ 2013 Nov 22 ]

hey,
yes using the zabbix php api class.

i've just used curl to get the same information and its displaying as above.

grabbing the auth
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"user.authenticate","params":

{"user":"Admin","password":"admin"}

,"auth":null,"id":0}' http://localhost/zabbix/api_jsonrpc.php

grabbing the data
curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":"extend","selectInventory":"true","filter":{"host":"servername"}},"auth":"AUTHKEYPASTEDINHERE","id":1}' http://localhost/zabbix/api_jsonrpc.php

Response
{"jsonrpc":"2.0","result":[{"templates":[

{"templateid":"0","hostid":"0"}

],"maintenances":[],"hostid":"10109","proxy_hostid":"0","host":"servername","status":"0","disable_until":"0","error":"","available":"1","errors_from":"0","lastaccess":"0","ipmi_authtype":"-1","ipmi_privilege":"2","ipmi_username":"","ipmi_password":"","ipmi_disable_until":"0","ipmi_available":"0","snmp_disable_until":"0","snmp_available":"0","maintenanceid":"0","maintenance_status":"0","maintenance_type":"0","maintenance_from":"0","ipmi_errors_from":"0","snmp_errors_from":"0","ipmi_error":"","snmp_error":"","jmx_disable_until":"0","jmx_available":"0","jmx_errors_from":"0","jmx_error":"","name":"servername","flags":"0","inventory":{"hostid":"10109"}}],"id":1}

Thanks

Comment by Remo Stäuble [ 2013 Nov 25 ]

I have exactly the same problem in 2.1.0 Alpha and 2.2.0. It only returns hostid in the inventory field.

Comment by Mike [ 2013 Nov 25 ]

hey, thanks for updating. good to know its not just me.

i can confirm this was working in 2.06/2.09

i'm still running with 2.20 its much better performance wise but would like the get the inventory details back if possible.

Comment by Remo Stäuble [ 2013 Nov 25 ]

@richlv: Do you need any more information from our site to solve this issue in 2.2.1?

Comment by richlv [ 2013 Nov 25 ]

i don't think selectInventory should be a literal string "true"... try setting it to '1'

Comment by Mike [ 2013 Nov 26 ]

i just tried with '1' and double checked the documentation

"selectInventory boolean/array Return the host inventory from the host in the inventory property.
Possible values are true to return all of the data, or an array of property names to return only specific properties"

thanks

Comment by Remo Stäuble [ 2013 Nov 26 ]

Same problem with 1 instead of true. Thanks for fixing this

Comment by John Musbach [ 2014 Jan 09 ]

We see this same problem in 2.0.8 but it looks like this has yet to be resolved in any version? Or is there a version we can upgrade to that resolves this issue? Thanks.

Comment by Gary Giesen [ 2014 Feb 19 ]

I can confirm this is an issue as well in latest 2.2.2. Would love to see this fixed.

Comment by Gary Giesen [ 2014 Feb 19 ]

Mike,

A workaround I found is the following:

curl -i -X POST -H 'Content-type:application/json' -d '{"jsonrpc":"2.0","method":"host.get","params":{"output":"extend","selectInventory":"extend","filter":{"host":"servername"}},"auth":"AUTHKEYPASTEDINHERE","id":1}' http://localhost/zabbix/api_jsonrpc.php

ie. use extend rather than true or 1 for selectInventory. Also works in PhpZabbixAPI:

'selectInventory' => 'extend'

While you won't be able to filter the out (I don't think) at least you will get everything you need.

Comment by Pavels Jelisejevs (Inactive) [ 2014 Apr 15 ]

The behavior of selectInventory has been changed in ZBXNEXT-1491, but hasn't been documented. It now behaves like all other subselects, that is, accepts either "extend" or an array of properties.

I've updated the API docs:
https://www.zabbix.com/documentation/2.2/manual/api/reference/host/get
https://www.zabbix.com/documentation/2.4/manual/api/reference/host/get
https://www.zabbix.com/documentation/2.4/manual/api/reference/hostprototype/get?&#parameters

CLOSED.

Generated at Tue Mar 18 09:44:13 EET 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.