Added Sharable link to calibrate speedtest results in grafana (Idk what unit the script is returing speed as)
This commit is contained in:
parent
b272f717ca
commit
2f4829466d
19
main.py
19
main.py
@ -8,7 +8,7 @@ serverport = 8086
|
||||
serverdatabase = "telegraf"
|
||||
servernickname = 'PythonSpeedtest'
|
||||
|
||||
def speed(): # To be called on schedule
|
||||
def speed(): # Actual Speedtest using speedtest-cli
|
||||
servers = [] # If you want to test against a specific server
|
||||
threads = 4
|
||||
# Choose the amount of threads to use for the test
|
||||
@ -22,20 +22,15 @@ def speed(): # To be called on schedule
|
||||
results = test.results.dict()
|
||||
|
||||
|
||||
resultlist = []
|
||||
result = {}
|
||||
result["UploadSpeed"] = results["upload"]
|
||||
result["DownloadSpeed"] = results["download"]
|
||||
result["Ping"] = results["ping"]
|
||||
|
||||
print(result)
|
||||
print(results["share"]) # Show share link
|
||||
return(result)
|
||||
|
||||
def influxupload(): # Still having errors in uploading the data..
|
||||
pass
|
||||
# client = InfluxDBClient(host=serverip, port=8086, database=serverdatabase)
|
||||
# client.write_points(jsondata, tags=None )
|
||||
def main(host='192.168.0.13', port=8086):
|
||||
def uploadInfluxdata(host='192.168.0.13', port=8086): # Main upload section
|
||||
query = 'select Float_value from cpu_load_short;'
|
||||
query_where = 'select Int_value from cpu_load_short where host=$host;'
|
||||
bind_params = {'host': servernickname}
|
||||
@ -55,9 +50,7 @@ def main(host='192.168.0.13', port=8086):
|
||||
}
|
||||
]
|
||||
#"time": "2009-11-10T23:00:00Z",
|
||||
client = InfluxDBClient(host, port, database = serverdatabase)
|
||||
|
||||
client.write_points(json_body)
|
||||
client = InfluxDBClient(host, port, database = serverdatabase) # Init connection to Influx Server
|
||||
client.write_points(json_body) # Write Speedtest results
|
||||
|
||||
# influxupload()
|
||||
main()
|
||||
uploadInfluxdata()
|
||||
Reference in New Issue
Block a user