[ZBX-6682] Value mapping is not expanded if item is used in map labels and map links Created: 2013 Jun 10  Updated: 2022 Oct 08  Resolved: 2013 Jul 31

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

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

Attachments: PNG File 2.0branch r36336.png     PNG File 2.0branch r36337.png     PNG File 2.0branch r36545.png     PNG File dev branch.png     PNG File latest data.png     PNG File map element.png    
Issue Links:
Duplicate

 Description   

Value mapping returns raw lastvalue, need "human representation" style. it is not work.
Host label:

{Host1:item1.last(0)}

-> 255, but should be No such service(255)



 Comments   
Comment by Oleg Egorov (Inactive) [ 2013 Jun 12 ]

FIXED IN svn://svn.zabbix.com/branches/dev/ZBX-6682 r36328

Comment by Toms (Inactive) [ 2013 Jun 13 ]

(1) applyValueMap() should be rewritten so it wont duplicate code with getMappedValue();

oleg.egorov RESOLVED IN r35335

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jun 13 ]

TESTED

Comment by Oleg Egorov (Inactive) [ 2013 Jun 13 ]

FIXED IN 2.0.7rc1 r36337
CLOSED

Comment by richlv [ 2013 Jun 13 ]

(2) *DRUMROLL*

whatsnew !

martins-v Added to: https://www.zabbix.com/documentation/2.0/manual/introduction/whatsnew207#value_mapping_in_map_labels

oleg.egorov CLOSED

Comment by Andrei Gushchin (Inactive) [ 2013 Jun 24 ]

(3) Item's value as text with space are reason of appearance html tags.
Please see the attached screenshots.

oleg.egorov RESOLVED IN r36540
neogan TESTED. Sorry but It still not works. See new screenshot r36545.
oleg.egorov I can't reproduce...
neogan TESTED in dev branch. It works perfect. I added last screenshot.

tomtom CLOSED

Comment by Toms (Inactive) [ 2013 Jun 27 ]

TESTED

Comment by Oleg Egorov (Inactive) [ 2013 Jun 27 ]

FIXED IN r36557
CLOSED

Comment by Alf Solli [ 2013 Jul 26 ]

I believe this introduced a bug;

How to reproduce:
Add map, with one host. Map Works

Add trigger to this host, that references another different host' items. Like on my host "Puma" :
Name: Security breach : Camera detection
Expression: (

{LGN-SiteSense01:AN2.status.avg(5m)}

=1) & (

{Puma:log[/var/log/messages,alarm state,,,].str(Gone into alarm)}

=1)

This worked just fine with 2.0.6

Quick diff 2.0.7 maps.inc.php -> 2.0.6 :
421c421
< 'output' => array('lastclock', 'value_type', 'lastvalue', 'units', 'valuemapid')

> 'output' => array('lastclock', 'value_type', 'lastvalue', 'units')
438,440d437
< $mapping = false;
< $value = formatItemValueType($item);
<
442,449c439,441
< case ITEM_VALUE_TYPE_STR:
< $mapping = getMappedValue($value, $item['valuemapid']);
< // break; is not missing here
< case ITEM_VALUE_TYPE_TEXT:
< case ITEM_VALUE_TYPE_LOG:
< if ($mapping !== false)

{ < $value = $mapping.' ('.$value.')'; < }


> case ITEM_VALUE_TYPE_FLOAT:
> case ITEM_VALUE_TYPE_UINT64:
> $value = convert_units($item['lastvalue'], $item['units']);
452c444
< $value = applyValueMap($value, $item['valuemapid']);

> $value = $item['lastvalue'];
454,456d445
< }
<
< if (isset($value)) {

Comment by Alf Solli [ 2013 Jul 26 ]

Sorry, forgot.
The error message thrown when I attempt this, is :

Undefined index: 10111 [include/maps.inc.php:1145]
Invalid argument supplied for foreach() [include/maps.inc.php:1145]

"10111" is the hosts.hostid of "LGN-SiteSense01"

Comment by Alf Solli [ 2013 Jul 26 ]

Nevermind the maps.inc.php diff. The change seems to be somewhere in api/classes/CTrigger.php . Just don't know where yet, but I'll keep looking later tonight.

Comment by richlv [ 2013 Jul 27 ]

reopening as per alf's comment

Comment by Alf Solli [ 2013 Jul 29 ]

Seems like the map works fine, as long as ALL hosts in the trigger are present in the map. So for the example, both LGN-SiteSense01
AND Puma has to exist on the map, as type host.

Could this be a biproduct of optimization ? Since I'm viewing the maps as a super-admin, I don't think it's permission related..

Comment by Volker Fröhlich [ 2013 Jul 31 ]

This should have postponed the 2.0.7 release!

2.0.6:

array(33) {
[0]=>
array(8) {
["hosts"]=>
array(1) {
[0]=>
array(1)

{ ["hostid"]=> string(5) "10156" }
}
["triggerid"]=>
string(5) "16685"
["status"]=>
string(1) "0"
["value"]=>
string(1) "0"
["priority"]=>
string(1) "1"
["lastchange"]=>
string(1) "0"
["description"]=>
string(53) "Host name of zabbix_agentd was changed on {HOST.NAME}"
["expression"]=>
string(9) "{22632}>0"
} ...

2.0.7:

array(33) {
[0]=>
array(9) {
["triggerid"]=>
string(5) "16685"
["status"]=>
string(1) "0"
["value"]=>
string(1) "0"
["priority"]=>
string(1) "1"
["lastchange"]=>
string(1) "0"
["description"]=>
string(53) "Host name of zabbix_agentd was changed on {HOST.NAME}"
["expression"]=>
string(9) "{22632}>0"
["hostid"]=>
string(5) "10156"
["hosts"]=>
array(1) {
[0]=>
&array(1) { ["hostid"]=> string(5) "10156" }

}
} ...

Notice the ampersand when it comes to the hosts! The foreach loop is tripping over that.

Comment by Alf Solli [ 2013 Jul 31 ]

In an attempt to debug this, I've added var_dump($triggers) on line 1142(2.0.7) and 1131(2.0.6) in maps.inc.php, right before the foreach loop.

This can be compared at
http://www.linuxgeekz.net/ZBX-2.0.6-debug/maps.php?form_refresh=1&fullscreen=0&sysmapid=2
http://www.linuxgeekz.net/ZBX-2.0.7-debug/maps.php?form_refresh=1&fullscreen=0&sysmapid=2

and unmodified at
http://demo.sensorfabrikken.no/maps.php?form_refresh=1&fullscreen=0&sysmapid=2

Login: demo, pass: demo

This map contains a host (hostid 10156, or "Puma" ) with this trigger:
(

{LGN-SiteSense01:AN2.status.avg(5m)}

=1) & (

{Puma:log[/var/log/messages,alarm state,,,].str(Gone into alarm)}

=1)

The host "LGN-SiteSense01" (or hostid 10111) does not exist at ALL on this map.

In 2.0.7, this hostid is mentioned in the array returned from CTriggers.php, and causes the Undefined index php errors on line 1145.
In 2.0.6, it's not, and works fine. (But in retrospect, that allowed a user to view a map, referring to items on a host they didn't have access to )

Comment by Alexander Vladishev [ 2013 Jul 31 ]

The regression will be fixed under ZBX-6840.

I'm closing the current issue.

Generated at Fri Apr 19 04:53:02 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.