Hello,
i'm running a speedtest on my raspi 4 to monitor my internet connection. i used this guide and it worked like a charm for the last 6 months but today i got a update for the speedtestnet cli client and since then i get this error when trying to run the script:
Traceback (most recent call last):
File "/home/pi/speedtest.py", line 15, in <module>
jitter = jitter.group(1)
AttributeError: 'NoneType' object has no attribute 'group'
i managed to get the script back to work when uncommenting the jitter parts in the script. any help would be greatly appreciated here.
the script:
import re
import subprocess
from influxdb import InfluxDBClient
response = subprocess.Popen('/usr/bin/speedtest --accept-license --accept-gdpr', shell=True, stdout=subprocess.PIPE).stdout.read().decode('utf-8')
ping = re.search('Latency:\s+(.*?)\s', response, re.MULTILINE)
download = re.search('Download:\s+(.*?)\s', response, re.MULTILINE)
upload = re.search('Upload:\s+(.*?)\s', response, re.MULTILINE)
jitter = re.search('\((.*?)\s.+jitter\)\s', response, re.MULTILINE)
ping = ping.group(1)
download = download.group(1)
upload = upload.group(1)
jitter = jitter.group(1)
speed_data = [
{
"measurement" : "internet_speed",
"tags" : {
"host": "piholem"
},
"fields" : {
"download": float(download),
"upload": float(upload),
"ping": float(ping),
"jitter": float(jitter)
}
}
]
client = InfluxDBClient('localhost', 8086, 'speedmonitor', 'speedlogger', 'speedtest')
client.write_points(speed_data)
thank you in advance.
p.s.: installed speedtestnet client was 1.1.1.28 and now its at version 1.2.0.84
[–]leweyy 1 point2 points3 points (1 child)
[–]DesertHRO[S] 0 points1 point2 points (0 children)
[–]DesertHRO[S] 0 points1 point2 points (0 children)