Ad Widget

Collapse

Macros in Trigger expressions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tenou
    Junior Member
    • Feb 2020
    • 17

    #1

    Macros in Trigger expressions

    Hey there,

    I'm trying to implement macros in trigger expressions. This way it'd be possible to assign discovered items to "groups" with different thresholds, without having to define every single threshold manually.
    However, when adding a macro to a trigger expression, zabbix is complaining about syntax errors.

    Is there a way to do this properly?
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    Pls show trigger expression.
    What type of macros are you using?

    Comment

    • Tenou
      Junior Member
      • Feb 2020
      • 17

      #3
      Code:
      {1wire-temperature-probe:system.run[cat /sys/bus/w1/devices/{#DEVICE}/w1_slave | tail -n +2  | cut -d= -f2-].last()}>=30
      That would be the trigger expression in the current state of things.
      What I'd want to do with it is this:

      Code:
      (
      {1wire-temperature-probe:system.run[cat /sys/bus/w1/devices/{#DEVICE}/w1_slave | tail -n +2 | cut -d= -f2-].last()}>=30
      and
      {$GROUP:"{#DEVICE}"}=0
      )
      or
      (
      {1wire-temperature-probe:system.run[cat /sys/bus/w1/devices/{#DEVICE}/w1_slave | tail -n +2 | cut -d= -f2-].last()}>=40
      and
      {$GROUP:"{#DEVICE}"}=1
      )
      {$GROUP:"{#DEVICE}"} being the context specific macro I was talking about.
      It's set as 0 by default ({$GROUP}=0 in the host tab), but you could override it by setting it manually for specific devices (eg. {$GROUP:"1481748147861"}=1).

      This way, by default the threshold for every device would be 30°C, but you could set it manually to 40°C without the hassle of disabling the existing triggers, configuring new ones etc.
      I hope you get what I'm trying to do. If not, feel free to ask!

      Comment

      • Tenou
        Junior Member
        • Feb 2020
        • 17

        #4
        Okay well.. It worked with the stuff I posted earlier today perfectly. There's no problem. I was just dumb. Sorry

        Comment

        Working...