Ad Widget

Collapse

extract the value of a key from a template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssks393
    Junior Member
    • Feb 2023
    • 28

    #1

    extract the value of a key from a template

    Hello,
    I am monitoring switches and I am using a stock zabbix switch monitoring template. When ping is down I receive an email notfication. I have created a custom subject in the alert that uses {HOST.NAME} {EVENT.NAME]
    the template has a key that gets the value of the switches system name. Its called system.name
    Can I use the system.name value in the email subject? for example {HOST.NAME} system.name {EVENT.NAME]
  • vijayk
    Senior Member
    • May 2023
    • 305

    #2
    Originally posted by ssks393
    Hello,
    I am monitoring switches and I am using a stock zabbix switch monitoring template. When ping is down I receive an email notfication. I have created a custom subject in the alert that uses {HOST.NAME} {EVENT.NAME]
    the template has a key that gets the value of the switches system name. Its called system.name
    Can I use the system.name value in the email subject? for example {HOST.NAME} system.name {EVENT.NAME]
    You can use predefined macro in trigger.

    Comment

    • ssks393
      Junior Member
      • Feb 2023
      • 28

      #3
      I have found this expression
      last(/HP Enterprise Switch by SNMP/system.name,#1))
      do I need to use any extra symbols when pasteing it to the subject?

      Comment

      • vijayk
        Senior Member
        • May 2023
        • 305

        #4
        Originally posted by ssks393
        I have found this expression
        last(/HP Enterprise Switch by SNMP/system.name,#1))
        do I need to use any extra symbols when pasteing it to the subject?
        It will gives last value of system.name which you define. You can try this. {ITEM.LASTVALUE}

        Comment

        • ssks393
          Junior Member
          • Feb 2023
          • 28

          #5
          how do I specify of which item {ITEM.LASTVALUE} will take?

          Comment

          • vijayk
            Senior Member
            • May 2023
            • 305

            #6
            share the existing item and trigger here.

            Comment

            • ssks393
              Junior Member
              • Feb 2023
              • 28

              #7
              Click image for larger version

Name:	zbx2.png
Views:	333
Size:	50.4 KB
ID:	472188 Click image for larger version

Name:	zbx.png
Views:	328
Size:	43.6 KB
ID:	472187
              Top picture is item and bottom trigger​

              Comment

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

                #8
                Originally posted by ssks393
                how do I specify of which item {ITEM.LASTVALUE} will take?
                It will be the item, that is used in trigger expression. If you have multiple items used in trigger expression, you can refer to them in order of appearance {ITEM.LASTVALUE1}, {ITEM.LASTVALUE2},...,{ITEM.LASTVALUE9}
                EDIT. as you have only one, "system.name", then thats the one, which value shows up in {ITEM.LASTVALUE} and will be used in event.

                Comment

                • ssks393
                  Junior Member
                  • Feb 2023
                  • 28

                  #9
                  Originally posted by cyber

                  It will be the item, that is used in trigger expression. If you have multiple items used in trigger expression, you can refer to them in order of appearance {ITEM.LASTVALUE1}, {ITEM.LASTVALUE2},...,{ITEM.LASTVALUE9}
                  I understand but I want to use it in email subject.

                  Comment

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

                    #10
                    Taking your example from above...
                    for example {HOST.NAME} {ITEM.LASTVALUE} {EVENT.NAME]
                    I think... you define your "template" for email in media config... https://www.zabbix.com/documentation...ications/media

                    Comment

                    • ssks393
                      Junior Member
                      • Feb 2023
                      • 28

                      #11
                      Originally posted by cyber
                      Taking your example from above...


                      I think... you define your "template" for email in media config... https://www.zabbix.com/documentation...ications/media
                      And how can I add the expression to the template?
                      last(/HP Enterprise Switch by SNMP/system.name,#1)
                      I tried and it does not return the value.

                      Comment

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

                        #12


                        I think documentation must be evil somehow, that people won't read it...

                        Comment

                        • ssks393
                          Junior Member
                          • Feb 2023
                          • 28

                          #13
                          Originally posted by cyber
                          https://www.zabbix.com/documentation...eration/macros

                          I think documentation must be evil somehow, that people won't read it...
                          Read this.
                          I tried using {?last(/{HOST.NAME}/system.name)}
                          ​than it returns *UNKNOWN*, but when I manually enter the host name of the host instead of {HOST.NAME} than it works, for example
                          {?last(/127.0.0.1/system.name)}
                          Attached Files

                          Comment


                          • ssks393
                            ssks393 commented
                            Editing a comment
                            SOLVED. Used {HOST.HOST} instead of {HOST.NAME}
                        Working...