Ad Widget

Collapse

Use item value as a macros or in another item's trigger name.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Valinor
    Junior Member
    • Sep 2020
    • 20

    #1

    Use item value as a macros or in another item's trigger name.

    Hello,
    I have an item that gets some text value from the server for example First or Second.
    I need to use it in another item's trigger so the alert message(trigger name) would be "Lack of memory on First".
    Is this possible?
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2


    Pay special attention to the macro example from the documentation that splitek references.

    Comment

    • Valinor
      Junior Member
      • Sep 2020
      • 20

      #3
      Originally posted by tim.mooney
      https://www.zabbix.com/forum/zabbix-...multiple-items

      Pay special attention to the macro example from the documentation that splitek references.
      Thanks! As I understand I can only do it by changing the trigger expression, I cannot just put it in any trigger name like host macros?

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        Yes, this particular method does require that the trigger reference all the items whose values you want to include in your message.

        Comment

        • Valinor
          Junior Member
          • Sep 2020
          • 20

          #5
          I've noticed that {host:key.func(param)} macros expression has a similar syntax to what I need, also it said that it can be used in Trigger-based notifications and commands.
          Though, when I try to use it like: {host:vfs.fs.inode[/,pfree].last(0)} it doen't do anything, and
          {{HOST.HOST}:vfs.fs.inode[/,pfree].last(0)} resolves hostname, but not the lates value :-(
          Any chance I can use it to grab a value from the different item on a host?

          Comment

          • tim.mooney
            Senior Member
            • Dec 2012
            • 1427

            #6
            Can you show your full trigger expression and the notification message? You can obscure any sensitive data like hostnames, if necessary.

            Comment

            • Valinor
              Junior Member
              • Sep 2020
              • 20

              #7
              I have an item with a key server_role which returns the value of Primary or Secondary.
              I want it to be used in most of the trigger notifications for this server, ideally without putting it to the trigger expressions.
              For example, I want to put it in Linux trigger name for CPU load:
              Processor load is too high on {HOST.NAME} {host:server_role.last(0)}
              So I want alert to come with the last value of server role item like: Processor load is too high on Web_server Secondary

              I've tried different combinations of {host:key.func(param)} expression, but it doesn't seem to work.

              Comment

              • Valinor
                Junior Member
                • Sep 2020
                • 20

                #8
                Originally posted by splitek
                https://www.zabbix.com/documentation...gers/functions
                str (<pattern>,<sec|#num>)
                Finding a string in the latest (most recent) value. pattern (optional) - required string
                sec or #num (optional) - maximum evaluation period1 in seconds or in latest collected values (preceded by a hash mark). In this case, more than one value may be processed.
                Supported value types: str, text, log

                Returns:
                1 - found
                0 - otherwise

                If more than one value is processed, '1' is returned if there is at least one matching value.

                This function is case-sensitive.

                Tip: You may use the 'count' function with the like operator to count string values that match a pattern.
                Example:
                trigger name: "........ on {HOST.NAME} is: {ITEM.VALUE1} role: {ITEM.VALUE2}"
                trigger expression:
                Code:
                {host:item_one_integer.last()}>90 or {host:item_two_character.str(SOME_STRING_NEVER_FOUND)}=1
                thanks, that method works, but I'm trying to find a way to accomplish it without editing every trigger expression.

                I thought that the macros would work in the trigger name, but it doesn't and I couldn't figure out why.
                {host:key.func(param)} → Trigger-based notifications and commands
                → Problem update notifications and commands
                → Map element/shape labels 3
                → Link labels in maps3
                → Graph names5
                → Trigger expressions6
                Simple macros, as used in building trigger expressions.

                Supported for shape labels in maps since 3.4.2.

                Comment

                • Valinor
                  Junior Member
                  • Sep 2020
                  • 20

                  #9
                  Originally posted by splitek
                  As you see doc only talks about "Trigger expressions" not "trigger name". More, in right column is "Simple macros, as used in building trigger expressions.". The text is clear, so don't waste your time it can't be done in the way you want.

                  BTW.
                  If you search this page: https://www.zabbix.com/documentation...ed_by_location
                  for string "trigger names" then you find that in trigger names work only few macros HOST... ITEM.VALUE ITEM.LASTVALUE
                  Trigger-based notifications and commands was the one that probably makes me interested.
                  But nevertheless, thanks for everybody for help, will work with the solution guys above mentioned.

                  Comment

                  • Valinor
                    Junior Member
                    • Sep 2020
                    • 20

                    #10
                    Maybe someone will be interested in the same idea, I've figure out how to solve it for me.
                    I've used {host:key.func(param)} in the actions/operation it works great if you put in message notification, the hosts where you need to use it can be separated with tags.

                    Comment

                    Working...