removed bit conversions, forced packet loss to int

This commit is contained in:
breadlysm 2020-07-20 21:19:36 -04:00
parent ec879c7029
commit 1ef2c6e9f8

View file

@ -47,7 +47,7 @@ def format_for_influx(cliout):
'time': data['timestamp'], 'time': data['timestamp'],
'fields': { 'fields': {
# Byte to Megabit # Byte to Megabit
'bandwidth': data['download']['bandwidth'] / 125000, 'bandwidth': data['download']['bandwidth'], #/125000
'bytes': data['download']['bytes'], 'bytes': data['download']['bytes'],
'elapsed': data['download']['elapsed'] 'elapsed': data['download']['elapsed']
} }
@ -57,7 +57,7 @@ def format_for_influx(cliout):
'time': data['timestamp'], 'time': data['timestamp'],
'fields': { 'fields': {
# Byte to Megabit # Byte to Megabit
'bandwidth': data['upload']['bandwidth'] / 125000, 'bandwidth': data['upload']['bandwidth'], #/125000
'bytes': data['upload']['bytes'], 'bytes': data['upload']['bytes'],
'elapsed': data['upload']['elapsed'] 'elapsed': data['upload']['elapsed']
} }
@ -66,7 +66,7 @@ def format_for_influx(cliout):
'measurement': 'packetLoss', 'measurement': 'packetLoss',
'time': data['timestamp'], 'time': data['timestamp'],
'fields': { 'fields': {
'packetLoss': data['packetLoss'] 'packetLoss': int(data['packetLoss'])
} }
} }
] ]
@ -81,6 +81,7 @@ def main():
speedtest = subprocess.run( speedtest = subprocess.run(
["speedtest", "--accept-license", "--accept-gdpr", "-f", "json"], capture_output=True) ["speedtest", "--accept-license", "--accept-gdpr", "-f", "json"], capture_output=True)
if speedtest.returncode == 0: # Speedtest was successful.
if speedtest.returncode == 0: # Speedtest was successful. if speedtest.returncode == 0: # Speedtest was successful.
data = format_for_influx(speedtest.stdout) data = format_for_influx(speedtest.stdout)
print("Speedtest Successful:") print("Speedtest Successful:")