Ad Widget

Collapse

OR and str operation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • linuxsquad
    Junior Member
    • Jul 2013
    • 12

    #1

    OR and str operation

    I have a trigger to monitor status (text) and it works fine:

    {Template_testing:command[0,e,"State"].str(clean)}#1

    However, I am trying to extend this trigger by adding 2nd status and OR statement:

    ({Template_testing:command[0,e,"State"].str(clean)}#1) |
    ({Template_testing:command[0,e,"State"].str(active)}#1)

    and it does NOT work

    Is it a bug? Or am I doing something wring here?
  • BDiE8VNy
    Senior Member
    • Apr 2010
    • 680

    #2
    This trigger fires for every value that doesn't include 'clean' and 'active'. Is this really what you want?

    ({host:item["par"].str(clean)}#1)|({host:item["par"].str(active)}#1)

    What means:
    ({host:item["par"].str(clean)} NOT 1) OR ({host:item["par"].str(active)} NOT 1)

    What means:
    string 'clean' not found or string 'active' not found

    BTW:
    There is a possibility to test the logical function of trigger expressions. Watch out for 'Expression constructor' in 'Creation of triggers and then hit the 'Test' hyperlink near by the expression.

    Comment

    • linuxsquad
      Junior Member
      • Jul 2013
      • 12

      #3
      BDiE8VNy,

      This is exactly what I need and expect, instead Zabbix fails this construct 100% of the time.

      Yes, I did try "test" for trigger expression.

      Comment

      • BDiE8VNy
        Senior Member
        • Apr 2010
        • 680

        #4
        Hmm... what happens if you use an expression similar to this one?:
        {host:item["par"].regexp("(clean.*active|active.*clean)")}#1
        Last edited by BDiE8VNy; 03-07-2013, 15:06. Reason: logical error

        Comment

        • linuxsquad
          Junior Member
          • Jul 2013
          • 12

          #5
          BDiE8VNy,

          I've used all possible combinations

          - regexp(clean|active)
          - regexp("clean|active")
          - regexp([clean|active])

          and probably couple more that I am forgetting. Zabbix's syntax check is fine, but the logic fails.

          Comment

          • BDiE8VNy
            Senior Member
            • Apr 2010
            • 680

            #6
            Do you see something suspicious the log files (server, proxy, agent)?

            Does the regular expression work outside Zabbix (with the actual string):
            Code:
            [user@example ~]$ alias regexp="egrep '(active.*clean|clean.*active)'"
            [user@example ~]$ regexp <<< "active"
            [user@example ~]$ regexp <<< "clean"
            [user@example ~]$ regexp <<< "active clean"
            active clean
            [user@example ~]$ regexp <<< "clean active"
            clean active

            Comment

            • linuxsquad
              Junior Member
              • Jul 2013
              • 12

              #7
              - on the client, regexp works as expected
              - neither server nor agent logs have relevant messages

              Comment

              • BDiE8VNy
                Senior Member
                • Apr 2010
                • 680

                #8
                I just successfully tested the following scenario:
                1. Created a new item of type 'Zabbix trapper' with key 'zabbix.trapper.test'
                2. Created a new trigger with expression:
                  Code:
                  {host.example.com:zabbix.trapper.test.regexp("(active.*clean|clean.*active)")}=0
                3. And finally send values to the item via zabbix_sender


                Zabbix Sender command I used:
                Code:
                zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -s host.example.com -k zabbix.trapper.test -o "foo bar"
                Depending on the send value I got the following Trigger status:
                "clean only" -> PROBLEM
                "clan and active" -> OK
                "active only" -> PROBLEM
                "active and clean" -> OK
                "foo bar" -> PROBLEM


                I can only suggest you to double check your configuration for typos or similar mistakes.

                Comment

                • linuxsquad
                  Junior Member
                  • Jul 2013
                  • 12

                  #9
                  Using your example with regexp works for both cases

                  - active
                  - clean

                  Thanks

                  Comment

                  Working...