def aggregator(es): db = DBManager() while True: time.sleep(1) for (endhost, burstid), burst in es.sent_echos.items(): try: #check for a valid burst with time expired if not valid_burst(burst): continue rtt = [packet['rtt'] for packet in burst if packet['rtt'] is not None] es.del_sent_echo(endhost, burstid) #100% loss. end host is probably dead if len(rtt) == 0: es.delete_targets(endhost, burst[0]['through']) continue latency = numpy.average(rtt) jitter = numpy.std(rtt) loss = float((BURST_SIZE - len(rtt)) / BURST_SIZE) * 100 db.store_rtt(endhost, str(burst[0]['through'].id_), latency, jitter, loss, time.gmtime(burst[0]['sent_at'])) except Exception, e: print e