Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19090

Using API graph.get issue when specifying HOSTIDS and ITEMIDS

    XMLWordPrintable

    Details

    • Type: Incident report
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: API (A)
    • Labels:
      None
    • Environment:
      Zabbix 5.0.5 LTS (Centos 8)

      Description

      Steps to reproduce:

      1. Pick any HOST; note HOST.ID
      2. Pick some ITEMS from this host; note ITEM.ID
      3. Setup a request to API while specifying specific HOSTIDS and ITEMIDS or
      4. Setup a request to API while specifying only ITEMIDS

      Result:
      Empty

      Expected:
      Graphs specific for the given ITEMIDS

      Workaround applied

      • Fetch all graphs for that HOSTID
      • Filter on graphs that have graphitems referring to ITEMIDS

      Not sure where this goed wrong, but it's definitely in CGraph.php under API services where, if specifying both HOSTIDS and ITEMIDS, may lead to a conflicting query statement:

      // hostids
      ...
      $sqlParts['where']['igi'] = 'i.itemid=gi.itemid';
      ...

      // itemids
      ...
      $sqlParts['where'][] = dbConditionInt('gi.itemid', $options['itemids']);
      ...

      Just a gut feeling from my side - happy to dig deeper, but first wanted to pass here for verification from your end ...

      ----------

      Some debug logging:

      2021-03-02 09:19:37 : # Retrieve associated graphs to this item
      2021-03-02 09:19:37 : % postJSON: https://<mydomain>/zabbix/api_jsonrpc.php
      2021-03-02 09:19:37 : > POST data{"jsonrpc":"2.0","method":"graph.get","params":

      {"itemids":"33154,33157,33160,33154","hostids":"10342","output":"extend"}

      ,"auth":"620fb998c4538ff719d0f7c45d536eda","id":6}
      2021-03-02 09:19:37 : > Received 36 bytes
      2021-03-02 09:19:37 : > Graph data

      { "jsonrpc": 2, "result": [], "id": 6 }

      I've verified the hostids and itemids. If I execute without itemids, the graphitems associated are included in the results ...

        Attachments

          Activity

            People

            Assignee:
            ssimonenko Sergey Simonenko
            Reporter:
            hoppa Mark Oudsen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: