Ad Widget

Collapse

Trigger Functions (str, regexp)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rbohlmann
    Junior Member
    • Mar 2019
    • 2

    #1

    Trigger Functions (str, regexp)

    So I am trying to do a simple DNS check on a record by doing a lookup and verifying its value. Should be simple, right? Wrong..

    Using Zabbix 4.0.4

    ITEM SETUP
    I set up the 'Item' as follows:
    NameNS Query Check [Internal]
    Type: Zabbix agent
    Key: net.dns.record[127.0.0.1,pi-ncid,A,2,1]
    Type of information: Text

    I know this 'Item' works because I can look at the Data received, and the value comes back as expected (as follows, w/out quotes):
    "pi-ncid A 10.10.1.26" Side note: I also made sure there was no leading or trailing whitespace attached to that data (by temporarily prepending and appending <> via preprocessing).

    TRIGGER SETUP
    I set up the 'Trigger' as follows:
    Name: DNS Internal Check
    Severity: Warning
    Expression: {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].str(pi-ncid A 10.10.1.26)}=0

    So this simply does not work. Using the 'Expression constructor' test returns a 'True' result for above when it should return 'False'.

    The expression {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].str(pi-ncid A 10.10.1.26)} should return a value of 1, but it returns a value of 0.

    I've tried all combinations of expressions/functions and they all behave similarly; I've tried the following (to mention a few):

    {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].str(pi-ncid A 10.10.1.26)} <- the origninal
    {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].regexp(.*10.10.1.26.*)}=0 <- trying regular expression function now
    {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].regexp(".*10.10.1.26.*")}=0 <- not sure if quotes were necessary or not
    {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].regexp(.*)}=0 <- this should match literally 'anything', but still returns a 0
    {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].regexp(".*")}=0 <- not sure if quotes were necessary or not


    ADDITIONAL
    I even tried a different 'Item Key' as I started to wonder if the str and regexp functions may not work with net.dns.record:

    Changing the key to system.run[dig +short pi-ncid], produced a data text value of "10.10.1.26", as expected. However, the Trigger expression {pi-hole:system.run[dig +short pi-ncid].str(10.10.1.26)}=0 still produced a 'True' value during testing.


    Appreciate any help you can provide.

    Cheers
  • rbohlmann
    Junior Member
    • Mar 2019
    • 2

    #2
    Nevermind, I figured it out... Seems the 'test' does not run against 'live' data and one must use the dropdown to select a '0' or '1' for the value to test... So my original expression of {pi-hole:net.dns.record[127.0.0.1,pi-ncid,A,2,1].str(pi-ncid A 10.10.1.26)}=0 works just fine...

    Hope this helps somebody... The issue was more related to "Trigger Expression Testing" rather than "str or regexp issues".

    Cheers,

    Russell

    Comment

    • aigo15108
      Junior Member
      • Oct 2019
      • 17

      #3
      Yup, this forum is so helpful! :-)

      I think I am having the same problem, no matter what value I am setting it is always OK. So go figure, love zabbix so much! :-)

      Comment

      Working...