blob: 4e1f6b8aaf727a243d8e0367739304a1b08e26c6 [file] [log] [blame]
adminf73f0512013-12-17 16:33:37 -08001#! /usr/bin/env python
2import sys
3import time
4import os
5import re
6import json
7
8
9CONFIG_FILE="/home/admin/ping.h10"
10
11
12
13def get_times(pingfile):
14 icmp_reqs = []
15 times = []
16 f = open(pingfile)
17 for line in f.readlines():
18 if re.search('64\sbytes', line):
19 icmp_reqs.append( (line.split()[4]).split('=')[1] )
20 f.close()
21 #print icmp_reqs
22 lastnum = int(icmp_reqs[0]) - 1
23 for num in icmp_reqs:
24 if int(num) != (lastnum + 1):
25 times.append(int(num) - lastnum)
26 lastnum = int(num)
27
28 return times
29
30if __name__ == "__main__":
31 total = 0
32 count = 0
33 flow = 1
34 for i in os.popen("ls /tmp/ping.*"):
35 print "Flow %d " % flow
36 for time in get_times(i.strip("\n")):
37 total = total + time
38 count = count + 1
39 print " %d" % time
40 flow = flow + 1
41 print "Average: %d" % (total / count )
42