[ZBX-5091] parameter templateids for API method "usermacro.get" uses wrong table name "macros_templates" Created: 2012 May 29  Updated: 2017 May 30  Resolved: 2012 May 31

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Documentation (D)
Affects Version/s: 1.8.14rc1
Fix Version/s: 1.8.14rc1

Type: Incident report Priority: Major
Reporter: Oleksii Zagorskyi Assignee: Martins Valkovskis
Resolution: Fixed Votes: 0
Labels: API, macros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate

 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!



 Comments   
Comment by Alexey Fukalov [ 2012 May 30 ]

dev branch: svn://svn.zabbix.com/branches/dev/ZBX-5091

Fixed in 1.8 and improved docs for 'templateids' filter.

Comment by Oleksii Zagorskyi [ 2012 May 30 ]

for dev branch, also, line #217:
-$sql_parts['where']['hht'] = 'hm.hostid=ht.macroid';
+$sql_parts['where']['hht'] = 'hm.hostid=ht.hostid';

no any words about (2) after resolving?
(2) RESOLVED as suggested for 1.8 and 2.0 doc <- would be absolutely enough.

REOPENED

<Vedmak> RESOLVED

<pavels> CLOSED.

Comment by Pavels Jelisejevs (Inactive) [ 2012 May 31 ]

A minor correction in r27969, but otherwise great.

TESTED.

<zalex> also TESTED.

Comment by Oleksii Zagorskyi [ 2012 May 31 ]

Maybe it could be merged also to 2.x branches?
I see there some logical improvements in naming, would be nice have 2.x improved as well.

Comment by Alexey Fukalov [ 2012 May 31 ]

svn://svn.zabbix.com/branches/1.8 27975

There were no changes that is needed in 2.0+, array key rename is not worth it.

Generated at Fri Apr 19 12:58:43 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.