Mercurial > ~darius > hgwebdir.cgi > adslstats
comparison speedcheck.py @ 39:1a87c79cf103
Handle new ping which does IPv6 (and spells stddev as std-dev!)
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 04 Jul 2022 13:18:58 +0930 |
parents | 815e6b61d76e |
children | 947fa4062b01 |
comparison
equal
deleted
inserted
replaced
38:6f85bedf9966 | 39:1a87c79cf103 |
---|---|
78 stdout, stderr = p.communicate() | 78 stdout, stderr = p.communicate() |
79 l = stdout.decode('ascii', 'ignore').split('\n') | 79 l = stdout.decode('ascii', 'ignore').split('\n') |
80 if len(l) != 6: | 80 if len(l) != 6: |
81 print('Unable to parse ping line:', l) | 81 print('Unable to parse ping line:', l) |
82 xx, xx, xx, plossline, latline, xx = l | 82 xx, xx, xx, plossline, latline, xx = l |
83 ploss = float(re.match('.* received, ([0-9.]+)% packet loss', plossline).groups()[0]) | 83 ploss = re.match('.* received, ([0-9.]+)% packet loss', plossline) |
84 latency = float(re.match('.*stddev = [0-9.]+/([0-9.]+)/.* ms', latline).groups()[0]) | 84 if ploss is not None: |
85 ploss = float(ploss.groups()[0]) | |
86 latency = re.match('.*std-?dev = [0-9.]+/([0-9.]+)/.* ms', latline) | |
87 if latency is not None: | |
88 latency = float(latency.groups()[0]) | |
85 return ploss, latency | 89 return ploss, latency |
86 | 90 |
87 def createrrd(rrdname): | 91 def createrrd(rrdname): |
88 # Create RRD for upstream/downstream speed, packet loss and | 92 # Create RRD for upstream/downstream speed, packet loss and |
89 # latency for near and far site | 93 # latency for near and far site |