Ad Widget

Collapse

Trigger with in() comparison and values supplied from a user macro — possible?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sigprof
    Junior Member
    • Apr 2025
    • 1

    #1

    Trigger with in() comparison and values supplied from a user macro — possible?

    I want to have something like this in a trigger (using Zabbix 7.2):

    Code:
    in(last(//sensor.psu.status[hh3cEntityExtErrorStatus.9]),51,61,91)
    except the 51,61,91 part should be customizable through a user macro.

    Writing something like
    Code:
    in(last(//sensor.psu.status[hh3cEntityExtErrorStatus.9]),{$PSU.HH3C.STATUS.CRIT.VALUES})
    does not work, because the value of the user macro gets quoted as a single string argument instead of being split to multiple arguments.

    I have been able to implement the desired behavior using the count() function with the "regexp" matching:
    Code:
    count(//sensor.psu.status[hh3cEntityExtErrorStatus.9],#1,"regexp",{$PSU.HH3C.STATUS.CRIT.MATCHES})>=1
    with {$PSU.HH3C.STATUS.CRIT.MATCHES} containing something like ^(51|61|91)$.
    Is there any better way to do that, or would the regexp matching be the only solution here?
    (Actually this solution is more versatile than in(last(...),...), because it is possible to check more than a single value from history; could the regexp matching be a performance problem here?)

    The stock template does things like
    Code:
    count(/HP Comware HH3C by SNMP/sensor.psu.status[hh3cEntityExtErrorStatus.{#SNMPINDEX}],#1,"eq","{$PSU_CRIT_STATUS:\"psuError\"}")=1
    which allows customization of the numeric values, but does not allow adding extra matching values.
Working...