[ZBX-6151] Cross-host reference in LLD trigger prototype ignored Created: 2013 Jan 18  Updated: 2017 May 30  Resolved: 2014 Mar 06

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: API (A), Frontend (F)
Affects Version/s: 2.0.4
Fix Version/s: 2.0.12rc1, 2.2.3rc1, 2.3.0

Type: Incident report Priority: Critical
Reporter: Roman Chapurny Assignee: Ivo Kurzemnieks
Resolution: Fixed Votes: 0
Labels: lld, triggers
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I have 2 hosts (A and B) configured with LLD rule for discovery of some object collection, for example host file systems. I need to compare some attributes of corresponding objects, for example free disk space, and trigger an event if there's a mismatch or if difference is out of range.

When an LLD trigger prototype created under host A that references LLD item prototype of host B is instantiated, reference to host B is substituted with a reference to host A. Consequently trigger expression that was meant to compare values of LLD discovered item on host A and host B compares value of this item on host A to itself. Instantiated triggers only get listed under host A in the GUI in this case.

If LLD is not involved, this kind of trigger works as expected, hosts A and B are correctly referenced and values of respective items are compared. In addition, trigger that references both hosts gets listed under each host in the GUI. I'd expect LLD trigger functionality to be the same in this respect as a regular trigger, so I'm filing this as a bug.

While this kind of cross-host references could be prone to mismatches (e.g. if a certain LLD item is discovered only on host A, but not on host B), these mismatches shouldn't be harmful, a trigger referencing non-existent item will not initialize until each referenced item is available/discovered under each host involved.

Steps to reproduce:
1. Create (or use standard) template with FS LLD rule (#FSNAME, #FSTYPE), add an LLD item prototype (vfs.fs.size[

{#FSNAME},pfree] )
2. Add 2 hosts (hostA and hostB), associate with this template
3. Go into LLD rule on host A, add trigger prototype with the following expression:
{hostA:vfs.fs.size[{#FSNAME}

,pfree].last(0)} # {hostB:vfs.fs.size[

{#FSNAME}

,pfree].last(0)}
4. After next LLD cycle review instantiated triggers based on the prototype above. Instantiated trigger expression does not match prototype expression:

{hostA:vfs.fs.size[/,pfree].last(0)}

#

{hostA:vfs.fs.size[/,pfree].last(0)}

5. If hostA:vfs.fs.size[/,pfree].last(0) and hostB:vfs.fs.size[/,pfree].last(0) are different, trigger is not activated as hostB:vfs.fs.size[/,pfree].last(0) is never evaluated.



 Comments   
Comment by Alexander Vladishev [ 2014 Feb 12 ]

Zabbix doesn't support cross-host item prototype references in the trigger prototypes and graph prototypes. Frontend (API) should prevent possibility of creation of such prototypes.

It is reproducible in 2.0.11 and 2.2.2.

Comment by Ivo Kurzemnieks [ 2014 Feb 20 ]

RESOLVED for 2.0 in svn://svn.zabbix.com/branches/dev/ZBX-6151
RESOLVED for 2.2 in svn://svn.zabbix.com/branches/dev/ZBX-6151-22

Comment by Alexander Vladishev [ 2014 Feb 25 ]

(1) [@2.0 & @2.2] redundant check for count of array elements

if ($triggerPrototypes && count($triggerPrototypes) > 1) {
}
elseif (!$triggerPrototypes) {
}

Will be better so:

if (!$triggerPrototypes) {
}
elseif (count($triggerPrototypes) > 1) {
}

same issue with graph prototypes

iivs RESOLVED for 2.2 in r42998 and 2.0 in r42999

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Feb 25 ]

(2) [@2.0 & @2.2] variables $triggerPrototypes an $graphPrototypes should be renamed. These arrays doesn't contain triggers- or graphs-prototypes.

iivs RESOLVED for 2.2 in r42998 and 2.0 in r42999

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Feb 25 ]

(3) [@2.2] unnecessary check for emptiness of an array

if ($graph['gitems']) {
    ...
}

iivs RESOLVED for 2.2 in r42998 and 2.0 in r42999

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Feb 25 ]

(4) Error messages should contain names of the elements.

iivs In 2.0 graphprototype.update would require extra select name from DB and as we discussed for graph prototypes we'll change error messages only for 2.2, but for trigger prototpes I've correct the error messages in both dev branches.

RESOLVED for 2.2 in r42998 and 2.0 in r42999

sasha REOPENED In 2.0 error messages for trigger prototypes are fixed only in one place.

iivs RESOLVED for 2.0 in r43001

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Feb 25 ]

(5) Trigger- and graph-prototypes can contain item prototypes from one discovery rule.

iivs RESOLVED for 2.0 in r43015 and 2.2 in r43016

sasha REOPENED

  • Errors occurred when saving graph prototype with regular items

[@2.0]

Undefined index: itemDiscovery [api/classes/CGraphPrototype.php:903]
array_flip(): Can only flip STRING and INTEGER values! [api/classes/CGraphPrototype.php:906]

[@2.2]

Undefined index: parent_itemid [graphs.php:222 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CGraphGeneral->update() → CGraphPrototype->validateUpdate() → CGraphPrototype->checkCrossRefferenceDiscovery() in /home/sasha/zabbix-svn/branches/dev/ZBX-6151-22/frontends/php/api/classes/CGraphPrototype.php:805]
array_flip(): Can only flip STRING and INTEGER values! [graphs.php:222 → CAPIObject->update() → CAPIObject->__call() → czbxrpc::call() → czbxrpc::callAPI() → call_user_func() → CGraphGeneral->update() → CGraphPrototype->validateUpdate() → CGraphPrototype->checkCrossRefferenceDiscovery() → array_flip() in /home/sasha/zabbix-svn/branches/dev/ZBX-6151-22/frontends/php/api/classes/CGraphPrototype.php:808]
  • the new functions should be protected
  • the new functions parameters are not described
  • these api calls should be with 'nopermission' option
$createdTriggers = $this->get(array(
    'triggerids' => $triggerids,
    'output' => array('description'),
    'selectItems' => array('itemid', 'hostid', 'flags')
));
$updatedTriggers = $this->get(array(
    'triggerids' => $triggerids,
    'output' => array('description'),
    'selectItems' => array('itemid', 'hostid', 'flags')
));
  • typo in function name checkCrossRefferenceDiscovery()
    • this function should be renamed, for example: checkMultipleRules()
  • frontends/php/include/triggers.inc.php:1102 this changes should be cancelled

iivs RESOLVED for 2.0 in r43094 and for 2.2 in r43095

sasha REOPENED

  • undocumented array elements in functions checkDiscoveryRuleCount()
  • CGraphPrototype::checkDiscoveryRuleCount() $item variable should be renamed as $gitem
  • @2.0 CTriggerPrototype unused fields 'hostid', 'flags' in api calls:
    $createdTriggers = $this->get(array(
        'triggerids' => $triggerids,
        'output' => array('description'),
        'selectItems' => array('itemid', 'hostid', 'flags'),
        'nopermissions' => true
    ));
    
    $updatedTriggers = $this->get(array(
        'triggerids' => zbx_objectValues($triggers, 'triggerid'),
        'output' => array('description'),
        'selectItems' => array('itemid', 'hostid', 'flags'),
        'nopermissions' => true
    ));
    

iivs
RESOLVED for 2.0 ir r43190
RESOLVED for 2.2 ir r43191

sasha CLOSED

Comment by Alexander Vladishev [ 2014 Mar 07 ]

2.2 removed strings:

  • Graph prototype must have at least one prototype.
  • Trigger prototype expression "%1$s" must contain at least one item prototype.

2.2 new strings:

  • Graph prototype "%1$s" contains item prototypes from multiple discovery rules.
  • Graph prototype "%1$s" must have at least one item prototype.
  • Trigger prototype "%1$s" contains item prototypes from multiple discovery rules.
  • Trigger prototype "%1$s" must contain at least one item prototype.
Comment by Alexander Vladishev [ 2014 Mar 07 ]

2.2 was successfully tested with small fix in r43289. Please review.

iivs REVIEWED. Thanks!

Comment by Alexander Vladishev [ 2014 Mar 07 ]

2.0 removed strings:

  • Graph prototype must have at least one prototype.
  • Trigger "%1$s" does not have item prototype.
  • Trigger prototype expression "%1$s" must contain at least one item prototype.

2.0 new strings:

  • Graph prototype "%1$s" contains item prototypes from multiple discovery rules.
  • Graph prototype "%1$s" must have at least one item prototype.
  • Trigger prototype "%1$s" contains item prototypes from multiple discovery rules.
  • Trigger prototype "%1$s" must contain at least one item prototype.
Comment by Alexander Vladishev [ 2014 Mar 07 ]

2.0 was successfully tested with small fix in r43291. Please review.

iivs REVIEWED. Thanks!

Comment by Ivo Kurzemnieks [ 2014 Mar 07 ]

Fixed trigger prototype and graph prototype validation so items are no longer allowed from multiple discovery rules.

For 2.0 additionally fixed filter by flags not overriding in item.get method

For 2.2 additionally fixed graph and graph prototype update validation allowing to pass only 'gitemid' parameter without 'itemid'. And added missing graph prototype is error message when validation non-numeric items.

API Changes documented:
https://www.zabbix.com/documentation/2.0/manual/appendix/api/changes_2.0
https://www.zabbix.com/documentation/2.2/manual/api/changes_2.2

Fixed in pre-2.0.12rc1 r43301, pre-2.2.3rc1 r43305 and pre-2.3.0 (trunk) r43306

Generated at Fri Mar 29 09:47:14 EET 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.