Ad Widget

Collapse

Last(#2) or sum(#2) ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kai-Kai
    Senior Member
    • Apr 2009
    • 142

    #1

    Last(#2) or sum(#2) ?

    Hello.

    I want to make a trigger which test twice the disponibility of a webpage before displaying alert.
    When the web is ok, the item "failed step" is on 0.

    So my question is, is the right trigger :
    ***.last(#2)#0
    or
    ***.sum(#2)>1
    ?

    I don't really see if last(#2)#0 test if ONE OF the 2 last values is different from 0, or if THE TWO last values are both different from 0 ?
    If it's the first, I have to use sum to do what I want...

    When I test, it seems to wait to receive 2 bad values to go in alert, but, when it receives a good one, it seems to stay in alert during a few time... I'm not sur I've right understood the way last() works...

    Thanks in advance.
    Last edited by Kai-Kai; 16-07-2009, 16:40. Reason: Problem solved.
  • Kai-Kai
    Senior Member
    • Apr 2009
    • 142

    #2
    After reading the documentation again and making more tests... I think I've misunderstood the way last works...

    In fact last(#2) mean the value before the last one, last(#3) the value before last(#2) etc...

    So, I think the way to do what I want is sum(#2)>1 isn't it ?
    Last edited by Kai-Kai; 03-07-2009, 13:16.

    Comment

    • Calimero
      Senior Member
      • Nov 2006
      • 481

      #3
      There's also .count() that allows you to... count how many times you got value X over the last #N checks or the last T seconds.

      .sum() is fine as long as you only have 0 or 1 as a return value. But some of the simple checks return 0 for failure, 1 for success and 2 for timeout. So .sum() is not appropriate on such items.

      Comment

      • Kai-Kai
        Senior Member
        • Apr 2009
        • 142

        #4
        Yeah, you're right... I haven't thought about count() before.
        It's effectively a good way to do that.

        In my case, I can use count or sum, but in cases where the value is another number than 0 or 1, count is effectively a better solution.

        The use of count with a third parameter is good here. Something like :
        ***.count(#2,0,"gt")>1
        will count the number of values greater than 0 in the 2 last values. I think it will give the same result than sum in this case.

        Thanks again for your answer.
        (You really have the answer to all of my questions ^^)

        Comment

        Working...