Ad Widget

Collapse

Question about API 4.0 how to relate problems with host

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gduchate
    Junior Member
    • Feb 2020
    • 7

    #1

    Question about API 4.0 how to relate problems with host

    Hello

    I am new to ZABBIX and I am trying to query some problem's data using the API, I managed to get a list of current problems as below, however I need some help on how to find or correlate these problem with the host they are coming from. The output from the problem get is as follow:
    thanks

    Request

    {
    "params": {
    "acknowledged": false
    },
    "id": 935079109,
    "jsonrpc": "2.0",
    "method": "problem.get",
    "auth": "43b05f80b3a71acf48ea4aa54a6bc607"
    }


    response:

    {
    "result": [
    {
    "eventid": "45",
    "source": 0,
    "object": 0,
    "objectid": "16005",
    "clock": 1581597767,
    "ns": 488932734,
    "r_eventid": "0",
    "r_clock": 0,
    "r_ns": 0,
    "correlationid": "0",
    "userid": "0",
    "name": "Free disk space is less than 20% on volume /",
    "acknowledged": 0,
    "severity": 2,
    "suppressed": 0
    },
    {
    "eventid": "46",
    "source": 0,
    "object": 0,
    "objectid": "16007",
    "clock": 1581598442,
    "ns": 539714773,
    "r_eventid": "0",
    "r_clock": 0,
    "r_ns": 0,
    "correlationid": "0",
    "userid": "0",
    "name": "Too many processes on Centos",
    "acknowledged": 0,
    "severity": 2,
    "suppressed": 0
    },
    {
    "eventid": "48",
    "source": 0,
    "object": 0,
    "objectid": "16008",
    "clock": 1581598828,
    "ns": 124473811,
    "r_eventid": "0",
    "r_clock": 0,
    "r_ns": 0,
    "correlationid": "0",
    "userid": "0",
    "name": "Lack of available memory on server Centos",
    "acknowledged": 0,
    "severity": 3,
    "suppressed": 0
    }
    ],
    "id": 935079109,
    "jsonrpc": "2.0"
    }

  • gduchate
    Junior Member
    • Feb 2020
    • 7

    #2
    After further investigation I attempted to query triggers with the objectid returned by the problem. I manage to get a reply but it still does not contain the hostname related to the problem I am looking for. The following is the example:

    request
    {
    "params": {
    "triggerids": [
    "16005"
    ],
    "selectHosts": [
    "hostid",
    "name"
    ]
    },
    "id": 1561655547,
    "jsonrpc": "2.0",
    "method": "trigger.get",
    "auth": "b5dcd8c47dfdf6d26c4ae266dbe3ae1b"
    }

    Reply:

    {
    "result": [
    {
    "triggerid": 16005,
    "description": "Free disk space is less than 90% on volume /",
    "expression": "{18310}\u003c90",
    "comments": "",
    "error": "",
    "flags": 0,
    "lastchange": 1581597767,
    "priority": 2,
    "state": 0,
    "status": 0,
    "templateid": 0,
    "type": 0,
    "url": "",
    "value": 1,
    "recovery_mode": 0,
    "recovery_expression": "",
    "correlation_mode": 0,
    "correlation_tag": "",
    "manual_close": 0
    }
    ],
    "id": 1561655547,
    "jsonrpc": "2.0"
    }


    Comment

    • gduchate
      Junior Member
      • Feb 2020
      • 7

      #3
      Great this is what I was looking for , thanks for pointing me on the right direction, I will try it out.

      Comment

      • gduchate
        Junior Member
        • Feb 2020
        • 7

        #4
        Hello

        I tried the recommended request to get the hosts for a trigger but the response still does not include the host. This is what I tried using Zabbix 4.0

        Request
        Code:
        {
        "params": {
        "triggerids": [
        "16005"
        ],
        "selectHosts": "extend",
        "output": "extend"
        },
        "id": 310502771,
        "jsonrpc": "2.0",
        "method": "trigger.get",
        "auth": "60d7457bcc03cd05690855507e613e51"
        }
        Reply
        Code:
        {
          "result": [
            {
              "triggerid": 16005,
              "description": "Free disk space is less than 90% on volume /",
              "expression": "{18310}\u003c90",
              "comments": "",
              "error": "",
              "flags": 0,
              "lastchange": 1581597767,
              "priority": 2,
              "state": 0,
              "status": 0,
              "templateid": 0,
              "type": 0,
              "url": "",
              "value": 1,
              "recovery_mode": 0,
              "recovery_expression": "",
              "correlation_mode": 0,
              "correlation_tag": "",
              "manual_close": 0
            }
          ],
          "id": 310502771,
          "jsonrpc": "2.0"
        }
        Last edited by gduchate; 14-02-2020, 16:46. Reason: Adding version

        Comment

        Working...