[ZBX-8720] Macros in graph names are resolved incorrectly if one of the graphs contains words similar to macros Created: 2014 Sep 05  Updated: 2017 May 30  Resolved: 2014 Nov 05

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Frontend (F)
Affects Version/s: 2.2.6, 2.3.5
Fix Version/s: 2.5.0

Type: Incident report Priority: Critical
Reporter: Pavels Jelisejevs (Inactive) Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: graphs, macros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File graph-macros.png    

 Description   

It seems that when a host has a graph with a functional macro in it's name and another graph with a string that looks like a macro, the macros are resolved incorrectly.

For example, I have a graph with one item, and two graphs with names "test2

{SOMETHING}" and "test {host:asdf.last(0)}". When I open the monitoring section, the macros are resolved incorrectly. See screenshot. However, if I remove "{SOMETHING}

" from the name, everything works correctly.



 Comments   
Comment by Pavels Jelisejevs (Inactive) [ 2014 Sep 05 ]

Might be related to ZBX-8722.

Comment by Krists Krigers (Inactive) [ 2014 Oct 03 ]

Fixed in r49581, branch svn://svn.zabbix.com/branches/dev/ZBX-8720 (copy of trunk).

Comment by Krists Krigers (Inactive) [ 2014 Oct 03 ]

(1) No translation string changes.

iivs CLOSED.

Comment by Ivo Kurzemnieks [ 2014 Oct 20 ]

(2) code in CMacrosResolver.php: 683-685 never executed, due to setting of empty array on line 640. So we can use simple non-associative array and remove the check afterwards. Also let's add "array" for function parameters.

kristsk As discussed RESOLVED in r50039.

iivs I made minor changes in r50054. Please, review.

kristsk Looks good. CLOSED.

Comment by Ivo Kurzemnieks [ 2014 Oct 21 ]

TESTED,
but close (2) before merging.

Comment by Krists Krigers (Inactive) [ 2014 Oct 21 ]

Fixed and merged to 2.5.0 (trunk) in r50056.

Comment by Alexander Vladishev [ 2014 Oct 25 ]

(3) The fix caused SQL errors

pg_query(): Query failed: ERROR:  syntax error at or near ")"
LINE 1: ...luemapid FROM items i,hosts h WHERE i.hostid=h.hostid AND ()
                                                                      ^ [charts.php:80 → CPageFilter->__construct() → CPageFilter->_initGraphs() → CFrontendApiWrapper->get() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CGraph->get() → CMacrosResolverHelper::resolveGraphNameByIds() → CMacrosResolver->resolve() → CMacrosResolver->resolveGraph() → CMacrosResolver->resolveGraphsFunctionalItemMacros() → DBselect() → pg_query() in include/db.inc.php:395]
Error in query [SELECT h.host,i.key_,i.itemid,i.value_type,i.units,i.valuemapid FROM items i,hosts h WHERE i.hostid=h.hostid AND ()] [ERROR:  syntax error at or near ")"
LINE 1: ...luemapid FROM items i,hosts h WHERE i.hostid=h.hostid AND ()
                                                                      ^]
pg_query(): Query failed: ERROR:  current transaction is aborted, commands ignored until end of transaction block [charts.php:80 → CPageFilter->__construct() → CPageFilter->_initGraphs() → CFrontendApiWrapper->get() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → call_user_func_array() → CGraph->get() → CMacrosResolverHelper::resolveGraphNameByIds() → CMacrosResolver->resolve() → CMacrosResolver->resolveGraph() → CMacrosResolver->resolveGraphsFunctionalItemMacros() → CItem->get() → DBselect() → pg_query() in include/db.inc.php:395]
Error in query [SELECT   i.itemid FROM items i WHERE i.flags IN (0,4) AND 1=0] [ERROR:  current transaction is aborted, commands ignored until end of transaction block]

Graph name which causes the error:

graph {{HOST.HOST}

kristsk RESOLVED in r50221, new branch svn://svn.zabbix.com/branches/dev/ZBX-8720 (copy of trunk).

sasha REOPENED

Such SQL query shan't be if we have no graph with a complex macro like {host:item.func()}

 SELECT i.hostid,gi.graphid,h.host FROM graphs_items gi,items i,hosts h WHERE gi.itemid=i.itemid AND i.hostid=h.hostid AND gi.graphid='548' ORDER BY gi.sortorder

It not a regression. Will be fixed later. Still RESOLVED.

sasha Method History()->getLast() shouldn't be called for functions min(), max() and avg()

REOPENED

kristsk RESOLVED in r50397.

sasha made a code more readable; minor code improvements. RESOLVED in r50447

kristsk CLOSED.

Comment by Alexander Vladishev [ 2014 Nov 03 ]

(4) Please review my minor fix in r50354

kristsk CLOSED.

Comment by Alexander Vladishev [ 2014 Nov 05 ]

Successfully tested. Please close (3) before a merge.

Comment by Krists Krigers (Inactive) [ 2014 Nov 05 ]

Fixed and merged to 2.5.0 (trunk) in r50453.

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