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

API template.get: Cannot return search results under some circumstances

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Trivial Trivial
    • None
    • None
    • None
    • None

      I am trying to search for templates by name using the Zabbix API, but I am encountering an issue:

      Below query is working:

      curl  -X POST \
        'http://monitor.homes/api_jsonrpc.php' \
        --header 'Accept: */*' \
        --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
        --header 'Content-Type: application/json-rpc' \
        --header 'Authorization: Bearer xxx' \
        --data-raw '{
        "jsonrpc": "2.0",
        "method": "template.get",
        "params": {
          "output": "extend",
          "filter": {
            "name": [
                      "Linux by Zabbix agent",
                      "Docker by Zabbix agent 2",
                      "SMART by Zabbix agent 2",
                      "NVidia Sensors"
                  ]
          }
        },
        "id": 1
      }'
      
      

      Returns a list of templates that match the names provided in the filter, which is good.
      Something like:

      {
        "jsonrpc": "2.0",
        "result": [
          {
            "proxyid": "0",
            "host": "NVidia Sensors",
            ... (truncated for brevity)
      
          },
          {
            "proxyid": "0",
            "host": "Docker by Zabbix agent 2",
            ... (truncated for brevity)
      
          },
          {
            "proxyid": "0",
            "host": "Linux by Zabbix agent",
            ... (truncated for brevity)
      
          },
          {
            "proxyid": "0",
            "host": "SMART by Zabbix agent 2",
            ... (truncated for brevity)
          }
        ],
        "id": 1
      }
      
      
      

      However, when I try to use a single name in the filter, like this:

      curl  -X POST \
        'http://monitor.homes/api_jsonrpc.php' \
        --header 'Accept: */*' \
        --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
        --header 'Content-Type: application/json-rpc' \
        --header 'Authorization: Bearer xxx' \
        --data-raw '{
        "jsonrpc": "2.0",
        "method": "template.get",
        "params": {
          "output": "extend",
          "filter": {
            "name": [
                      "Linux by Zabbix agent"
                  ]
          }
        },
        "id": 1
      }'
      
      

      It returns empty results:

      {
        "jsonrpc": "2.0",
        "result": [],
        "id": 1
      }
      

      I am expect it shows the "Linux by Zabbix agent" template details.

      After a brief investigation, it seems that some template name can return expected data and some cannot:

      • "Linux by Zabbix agent" Returns empty
      • "Docker by Zabbix agent 2" Returns Data
      • "SMART by Zabbix agent 2" Returns empty
      • "NVidia Sensors" Returns empty

      And
      1. If you add the one ("Docker by Zabbix agent 2") can return data in the filter along with those cannot, it will return data.
      2. If you remove the one ("Docker by Zabbix agent 2") that can return data, it will return empty results.

       

       

      I am attaching these 4 templates here:

      {
        "jsonrpc": "2.0",
        "result": [
          {
            "proxyid": "0",
            "host": "NVidia Sensors",
            "status": "3",
            "ipmi_authtype": "-1",
            "ipmi_privilege": "2",
            "ipmi_username": "",
            "ipmi_password": "",
            "maintenanceid": "0",
            "maintenance_status": "0",
            "maintenance_type": "0",
            "maintenance_from": "0",
            "name": "NVidia Sensors",
            "flags": "0",
            "templateid": "10452",
            "description": "## Overview\r\n\r\nThis template integrates NVidia SMI for a single graphics card with Zabbix.\r\n\r\nThe template adds monitoring of:\r\n\r\n* GPU Utilisation\r\n* GPU Power Consumption\r\n* GPU Memory (Used, Free, Total)\r\n* GPU Temperature\r\n* GPU Fan Speed\r\n\r\nThe following agent parameters can be used to add the metrics into Zabbix.\r\n\r\nUserParameter=gpu.temp,nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader,nounits -i 0  \r\nUserParameter=gpu.memtotal,nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits -i 0  \r\nUserParameter=gpu.used,nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits -i 0   \r\nUserParameter=gpu.free,nvidia-smi --query-gpu=memory.free --format=csv,noheader,nounits -i 0   \r\nUserParameter=gpu.fanspeed,nvidia-smi --query-gpu=fan.speed --format=csv,noheader,nounits -i 0   \r\nUserParameter=gpu.utilisation,nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits -i 0   \r\nUserParameter=gpu.power,nvidia-smi --query-gpu=power.draw --format=csv,noheader,nounits -i 0\r\n\r\n## Author\r\n\r\nRichard Kavanagh\r\nUpdated & prettyfied by Tom Stocker, [email protected]",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "custom_interfaces": "0",
            "uuid": "499019c3dfce41dfa20c6052b49e6eea",
            "vendor_name": "",
            "vendor_version": "",
            "proxy_groupid": "0",
            "monitored_by": "0"
          },
          {
            "proxyid": "0",
            "host": "Docker by Zabbix agent 2",
            "status": "3",
            "ipmi_authtype": "-1",
            "ipmi_privilege": "2",
            "ipmi_username": "",
            "ipmi_password": "",
            "maintenanceid": "0",
            "maintenance_status": "0",
            "maintenance_type": "0",
            "maintenance_from": "0",
            "name": "Docker by Zabbix agent 2",
            "flags": "0",
            "templateid": "10449",
            "description": "Get Docker engine metrics from plugin for the New Zabbix Agent (zabbix-agent2).\r\n\r\nYou can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/435429-discussion-thread-for-official-zabbix-template-docker\r\n\r\nGenerated by official Zabbix template tool \"Templator\"",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "custom_interfaces": "0",
            "uuid": "c5fd214cdd0d4b3b8272e73b022ba5c2",
            "vendor_name": "Zabbix",
            "vendor_version": "6.4-0",
            "proxy_groupid": "0",
            "monitored_by": "0"
          },
          {
            "proxyid": "0",
            "host": "Linux by Zabbix agent",
            "status": "3",
            "ipmi_authtype": "-1",
            "ipmi_privilege": "2",
            "ipmi_username": "",
            "ipmi_password": "",
            "maintenanceid": "0",
            "maintenance_status": "0",
            "maintenance_type": "0",
            "maintenance_from": "0",
            "name": "Linux by Zabbix agent",
            "flags": "0",
            "templateid": "10001",
            "description": "Official Linux template. Requires agent of Zabbix 3.0.14, 3.4.5 and 4.0.0 or newer.\r\n\r\nKnown Issues:\r\n\r\n  Description: Network discovery. Zabbix agent as of 4.2 doesn't support items such as net.if.status, net.if.speed.\r\n\r\nYou can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/387225-discussion-thread-for-official-zabbix-template-for-linux\r\n\r\nTemplate tooling version used: 0.38",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "custom_interfaces": "0",
            "uuid": "f8f7908280354f2abeed07dc788c3747",
            "vendor_name": "",
            "vendor_version": "",
            "proxy_groupid": "0",
            "monitored_by": "0"
          },
          {
            "proxyid": "0",
            "host": "SMART by Zabbix agent 2",
            "status": "3",
            "ipmi_authtype": "-1",
            "ipmi_privilege": "2",
            "ipmi_username": "",
            "ipmi_password": "",
            "maintenanceid": "0",
            "maintenance_status": "0",
            "maintenance_type": "0",
            "maintenance_from": "0",
            "name": "SMART by Zabbix agent 2",
            "flags": "0",
            "templateid": "10386",
            "description": "The template for monitoring S.M.A.R.T. attributes of physical disk that works without any external scripts. It collects metrics by Zabbix agent 2 version 5.0 and later with Smartmontools version 7.1 and later. Disk discovery LLD rule finds all HDD, SSD, NVMe disks with S.M.A.R.T. enabled. Attribute discovery LLD rule finds all Vendor Specific Attributes for each disk. If you want to skip some attributes, please set regular expressions with disk names in {$SMART.DISK.NAME.MATCHES} and with attribute IDs in {$SMART.ATTRIBUTE.ID.MATCHES} macros on the host level.\r\n\r\nYou can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/415662-discussion-thread-for-official-zabbix-smart-disk-monitoring\r\n\r\nTemplate tooling version used: 0.38",
            "tls_connect": "1",
            "tls_accept": "1",
            "tls_issuer": "",
            "tls_subject": "",
            "tls_psk_identity": "",
            "tls_psk": "",
            "custom_interfaces": "0",
            "uuid": "7b6c6228b25f4586b42cd1bf37ff8034",
            "vendor_name": "",
            "vendor_version": "",
            "proxy_groupid": "0",
            "monitored_by": "0"
          }
        ],
        "id": 1
      } 

            zabbix.support Zabbix Support Team
            duchenpaul Chen Du
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: