Ad Widget

Collapse

Getting host name ({HOST.HOST}) in trigger expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Linwood
    Senior Member
    • Dec 2013
    • 398

    #1

    Getting host name ({HOST.HOST}) in trigger expression

    I was surprised to find I cannot (apparently) use the host name in a trigger expression.

    I wanted to compare the SNMP return for sysName against the current host name as a way of noticing if a device has migrated (e.g. due to DHCP) to a different host.

    I realize I can use the change in that value as well, but I was trying to do this instead as a way of also detecting initial incorrect setups (e.g. someone adds a host and puts in the wrong IP). I also realize this requires discipline in naming (but that's a goal not a problem).

    Am I correct, there's no syntax or technique that let's you do so?

    The only workaround I can see (and what I may do) is an external check, since {HOST.HOST} can be passed as a parameter to it, though that produces a separate item as well as trigger, not to mention a lot more overhead.

    Am I missing anything?
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    IMO using in trigger names macro wih hostname is VERY BAD idea.
    Why?
    Few example page with list of active triggers with in problems state it is separated column where hostname is already listed. Using hostname second time in trigger name makes such table less readable/clear and it leaves less line space for real message of the trigger.
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment

    • Linwood
      Senior Member
      • Dec 2013
      • 398

      #3
      Thanks, kloczek, but perhaps you misunderstood.

      I do not want it in the trigger name, I want it in the trigger expression, to compare against.

      Comment

      • kloczek
        Senior Member
        • Jun 2006
        • 1771

        #4
        Originally posted by Linwood
        Thanks, kloczek, but perhaps you misunderstood.

        I do not want it in the trigger name, I want it in the trigger expression, to compare against.
        Yep mistake ..
        Nevertheless I'm a bit curious in what kind of expression/scenario you may need exactly this macro (?)
        http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
        https://kloczek.wordpress.com/
        zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
        My zabbix templates https://github.com/kloczek/zabbix-templates

        Comment

        • Linwood
          Senior Member
          • Dec 2013
          • 398

          #5
          Doing this off the top of my head but something like:

          sysName.regexp(^{HOST.HOST}$)=0 and
          sysname.regexp(.+)=1

          to check that the key (which contains snmp's sysName field) has a value, and does not match the host name. Obviously prefixed by a template.

          Comment

          • msz@kommunekredit.dk
            Junior Member
            • Jun 2024
            • 7

            #6
            I am also a little curious here, for a web scenario trigger you need to use something like this (from Zabbix manual):
            "length(last(/host/web.test.error[Scenario]))>0 and last(/host/web.test.fail[Scenario])>0"
            where "host" is the host name - here it would make perfect sense to use the {HOST.HOST} or {HOST.NAME} since the web scenario is a part of the host (I presume).

            Comment

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

              #7
              Originally posted by [email protected]
              I am also a little curious here, for a web scenario trigger you need to use something like this (from Zabbix manual):
              "length(last(/host/web.test.error[Scenario]))>0 and last(/host/web.test.fail[Scenario])>0"
              where "host" is the host name - here it would make perfect sense to use the {HOST.HOST} or {HOST.NAME} since the web scenario is a part of the host (I presume).
              If you create web scenario directly on host, you most probably will have that trigger also directly on host. so you don't need to use macro, just select the item with hardcoded hostname... If you use template for it, then in template you have template name there, which will be replaced with hostname, when added to host...

              Comment

              Working...