Adjust speedtesting, add minimum speed
parent
5def4bad74
commit
e3b07d0947
|
|
@ -134,3 +134,5 @@ data/database.db
|
||||||
secrets.yaml
|
secrets.yaml
|
||||||
test.py
|
test.py
|
||||||
test.png
|
test.png
|
||||||
|
data/database.db-shm
|
||||||
|
data/database.db-wal
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,12 @@ ros_queues:
|
||||||
- WAN
|
- WAN
|
||||||
ros_du_invert: False
|
ros_du_invert: False
|
||||||
ros_fasttrack_comment: "defconf: fasttrack"
|
ros_fasttrack_comment: "defconf: fasttrack"
|
||||||
|
# Minimum speed which not to cross, if speed is lower than this it will set this speed
|
||||||
|
ros_minimum_speed: 300000
|
||||||
|
# Speed at which to leave fasttrack on. Use if your ROS device's CPU can't handle max speed you get, for example LHG LTE
|
||||||
|
# starts to show high CPU usage at close to 20mbit.
|
||||||
|
# Not implemented yet
|
||||||
|
ros_maximum_speed: 15000000 # 15 mbit
|
||||||
|
|
||||||
|
|
||||||
|
# Conversion rate 1 mbit : 1000000 bits
|
||||||
|
|
@ -111,22 +111,7 @@ def ros_dynamic_speed(upload, download):
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def speedtest():
|
||||||
'''
|
|
||||||
This script will run a few speed tests, calculate average upload and download speeds and record them into database.
|
|
||||||
Once finished it will also generate an image with graph plotted.
|
|
||||||
'''
|
|
||||||
|
|
||||||
# generate_plot_image(*gather_data())
|
|
||||||
# import sys
|
|
||||||
# sys.exit()
|
|
||||||
from random import uniform
|
|
||||||
|
|
||||||
try:
|
|
||||||
if config["ros_dynamic_speed"]:
|
|
||||||
ros_fastrack_enable(True)
|
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
import speedtest
|
import speedtest
|
||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
|
|
@ -144,24 +129,49 @@ if __name__ == "__main__":
|
||||||
s.upload(threads=threads, pre_allocate=False)
|
s.upload(threads=threads, pre_allocate=False)
|
||||||
|
|
||||||
results_dict = s.results.dict()
|
results_dict = s.results.dict()
|
||||||
|
|
||||||
|
if results_dict['download'] >= config['ros_minimum_speed']:
|
||||||
download = round(results_dict['download'] / 1000000, 2)
|
download = round(results_dict['download'] / 1000000, 2)
|
||||||
upload = round(results_dict['upload'] / 1000000, 2)
|
upload = round(results_dict['upload'] / 1000000, 2)
|
||||||
# download = uniform(0,2)
|
|
||||||
# upload = uniform(0,2)
|
|
||||||
break
|
break
|
||||||
|
time.sleep(10)
|
||||||
except:
|
except:
|
||||||
log.error(f"Test failed, try {i + 1}/3", exc_info=True)
|
log.error(f"Test failed, try {i + 1}/3", exc_info=True)
|
||||||
|
|
||||||
log.debug(f"{download}mbps, {upload}mbps")
|
log.debug(f"{download}mbps, {upload}mbps")
|
||||||
|
return download, upload, results_dict
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
'''
|
||||||
|
This script will run a few speed tests, calculate average upload and download speeds and record them into database.
|
||||||
|
Once finished it will also generate an image with graph plotted.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# generate_plot_image(*gather_data())
|
||||||
|
# import sys
|
||||||
|
# sys.exit()
|
||||||
|
from random import uniform
|
||||||
|
|
||||||
|
try:
|
||||||
|
if config["ros_dynamic_speed"]:
|
||||||
|
ros_fastrack_enable(True)
|
||||||
|
time.sleep(5)
|
||||||
|
|
||||||
|
download, upload, results_dict = speedtest()
|
||||||
|
|
||||||
entry = Entry()
|
entry = Entry()
|
||||||
entry.upload = upload
|
entry.upload = upload
|
||||||
entry.download = download
|
entry.download = download
|
||||||
entry.save()
|
entry.save()
|
||||||
|
|
||||||
|
ros_upload = results_dict['upload']
|
||||||
|
ros_download = results_dict['download']
|
||||||
|
|
||||||
|
if ros_download < config['ros_minimum_speed']:
|
||||||
|
ros_download = config['ros_minimum_speed']
|
||||||
|
|
||||||
if config["ros_dynamic_speed"]:
|
if config["ros_dynamic_speed"]:
|
||||||
ros_dynamic_speed(results_dict['upload'], results_dict['download'])
|
ros_dynamic_speed(results_dict['upload'], results_dict['download'])
|
||||||
|
|
||||||
ros_fastrack_enable(False)
|
ros_fastrack_enable(False)
|
||||||
|
|
||||||
dates, downloads, uploads = gather_data()
|
dates, downloads, uploads = gather_data()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue