Ad Widget

Collapse

Is it possible to get the host name inside a trigger expression ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lokha
    Junior Member
    • Jun 2020
    • 15

    #1

    Is it possible to get the host name inside a trigger expression ?

    I want to check inside the trigger expression using the host name ({HOST.NAME}). But when I try to do this, I get an error:
    Code:
    Invalid parameter "/1/expression": incorrect trigger expression starting from " {HOST.NAME}.str("test")".
    I tried to go the roundabout way. I tried to create an Item that would store the hostname. But that also turned out to be impossible. I tried to create an Item of type Zabbix trapper which would store the value {HOST.NAME}. But when I try to do this, I get an error:

    Code:
    Invalid key "{HOST.NAME}" for item...

    Is it possible to do what I want to do?
  • lokha
    Junior Member
    • Jun 2020
    • 15

    #2
    I found a crooked solution.

    I created a script /usr/lib/zabbix/externalscripts/echo.sh
    Code:
    #!/bin/sh
    
    echo "$@"

    Then I created an Item of the External check type with this key:
    Code:
    echo.sh["{HOST.NAME}"]
    And I can already use this Item inside the trigger expression.

    But I'd be happy to hear better solutions.

    Comment

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

      #3
      So your wish is to create a trigger which only works if hostname contains a string "test"..?
      No you cannot do that. Trigger expressions are built using items, not hosts...

      Comment

      • systemservice
        Junior Member
        • Aug 2024
        • 3

        #4
        What is the reason for this limitation?
        For example, in the trigger expression you can write:
        HTML Code:
        find(/DNS query/net.dns.record[,{HOST.DNS},A,2,1],,"like","192.168.1.1")=0
        ..,and it works - the host macro {HOST.DNS} is accepted.
        So why is the host macro not accepted in the place of the IP address below?
        HTML Code:
        find(/DNS query/net.dns.record[,{HOST.DNS},A,2,1],,"like",{HOST.IP})=0
        EDIT: I would like to delete this post.
        Last edited by systemservice; 02-10-2024, 15:17.

        Comment

        Working...