Handle empty ping response

This commit is contained in:
Santiago L 2021-05-17 13:22:08 +02:00
parent 3b4bb51925
commit b24ddf7546
1 changed files with 6 additions and 1 deletions

View File

@ -14,7 +14,12 @@ def retrieve_state(servers):
state = {}
for server, ping, uptime in zip(servers, pings, uptimes):
ping = join(ping, silent=True)
ping = ping.stdout.splitlines()[-1].decode()
try:
ping = ping.stdout.splitlines()[-1].decode()
except IndexError:
ping = ''
if ping.startswith('rtt'):
ping = '%s ms' % ping.split('/')[4]
else: