[ZBX-8517] User macro not expanded in calculated items prototypes Created: 2014 Jul 24  Updated: 2017 Oct 24  Resolved: 2017 Oct 24

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Documentation (D), Server (S)
Affects Version/s: 2.2.4
Fix Version/s: None

Type: Incident report Priority: Minor
Reporter: Gabriele Paggi Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: calculateditems, macros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

RHEL 5 and RHEL 6



 Description   

Hello,

I have an LLD rule that discovers Oracle tablespaces and sets up two items prototypes (tablespace size and tablespace usage). This is working OK.
I need to compute the usage percentage, so I created a new item prototype with type "computed".
This is the formula I'm using:

100*last("oracle.tbs_free[\"{$MONUSER}\",\"{$MONPASS}\",\"{#ORASID}\",\"{#TBS}\"]",0)/last("oracle.tbs_size[\"{$MONUSER}\",\"{$MONPASS}\",\"{$ORASID}\",\"{#TBS}\"]",0)

I see that {#ORASID} and {#TBS} correctly get replaced with their values but {$MONUSER} and {$MONPASS} don't, so the item doesn't get populated (generates "cannot evaluate function last error.

According to the documentation they should be replaced:
https://www.zabbix.com/documentation/2.4/manual/config/items/itemtypes/calculated
"User macros in the formula will be expanded if used to reference a parameter or a constant.
User macros will NOT be expanded if used to reference a function, host name, item key or operator."

I'm not sure if this is a duplicate of this other, now closed, issue: ZBX-5540.

Thanks!

Gabriele Paggi



 Comments   
Comment by Marc [ 2014 Jul 24 ]

Could it be ZBX-2866?

Comment by Gabriele Paggi [ 2014 Jul 24 ]

That issue seems to be about aggregating arguments but, ralphhu's last comment added on 2013 Apr 18 16:10, shows the same issue I'm facing.

Comment by Marc [ 2014 Jul 24 ]

I meant the root cause that the issue (and it's duplicates) share not the scenario of the issue itself.

Comment by Gabriele Paggi [ 2014 Jul 24 ]

I had a look at ZBX-2866 and its duplicates and I'm not sure I understand what is the root cause, a bug perhaps?. Can you please explain?
Thanks.

Comment by Martins Valkovskis [ 2014 Jul 24 ]

If I understand this right, the user macros are not resolved because they're part of the quoted item key. If so then it is as per documentation:

"User macros will NOT be expanded if used to reference a function, host name, item key..."

Comment by Marc [ 2014 Jul 24 ]

gpaggi, i believe i had misunderstood your issue.
How does the result of the lld look like?

shouldn't:
last("oracle.tbs_size[\"{$MONUSER}\",\"{$MONPASS}\",\"{$ORASID}\",\"{#TBS}\"]",0)

rather be (ORASID):
last("oracle.tbs_size[\"{$MONUSER}\",\"{$MONPASS}\",\"{#ORASID}\",\"{#TBS}\"]",0)

User macros should not be resolved at this point. They'll be resolved on host level on usage.
At least as long there is no way to optionally avoid their resolving - what ZBX-2866 is about

Comment by Gabriele Paggi [ 2014 Jul 24 ]

Marc sorry, that's a typo I did: it's {#ORASID} in both keys.
I run a test by replacing {$MONUSER} and {$MONPASS} with their content in the key's definition, like:

last("oracle.tbs_size[\"db_mon\",\"xxxx\",\"{$ORASID}\",\"{#TBS}\"]",0)

On host level I see the same error "cannot evaluate function last..." I got before. Even if the key is now correct it seems its value doesn't get replaced and fed into last.

As a workaround I now have my script on the host to return also the percentage of used tablespace but it would be nice to understand how to have that computed in a calculated item prototype.

Comment by Marc [ 2014 Jul 25 ]

Since it's not clear whether you encounter a bug, I suggest to ask for community support in forums or IRC:
http://www.zabbix.com/community.php

or commercial support:
http://www.zabbix.com/services.php

Comment by Aleksandrs Saveljevs [ 2015 Jan 20 ]

Could not reproduce with Zabbix 2.2.4: a calculated item, created from a prototype, which references another created item with user macro, works well.

Gabriele, if the issue is still relevant for you, could you please attach screenshots of all item prototype configuration and the "cannot evaluate function last ..." error that you are getting?

Comment by Rostislav Palivoda [ 2017 Oct 24 ]

Please reopen if required.

Generated at Fri Mar 29 17:22:34 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.