Ad Widget

Collapse

Zabbix built-in Macros not working with Find in Trigger expressions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • automiketic
    Junior Member
    • Nov 2022
    • 8

    #1

    Zabbix built-in Macros not working with Find in Trigger expressions

    Perhaps I haven't found the right combination of quotes/parenthesis/etc, but when I try to use Zabbix built in macros, specifically {HOST.HOST} or {HOST.NAME} within a trigger expression like this:

    Code:
    find(/BBU SNMP TRAPS/snmptrap.fallback,,,"{HOST.HOST}")=1
    It seems like macro is not expanded and just read literally. I can use a user macro with the same syntax without issue. The following works:

    Code:
    find(/BBU SNMP TRAPS/snmptrap.fallback,,,"{$BBU.NAME}")=1
    Is there a way for me to use the built in macro within the quotes or do I need to use the user macro due to the quotes?

    If I do have to use a user macro, is there any way for me to create a user macro from a built in macro without having to create one on each host manually?
    Last edited by automiketic; 30-01-2023, 22:46.
  • automiketic
    Junior Member
    • Nov 2022
    • 8

    #2
    By what I've read I can't easily import built-in macros into user macros though I suspect I could with a little scripting and API. That being said no one knows the proper syntax for calling a zabbix macro within double quotes?

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #3
      Lets go back to basics and read, what is said in docs... https://www.zabbix.com/documentation...ed_by_location
      {HOST:HOST} does not have anything about possibility to be used in trigger expressions. Only built in macro, you can use there, is {TRIGGER.VALUE}

      Comment

      • automiketic
        Junior Member
        • Nov 2022
        • 8

        #4
        Click image for larger version

Name:	image.png
Views:	779
Size:	46.7 KB
ID:	458806
        I took from this that it could be used in trigger expressions.

        Comment

        • LenR
          Senior Member
          • Sep 2009
          • 1005

          #5
          What you highlighted is where the value is sourced, the middle column is where you can use the macro, trigger expression isn't included.

          It seems you want to look for the host name in a log message, and I think you're right, there isn't a way to do that out of the box. I used an API script at auto registration time to set inventory fields, I think the same thing could be done to set a user macro. How are these hosts defined? Discovery, auto registration or manually? But, all I can think of is to use the API to set a user macro.

          Comment

          • cyber
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Dec 2006
            • 4807

            #6
            You are interpreting it wrong..
            If you use items from multiple hosts in your trigger expression, then you can use this macro with 1-9 index to refer to host of first, second, third, etc... item, that was used in expression... but you still can use it only in places, described in second column of this pic..

            Comment

            Working...