tor_multipath_voip/scripts/links_parse.py

13 lines
328 B
Python
Executable file

#!/usr/bin/python3
import sys,re
print("run,ts,link_id,status")
for line in sys.stdin:
res = re.match(r"\[(\d+)\] Blacklisted links: ([_U]+)", line)
if not res: continue
ts,l = res.groups()
l2 = [(i, 'up' if l[i] == "U" else 'down') for i in range(len(l))]
for i,v in l2:
print(f"{sys.argv[1]},{ts},{i},{v}")