[quagga] Patch the previous script (squash)
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing

This commit is contained in:
shirenn 2021-02-04 17:32:58 +01:00
parent ada5c64293
commit ecfd7037c2

View file

@ -18,7 +18,7 @@ def parse_bgp_summary(summary):
res['routes'] = int(match.group('routes'))
uptime = match.group('uptime')
if re.fullmatch(r'[0-9]+:[0-9]+:[0-9]+', uptime) is not None:
uptime = line[8].split(':')
uptime = uptime.split(':')
uptime = int(uptime[0])*3600 + int(uptime[1])*60 + int(uptime[2])
else:
uptime_match = re.fullmatch(r'([0-9]+)d([0-9]+)h([0-9]+)m', uptime)
@ -38,8 +38,8 @@ def parse_bgp_summary(summary):
return res
def prompt(version='ipv4'):
summary = subprocess.run(['/usr/bin/vtysh', '-c', f'show bgp {version} unicast summary'], capture_output=True).stdout.decode('utf-8')
bgp_routes_uptime = parse_bgp_summary(bgp_ipv4_unicast_summary)
bgp_unicast_summary = subprocess.run(['/usr/bin/vtysh', '-c', f'show bgp {version} unicast summary'], capture_output=True).stdout.decode('utf-8')
bgp_routes_uptime = parse_bgp_summary(bgp_unicast_summary)
routes = bgp_routes_uptime['routes']
uptime = bgp_routes_uptime['uptime']
print(f'# HELP quagga_bgp_{version}_routes Number of {version} routes added by quagga')