Downgrade to Python 3.7 for Debian 10

This commit is contained in:
Peter J. Holzer 2022-09-27 12:30:45 +02:00
parent 3f6b306b30
commit a79aac5cfd
1 changed files with 6 additions and 2 deletions

View File

@ -24,15 +24,19 @@ now = time.time()
p = subprocess.run(["/bin/ping", "-c", "20", "-i", "0.2", "-n", args.hostname], capture_output=True, text=True)
report0 = []
for ln in p.stdout.split("\n")[:-1]:
if m := re.match(r"(\d+) packets transmitted, (\d+) received, (\d+)% packet loss", ln):
m = re.match(r"(\d+) packets transmitted, (\d+) received, (\d+)% packet loss", ln)
if m:
report0.append({ "measure": "ping_transmitted", "unit": "packets", "value": int(m.group(1)) })
report0.append({ "measure": "ping_received", "unit": "packets", "value": int(m.group(2)) })
report0.append({ "measure": "ping_loss", "unit": "%", "value": int(m.group(3)) })
elif m := re.match(r"rtt min/avg/max/mdev = ([0-9.]+)/([0-9.]+)/([0-9.]+)/([0-9.]+) ms", ln):
continue
m = re.match(r"rtt min/avg/max/mdev = ([0-9.]+)/([0-9.]+)/([0-9.]+)/([0-9.]+) ms", ln)
if m:
report0.append({ "measure": "ping_min_rtt", "unit": "s", "value": float(m.group(1)) / 1000 })
report0.append({ "measure": "ping_avg_rtt", "unit": "s", "value": float(m.group(2)) / 1000 })
report0.append({ "measure": "ping_max_rtt", "unit": "s", "value": float(m.group(3)) / 1000 })
report0.append({ "measure": "ping_mdev_rtt", "unit": "s", "value": float(m.group(4)) / 1000 })
continue
if len(report0) != 7:
print("Partial results:", report0)