コード例 #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)
コード例 #2
0
ファイル: check.py プロジェクト: jpf/network-status
 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
コード例 #3
0
ファイル: check.py プロジェクト: jpf/network-status
        # 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']))
コード例 #4
0
ファイル: test_avg.py プロジェクト: jpf/network-status
 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)
コード例 #5
0
ファイル: test_avg.py プロジェクト: jpf/network-status
 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)
コード例 #6
0
ファイル: test_avg.py プロジェクト: jpf/network-status
 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)
コード例 #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)
コード例 #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)
コード例 #9
0
ファイル: check.py プロジェクト: jpf/network-status
 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
コード例 #10
0
ファイル: check.py プロジェクト: jpf/network-status
    # 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']))