Ad Widget

Collapse

Compare Value of Two Text Items in Trigger Expression

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JustinAddams
    Junior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2018
    • 5

    #1

    Compare Value of Two Text Items in Trigger Expression

    Hi guys,

    Im attempting to create a trigger that alerts if two items do not contain the same value.
    This seems to be very simple if the items are Integers and impossible if the items are Text, am just hoping if anyone can shed some light on the matter.

    I attempted to follow the information provided under https://www.zabbix.com/forum/zabbix-...cond-missmatch
    But that didn't work.

    And if i write the Trigger like this
    Code:
    {Template - Debug:debug.debug_charlie.last()} = {Template - Debug:debug.debug_delta.last()} = 0
    I just get evaluation errors as the Strings arent Numbers.
    Cannot evaluate expression: expected numeric token at "Va) = (Va) = 0"
  • JustinAddams
    Junior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2018
    • 5

    #2
    Taking into account the existence of this Issue https://support.zabbix.com/browse/ZBXNEXT-702

    And this line in the documentation
    1) All functions return numeric values only. Comparison to strings is not supported, for example.
    I'm starting to think this is impossible and that the examples provided in the other Forum Post are missing key pieces such as a hardcoded string to find in the .str() function.

    If anyone can confirm it'd be appreciated.

    Comment

    • brunohl
      Senior Member
      Zabbix Certified Specialist
      • Mar 2019
      • 215

      #3
      Any update on this one?

      Comment

      • splitek
        Senior Member
        • Dec 2018
        • 101

        #4
        If you using Zabbix 4, you can try write preprocessing rule with JavaScript to calculate some hash for text, so you can compare this two hashes.
        Ofc hash need to be number only.

        Comment

        • brunohl
          Senior Member
          Zabbix Certified Specialist
          • Mar 2019
          • 215

          #5
          Yeah, I made it work converting to a float value, but it got truncated. But I guess it will work as there are many decimal places. Thanks anyway

          Comment

          • JustinAddams
            Junior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Oct 2018
            • 5

            #6
            Only just checked the forum, forgot to setup notifications.
            Thanks for the great idea!

            Comment

            • gofree
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2017
              • 400

              #7
              shre it pls last tiem I had to do it via ext bash script - version 4.0.x didnt have the java script capability
              Last edited by gofree; 27-09-2019, 14:48.

              Comment

              • brunohl
                Senior Member
                Zabbix Certified Specialist
                • Mar 2019
                • 215

                #8
                Actually I didn't make via pre-processing but by my JS external script. What I would return like "f760f5a2f0e7c50ae361a394152c5d3f"
                I converted through this function:
                Code:
                obj.convertMd5ToNum = function ( hash ) {
                    var newHash = '1.';
                    for (var i in hash) {
                      newHash += hash.charCodeAt(i);
                    }
                    return parseFloat( newHash );
                  }
                To:
                1.1025554481025397

                Comment


                • Bintao
                  Bintao commented
                  Editing a comment
                  If you just put in "f760f5a" you'll get same 'newHash'. I was trying to use this script to detect if two IP addresses is different, unfortunately it doesn't help
              • richlv
                Senior Member
                Zabbix Certified Trainer
                Zabbix Certified SpecialistZabbix Certified Professional
                • Oct 2005
                • 3112

                #9
                String comparison in triggers is supported since Zabbix 5.0:
                Zabbix 3.0 Network Monitoring book

                Comment

                • JustinAddams
                  Junior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Oct 2018
                  • 5

                  #10
                  I better get around to my 5.x upgrade then!
                  Thanks for the tip.

                  Comment

                  Working...