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

parameter templateids for API method "usermacro.get" uses wrong table name "macros_templates"

    Details

      Description

      (1) [Code of 1.8]
      These error have been fixed in revison 16195 only for 1.9.1
      1.8 branch still contains these errors. See rev 16195 of CUserMacro.php to know how to fix if for 1.8

      (2) [Documentation]
      How it works in 2.0:
      Request ("method":"usermacro.get"):

      { "output":"extend", "templateids":["10124"] }

      Response:
      {
      "jsonrpc":"2.0",
      "result":[{
      "templates":[

      { "templateid":"10124" }

      ],
      "hosts":[

      { "hostid":"10126" }

      ],
      "hostmacroid":"52",
      "hostid":"10126",
      "macro":"{$MACRO6}",
      "value":"foo-host"
      }],
      "id":0
      }

      where:
      10124 - ID of a template
      10126 - ID of a host which linked to the template and the host has a macro {$MACRO6}

      Generated SQL:
      SELECT DISTINCT hm.*,ht.templateid FROM hostmacro hm,hosts_templates ht
      WHERE
      (ht.templateid IN ('10124')) AND hm.hostid=ht.hostid

      I do not see much sense to have such feature (IMO) and definitely its description in documentation is BAD.

      So, consider to:
      a) remove this parameter from API and doc;
      or
      b) Write good description in documentation:
      http://www.zabbix.com/documentation/1.8/api/usermacro/get
      http://www.zabbix.com/documentation/2.0/manual/appendix/api/usermacro/get

      My suggestion is: "Select all host macros from hosts which linked to given templates."

      Current description "Template IDs" it very similar to a "Host IDs" description for a hostids parameter, which can be interpreted as "select macros from templates" but actually its meaning is absolutely different.

      How users can guess what "templateids" means ?
      They have to look to source code? or generated SQL? - is NOT acceptable for users!

        Attachments

          Activity

            People

            • Assignee:
              martins-v Martins Valkovskis
              Reporter:
              zalex_ua Oleksiy Zagorskyi
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: