Ad Widget

Collapse

Macro name in trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxxer
    Member
    • Oct 2010
    • 80

    #1

    Macro name in trigger

    I'm trying to have a trigger check the IP host against a DNS query. I did the DNS query item but I'm missing how to check the returned value in a trigger.


    Code:
    {Template YO verifica host DNS:net.dns.record[1.0.0.1,{$DNS_HOST},A].last()}<>{$DNS_EXPECTED_IP}
    won't work because the check returns something like host.name.it A 1.3.2.3.

    I also tried

    Code:
    {{ITEM.VALUE}.regsub([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}+, \1)}
    to strip out all the unnecessary output and check against the IP value only but again it's not accepted.

    Any hint?
    thanks
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    First, triggers can only compare numbers, not strings (before version 5).
    Second use a trigger construction like
    {Template YO verifica host DNS:net.dns.record[1.0.0.1,{$DNS_HOST},A].regexp({$DNS_EXPECTED_IP_REGEX})} >0
    {$DNS_EXPECTED_IP_REGEX} - a macro containing a regular expression describing the response you need.

    Comment

    • maxxer
      Member
      • Oct 2010
      • 80

      #3
      Great, thanks!

      Isn't possible to have the macro with the IP only and wrap the rest around in the trigger definition?

      Comment


      • Hamardaban
        Hamardaban commented
        Editing a comment
        Read the documentation carefully and try it out.
    Working...