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

template.get filtered over templateid gives empty result

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • None
    • 3.4.4
    • API (A)
    • None

      Knowing templateid I want to know name of the template
      Looks like it is not possible to do such reverse lookup by call template.get with filtering output by templateid.

      $ curl --silent -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"template.get","params":{"output":"extend","filter":{"name":"Template SNMP Device"}},"auth":"0643270e4a00986804d88ad736ad7df4","id":0}' http://localhost/api_jsonrpc.php;echo
      {"jsonrpc":"2.0","result":[{"proxy_hostid":"0","host":"Template SNMP Device","status":"3","disable_until":"0","error":"","available":"0","errors_from":"0","lastaccess":"0","ipmi_authtype":"0","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":"Template SNMP Device","flags":"0","templateid":"10066","description":"","tls_connect":"1","tls_accept":"1","tls_issuer":"","tls_subject":"","tls_psk_identity":"","tls_psk":""}],"id":0}
      
      $ curl --silent -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"template.get","params":{"output":"extend","filter":{"name":"Template SNMP Device"}},"auth":"0643270e4a00986804d88ad736ad7df4","id":0}' http://localhost/api_jsonrpc.php | jq .result[].templateid; echo
      "10066"
      

      So in case of the template "Template SNMP Device" its templateid is 10066

      $ curl --silent -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"template.get","params":{"output":"extend","filter":{"templateid":"10066"}},"auth":"0643270e4a00986804d88ad736ad7df4","id":0}' http://localhost/api_jsonrpc.php;echo
      {"jsonrpc":"2.0","result":[],"id":0}
      

            Unassigned Unassigned
            kloczek Tomasz Kłoczko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: