[ZBX-9729] macro {HOST.IP5} should not expand in item keys Created: 2015 Jul 27  Updated: 2017 May 30  Resolved: 2015 Sep 11

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Proxy (P), Server (S)
Affects Version/s: 2.4.5
Fix Version/s: 3.0.0alpha3

Type: Incident report Priority: Minor
Reporter: Aleksandrs Saveljevs Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: macros
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-10798 HOST.IP1 macro stopped working afer u... Closed
is duplicated by ZBX-10376 Numbered macros {MACRO<1-9>} not pass... Closed

 Description   

Suppose we use the following item key: echo[{HOST.IP5}]. The {HOST.IP5} macro will expand to the host's IP, same as {HOST.IP}. However, it should not, because {HOST.IP5} is meant to refer to the IP address of the host of the 5th item in a trigger expression.



 Comments   
Comment by Glebs Ivanovskis (Inactive) [ 2015 Aug 20 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-9729 revision 55075.

Comment by Andris Zeila [ 2015 Aug 26 ]

(1) While the m == bl comparison is correct it's somewhat confusing. It would be better to add a new variable with appropriate naming (for example indexed_macro), so that the comparison is obvious.

Also in some comparisons this check is done first, in others - last. We should keep the same order in all comparisons. Having it done at the beginning seems logical.

glebs.ivanovskis Applied proposed changes in r55175. RESOLVED

wiper Please check my changes in r55206.
CLOSED

Comment by Andris Zeila [ 2015 Aug 28 ]

Successfully tested

Comment by Glebs Ivanovskis (Inactive) [ 2015 Aug 28 ]

Fixed in pre-3.0.0alpha2 (trunk) r55215.

Comment by Andrey Melnikov [ 2015 Oct 07 ]

Ok, you completely break working configurations.
I can't see anywhere in docs about "n-th items in trigger expression". For this type there is {ITEM.VALUEx} macros.
Which macros I should use for ping secondary IP address from host config?

Comment by Aleksandrs Saveljevs [ 2015 Oct 08 ]

Could you please elaborate a bit more on how this breaks a working configuration? {HOST.IP2} always expanded to the same value as {HOST.IP}.

Comment by Andrey Melnikov [ 2015 Oct 08 ]

rev 55215 breaks expansion for "indexed" macro in keys. Completely.

 15897:20151007:220001.720 In substitute_key_macros() data:'icmppingsec[{HOST.IP1},5,,1472]'
 15897:20151007:220001.720 In substitute_simple_macros() data:'{HOST.IP1}'
 15897:20151007:220001.720 In substitute_simple_macros() nothing matched: idxmacro=1, type=00000040, m={HOST.IP}
 15897:20151007:220001.720 End substitute_simple_macros() data:'{HOST.IP1}'
 15897:20151007:220001.720 End of substitute_key_macros():SUCCEED data:'icmppingsec[{HOST.IP1},5,,1472]'
 15897:20151007:220001.720 In add_icmpping_item() addr:'{HOST.IP1}' count:5 interval:0 size:1472 timeout:0
 15897:20151007:220001.720 End of add_icmpping_item()

reverted patch:

 17017:20151007:223501.730 In substitute_key_macros() data:'icmppingsec[{HOST.IP1},5,,1472]'
 17017:20151007:223501.730 In substitute_simple_macros() data:'{HOST.IP1}'
 17017:20151007:223501.730 End substitute_simple_macros() data:'127.0.0.1'
 17017:20151007:223501.730 End of substitute_key_macros():SUCCEED data:'icmppingsec[127.0.0.1,5,,1472]'
 17017:20151007:223501.730 In add_icmpping_item() addr:'127.0.0.1' count:5 interval:0 size:1472 timeout:0
 17017:20151007:223501.730 End of add_icmpping_item()

Find two differences.

Comment by Aleksandrs Saveljevs [ 2015 Oct 08 ]

Ah, thank you! Anyway, the ability to use {HOST.IP1} in an item key was a bug. If someone relied on that bug, well, sorry.

Comment by Andrey Melnikov [ 2015 Oct 08 ]

HOST.IP == HOST.IP1 isnt't it?

Comment by Glebs Ivanovskis (Inactive) [ 2015 Oct 08 ]

It was. And {HOST.IP2} was equivalent to {HOST.IP}. And {HOST.IP3}. And {HOST.IP4}... Which was clearly nonsense.

In the context where is only one host it is logical to use simply {HOST.IP}.

Comment by Andrey Melnikov [ 2015 Oct 08 ]

Maybe it should expand to empty string if there no second/third/four/.... IP in host config? This is more logically then always expand to first IP.

Comment by Glebs Ivanovskis (Inactive) [ 2015 Oct 08 ]

Documentation says:

Note that the numbered macro syntax of {MACRO<1-9>} is used to reference hosts in the order in which they appear in a trigger expression. Thus, macros like {HOST.IP1}, {HOST.IP2}, {HOST.IP3} will expand to the IP of the first, second and third host in the trigger expression, providing the expression contains those hosts.

Multiple IPs in host configuration have nothing to do with indexed macro.

If we don't recognize the sequence of symbols as macro or user parameter or alias it is logical to leave it as it is, not replace it with empty string. Maybe it's simply text.

Comment by Aleksandrs Saveljevs [ 2015 Oct 08 ]

{HOST.IP5} never had the semantics that it would expand to the 5th IP in host config, so in this regard nothing is broken.

Request ZBXNEXT-1154 seems to talk along the lines of being able to refer to alternative interfaces on the host. You might wish to add a comment there.

Comment by Alexander Vladishev [ 2016 Feb 11 ]

Related issue: ZBX-10376

Comment by Slash [ 2017 Mar 07 ]

Hello,

I more or less understand the issue that prompted the change but I would like to discuss it a bit.

I'm monitoring a lot of customer's routers (~300) that have 2 internet connections, on zabbix 2.4, I used {HOST.IP1} and {HOST.IP2} to ping them, raise average alert when 1 interface was down and raise high alert when both interface were down.

How can I do that now?

Comment by Andrey Melnikov [ 2017 Mar 07 ]

Use user macros, create multiple icmpping[{$HOST.IP_X}] items. Or use LLD if your routers support SNMP (walk over IP-MIB::ipAdEntAddr).

Comment by Slash [ 2017 Mar 07 ]

lynxchaus: I ended up doing exactly this after talking about it on irc with Gleb, thank you for your time.

Generated at Sat Apr 27 00:28:16 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.