[ZBX-5280] Host macro inside map label trigger expression macro Created: 2012 Jul 05  Updated: 2017 May 30  Resolved: 2012 Oct 15

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Frontend (F)
Affects Version/s: 2.0.0
Fix Version/s: 2.0.4rc1, 2.1.0

Type: Incident report Priority: Major
Reporter: Alexey Fukalov Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: macros, maps
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBX-2924 resolve inconsistencies in macro expa... Closed

 Description   
  • trigger elements should support {HOST.HOST1-9}

    macros inside item value referencing macros

  • host elements should support {HOST.HOST} macros inside item value referencing macros

    In case of macro like "{{HOST.HOST}

    :log[

    {HOST.HOST}.log].last(0)}" only first {HOST.HOST}

    macro should be resolved.



 Comments   
Comment by Alexei Vladishev [ 2012 Sep 18 ]

All macros must be resolved just by one pass. If a macro value contains another macro, the value should stay as it is. There are some exceptions, for example, if

{TRIGGER.NAME} value has some macros, the macros must be expanded before processing of {TRIGGER.NAME}

.

<Toms> Looks like

{TRIGGER.NAME}

should be only expanded in notifications and commands according to documentation.

Comment by Toms (Inactive) [ 2012 Sep 20 ]

(1) There is problem in trigger name macros

{HOST.NAME1}

resolving in Monitoring->Triggers, if trigger expression has same function more than once.

<Toms> CLOSED. Created https://support.zabbix.com/browse/ZBX-5608.

Comment by Toms (Inactive) [ 2012 Sep 20 ]

(2) When resolving

{HOST.DNS}

(as well others) macros in Maps for host item, default selection is not taken into account.

<Toms> RESOLVED in r30319

Vedmak CLOSED

Comment by Toms (Inactive) [ 2012 Sep 24 ]

Fixed in dev. branch: svn://svn.zabbix.com/branches/dev/ZBX-4187 r30317

Comment by Toms (Inactive) [ 2012 Sep 24 ]

(3) There was a problem with HOST.DNS priorities when only JMX and IPMI interfaces are used in host

<Toms> RESOLVED in r30323

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 26 ]

(4)

  • open a map with trigger element
  • change trigger for that element
  • save map.

Image reload failed.

tomtom RESOLVED in r30409

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(5)
Not sure if

{HOST.HOST1}

macro should be supported for hosts.

tomtom RESOLVED in r30410

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(6)
Maybe not directly related to this issue.
Why newly created item without values show 0 for macro like {{HOST.HOST}:log[

{HOST.HOST}

.log].last(0)} ?

tomtom RESOLVED in r30413

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(7)
comment

// get host host if element is host

doesn't seem correct

tomtom RESOLVED in r30413

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(8)
Why array_key_exists instead of isset there?

// allowed item types for min, max and avg function
			$history_table = array(
				ITEM_VALUE_TYPE_FLOAT => 'history',
				ITEM_VALUE_TYPE_UINT64 => 'history_uint'
			);
			if (!array_key_exists($item['value_type'], $history_table)) {

tomtom RESOLVED in r30413

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(9)

$macro = preg_replace('/{({HOSTNAME'.$i.'}|{HOST.HOST'.$i.'}):(.*)}/Uu', '{'.$host['host'].':$2}', $macro);

regexp 'u' modifier seems not needed here.

tomtom RESOLVED in r30413

Vedmak CLOSED

Comment by Alexey Fukalov [ 2012 Sep 27 ]

(10)

$res = DBselect('SELECT hi.ip,hi.dns,hi.useip,h.host,h.name,f.functionid,hi.type AS interfacetype' .
					' FROM interface hi,items i,functions f,hosts h'.
					' WHERE h.hostid=hi.hostid'.
						' AND hi.hostid=i.hostid'.
						' AND i.itemid=f.itemid'.
						' AND hi.main=1 AND f.triggerid='.$selement['elementid']);

			// process interface priorities, build $hostsByFunctionId array
			$tmpFunctionId = -1;
			while ($dbHost = DBfetch($res)) {
				if ($dbHost['functionid'] != $tmpFunctionId) {
					$tmpPriority = 0;
					$tmpFunctionId = $dbHost['functionid'];
				}
				if  ($priorities[$dbHost['interfacetype']] > $tmpPriority) {
					$hostsByFunctionId[$dbHost['functionid']] = $dbHost;
					$tmpPriority = $priorities[$dbHost['interfacetype']];
				}
			}

I think this code can return incorrect results in case we have trigger with 2 hosts and many interfaces. Select can return functions mixed in order from different hosts.

tomtom RESOLVED in r30418.

Vedmak CLOSED

Comment by Toms (Inactive) [ 2012 Oct 04 ]

Fixed in 2.0.4rc1 r30616, 2.1.0 r30617

Comment by Alexey Fukalov [ 2012 Oct 11 ]

(11)
If map has trigger element, error is shown.
Undefined index elementExpressionTrigger

Vedmak cannot reproduce, probably some bug with my setup. CLSOED

Generated at Thu Mar 28 17:16:25 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.