Ad Widget

Collapse

Inventory Fields not populating via Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • glidewired
    Junior Member
    • Aug 2022
    • 1

    #1

    Inventory Fields not populating via Zabbix API

    I am unable to populate any fields in the "Inventory" tab via the Zabbix API. The below call will create the host, as well as, the tags, but will not touch the "Inventory" fields. This is an example using the python module pyzabbix, but I have tried the same call with curl and a straight up shell script and I am having no luck. I have tried changing the Lat/Lon numeric values to string values, but that did nothing. No matter what I do I don't see any updates in the GUI or mysql DB. I have also tried using host.update, but I have still had no luck. I can change the inventory_mode all day long, but no updates to the "Inventory" fields. Any help would be greatly appreciated. Thanks in advance.

    Zabbix Server: 6.2
    OS: Suse Linux Enterprise 12
    DB: mysql Ver 8.0.30


    DEBUG pyzabbix.api:Sending: {'jsonrpc': '2.0', 'method': 'host.create', 'params': {'host': '12345', 'status': 1, 'interfaces': [{'type': 1, 'main': '1', 'useip': 1, 'ip': '192.168.1.199', 'dns': 'rtr.router.net', 'port': 10050}], 'groups': [{'groupid': 19}], 'templates': [{'templateid': 10186}], 'inventory': [{'location_lat': '37.248574', 'location_lon': '-94.119297'}], 'inventory_mode': 0, 'tags': [{'tag': 'owner', 'value': 'HEN'}, {'tag': 'postal', 'value': '75201'}]}, 'id': 0, 'auth': '6********************************************e"'}

    DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.106:80

    send: b'POST /zabbix/api_jsonrpc.php HTTP/1.1\r\nHost: 192.168.1.106\r\nUser-Agent: python/pyzabbix\r\nAccept-Encoding: gzip, deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/json-rpc\r\nCache-Control: no-cache\r\nContent-Length: 532\r\n\r\n'

    send: b'{"jsonrpc": "2.0", "method": "host.create", "params": {"host": "12345", "status": 1, "interfaces": [{"type": 1, "main": "1", "useip": 1, "ip": "192.168.1.199", "dns": "rtr.router.net", "port": 10050}], "groups": [{"groupid": 19}], "templates": [{"templateid": 10186}], "inventory": [{"location_lat": "37.248574", "location_lon": "-94.119297"}], "inventory_mode": 0, "tags": [{"tag": "owner", "value": "HEN"}, {"tag": "postal", "value": "75201"}]}, "id": 0, "auth": "6******************************************** e"}'

    reply: 'HTTP/1.1 200 OK\r\n'
    header: Date: Thu, 25 Aug 2022 22:23:17 GMT
    header: Server: Apache
    header: X-Powered-By: PHP/7.4.30
    header: Access-Control-Allow-Origin: *
    header: Access-Control-Allow-Headers: Content-Type
    header: Access-Control-Allow-Methods: POST
    header: Access-Control-Max-Age: 1000
    header: Keep-Alive: timeout=5, max=100
    header: Connection: Keep-Alive
    header: Transfer-Encoding: chunked
    header: Content-Type: application/json
    DEBUG:urllib3.connectionpool:http://192.168.1.106:80 "POST /zabbix/api_jsonrpc.php HTTP/1.1" 200 None
    DEBUG pyzabbix.api:Response Code: 200
    DEBUG pyzabbix.api:Response Body: {'jsonrpc': '2.0', 'result': {'hostids': ['10556']}, 'id': 0}
Working...