Beispiel #1
0
 def test_windowed_average_uses_correct_length(self):
     tests = [(1, 1), (1, 1), (4, 2), (6, 3.0), (1, 2.6),
              (3, 2.6666666666666665), (6, 3.142857142857143)]
     average = windowed_average()
     for (element, expected) in tests:
         rv = average.calculate(element)
         self.assertEquals(rv, expected)
Beispiel #2
0
 def __init__(self, window):
     self.historical_avg = windowed_average(window)
     self.avg = windowed_average(int(window / 3))
     self.value = 0
     self.historical_value = 0
     self.trend = 1
Beispiel #3
0
        # print 'trend: ' + str(trend)
        if trend > 1.6:
            return trend_icon['up']
        if trend > 1.2:
            return trend_icon['up-slightly']
        if trend <= 1.2 and trend >= 0.8:
            return trend_icon['flat']
        if trend < 0.8:
            return trend_icon['down-slightly']
        if trend < 0.2:
            return trend_icon['down']
        return '!'


window = 30
rtt_avg = windowed_average(window)
rtt_trend = trending(window)
pl_avg = windowed_average(window)
pl_trend = trending(window)
reset_timeout = int(window / 3)

failure_count = 0
count = 0


def update(line):
    out = ''
    packet_loss = 0.0
    result = parse_ping(line)
    if result['status'] == 'got-reply':
        avg = rtt_avg.calculate(float(result['time']))
Beispiel #4
0
 def test_windowed_average_uses_correct_length(self):
     tests = [(1, 1), (1, 1), (4, 2), (6, 3.0), (1, 2.6), (3, 2.6666666666666665), (6, 3.142857142857143)]
     average = windowed_average()
     for (element, expected) in tests:
         rv = average.calculate(element)
         self.assertEquals(rv, expected)
Beispiel #5
0
 def test_windowed_average_has_count(self):
     count = 10
     average = windowed_average()
     for element in range(0,count):
         average.calculate(element)
     self.assertEquals(average.count, count)
Beispiel #6
0
 def test_windowed_average(self):
     average = windowed_average(len(self.elements))
     rv = 0
     for element in self.elements:
         rv = average.calculate(element)
     self.assertEquals(rv, 4.714285714285714)
Beispiel #7
0
 def test_windowed_average_has_count(self):
     count = 10
     average = windowed_average()
     for element in range(0, count):
         average.calculate(element)
     self.assertEquals(average.count, count)
Beispiel #8
0
 def test_windowed_average(self):
     average = windowed_average(len(self.elements))
     rv = 0
     for element in self.elements:
         rv = average.calculate(element)
     self.assertEquals(rv, 4.714285714285714)
Beispiel #9
0
 def __init__(self, window):
   self.historical_avg = windowed_average(window)
   self.avg = windowed_average(int(window / 3))
   self.value = 0
   self.historical_value = 0
   self.trend = 1
Beispiel #10
0
    # print 'trend: ' + str(trend)
    if trend > 1.6:
      return trend_icon['up']
    if trend > 1.2:
      return trend_icon['up-slightly']
    if trend <= 1.2 and trend >= 0.8:
      return trend_icon['flat']
    if trend < 0.8:
      return trend_icon['down-slightly']
    if trend < 0.2:
      return trend_icon['down']
    return '!'
    
      
window = 30
rtt_avg = windowed_average(window)
rtt_trend = trending(window)
pl_avg = windowed_average(window)
pl_trend = trending(window)
reset_timeout = int(window / 3)

failure_count = 0
count = 0

def update(line):
  out = ''
  packet_loss = 0.0
  result = parse_ping(line)
  if result['status'] == 'got-reply':
    avg = rtt_avg.calculate(float(result['time']))