[ZBX-5540] User macros do not expand in formula field for calculated items Created: 2012 Sep 05 Updated: 2017 May 30 Resolved: 2012 Sep 07 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 2.0.3rc1, 2.1.0 |
Fix Version/s: | 2.0.0 |
Type: | Incident report | Priority: | Major |
Reporter: | Alexey Pustovalov | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | calculateditems, macros | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Issue Links: |
|
Description |
The user macros are not expanded in calculated items. For example:
This item goes unsupported and the error message tells me clearly that the macro is ignored: |
Comments |
Comment by Alexey Pustovalov [ 2012 Sep 05 ] |
3225:20120905:191711.150 In get_value_calculated() key:'test2' expression:'last("{$HOST_MACRO1}:proc.num[snmpd]")+last("{$HOST_MACRO2}:proc.num[snmpd]")' 3225:20120905:191711.151 In substitute_simple_macros() data:'{1} + {2}'3225:20120905:191711.151 Mvar:'{1}' 3225:20120905:191711.152 Mvar:'{2} ' + {2}' |
Comment by Alexey Pustovalov [ 2012 Sep 05 ] |
I prepared the patch for solve the problem: + if (FAIL == (ret = substitute_simple_macros(NULL, NULL, &dc_item->host, NULL, NULL, for (e = dc_item->params; '\0' != *e; e++) zabbix_log(LOG_LEVEL_DEBUG, "%s() expression:'%s'", __function_name, exp->exp);
return ret; } I do not know why value of user defined macro should be numeric. |
Comment by Alexei Vladishev [ 2012 Sep 07 ] |
Discussed with Sasha, there is nothing to fix. Actually it works as designed, support of macros in item references, function name, etc may introduce ambiguity. It should be documented clearly. |
Comment by Karim GUEDIDER [ 2012 Sep 07 ] |
Hi, thanks |
Comment by Martins Valkovskis [ 2012 Sep 07 ] |
Rules for expanding user macros in a calculated item formula are documented in a note at: http://www.zabbix.com/documentation/2.0/manual/config/items/itemtypes/calculated#configurable_fields |
Comment by hamid sfandiari [ 2012 Sep 09 ] |
How can I use User macro as HOSTNAME or Key_ name in calculated items formulla? |
Comment by Alexei Vladishev [ 2012 Sep 10 ] |
Now everything works according to documentation. I am closing it. |
Comment by Filipe Paternot [ 2014 Jun 13 ] |
I think this would be a great feature. Actually i think this should be supported by design. I say that because you might want to do something consistent like this: (VALID) - create a few items using some usermacro This template would not work (unless you set it manually). You would not have the references since the macros are not expanded. I cant imagine a valid scenario that this would harm in some way. |