Ad Widget

Collapse

Can I directly compare 2 items values in a trigger?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Farzad FARID
    Member
    • Apr 2007
    • 79

    #1

    Can I directly compare 2 items values in a trigger?

    Hi,

    In all default trigger examples the formulas for comparison involve an item and a fixed value (eg: Unix_t:vm.memory.size[free].last(0)<10000).

    Can I use the mathematic formulas to directly compare two items to each other in order to build a trigger? There are case where the limit value to be compared to is also a dynamique value.

    For example (just a useless one that comes to my mind):
    Expression : net.if.in[eth0,bytes].last(0) > net.if.in[eth1,bytes].last(0)

    A real use would be to retrieve two values from a JBoss application server (number of active DB connections and maximum number of supported DB connections), and compare them to check if the application server is overloaded.

    Regards
  • Farzad FARID
    Member
    • Apr 2007
    • 79

    #2
    Yes it works

    Hi, and happy New Year to all of you

    I reply to my own question 8 months later, because a friend of mine had the same question, and only found my unanswered question instead of a definitive answer

    So the answer is Yes, it works. But you have to enter the expression manually, because the GUI helper only lets you enter a constant value on the right hand side of the comparison.

    Here is a real example. The comparison is meaningless in the real world (I compare the User Space CPU percentage to the Idle CPU percentage), but it is easy to trigger in a test situation:

    Code:
    {dedibox_t:system.cpu.util[,user,avg1].last(0)} > {dedibox_t:system.cpu.util[,idle,avg1].last(0)}
    Regards

    Comment

    • r3dn3ck
      Member
      • Jul 2008
      • 43

      #3
      you can also do the basic 4 function math with -+/* in place of the comparison operator.

      Comment

      • MarkusL
        Member
        • Nov 2008
        • 41

        #4
        Hi r3dn3ck!

        Do you know, if it´s possible to do math-functions within a comparison.

        F.e. I want to check Terminalserver-Load-Balancing. For that I could make two triggers:

        ({terminalserver1:active-sessions[].last(0)} +3) < {terminalserver2:active-sessions[].last(0)}

        ({terminalserver2:active-sessions[].last(0)} +3) < {terminalserver1:active-sessions[].last(0)}

        With that I would check: if on one terminalserver all sessions together +3 is still smaller than all active sessions on the other terminalserver, please report that. Loadbalancer should have max. 2 sessions more on one of the servers,... Otherwise loadbalancing is not ok.


        Thanks,
        kind regards,

        Markus.

        Comment

        • esimim2
          Junior Member
          • Nov 2018
          • 2

          #5
          To compare items in two different hosts you use the function "Last (most recent) T value is = N". Then in the constructor you edit the expression adding the item do the right:
          {host1:sequence.last()}>{host1:sequence.last()}+10
          King regards to the community,

          Eliandro.

          Comment

          • magrif
            Junior Member
            • Jan 2021
            • 1

            #6
            Hi everyone.
            What about some like: {host:logrt["/var/log/auth.log", "failed"].regexp("{host:system.run[echo User123].last()}")}=1? It's possible?
            Thanks!

            Comment

            Working...