exec
parent
cfc190f147
commit
b900373cd5
@ -1,57 +1,57 @@
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import mysql.connector
|
import mysql.connector
|
||||||
|
|
||||||
|
|
||||||
def Average(lst):
|
def Average(lst):
|
||||||
return sum(lst) / len(lst)
|
return sum(lst) / len(lst)
|
||||||
|
|
||||||
|
|
||||||
# mariadb
|
# mariadb
|
||||||
mariadbConnection = mysql.connector.connect(
|
mariadbConnection = mysql.connector.connect(
|
||||||
host="woitschetzki.de", port="3306", user="root", password="lungretter1", database="bandwidth")
|
host="woitschetzki.de", port="3306", user="root", password="lungretter1", database="bandwidth")
|
||||||
mariadbCursor = mariadbConnection.cursor()
|
mariadbCursor = mariadbConnection.cursor()
|
||||||
mariadbCursor.execute("SELECT times, ping, download, upload FROM speedtest")
|
mariadbCursor.execute("SELECT times, ping, download, upload FROM speedtest")
|
||||||
mariadbResult = mariadbCursor.fetchall()
|
mariadbResult = mariadbCursor.fetchall()
|
||||||
|
|
||||||
times = []
|
times = []
|
||||||
pings = []
|
pings = []
|
||||||
downloads = []
|
downloads = []
|
||||||
uploads = []
|
uploads = []
|
||||||
sum_ping = 0.0
|
sum_ping = 0.0
|
||||||
|
|
||||||
for i in mariadbResult:
|
for i in mariadbResult:
|
||||||
times.append(i[0])
|
times.append(i[0])
|
||||||
pings.append(i[1])
|
pings.append(i[1])
|
||||||
downloads.append(i[2])
|
downloads.append(i[2])
|
||||||
uploads.append(i[3])
|
uploads.append(i[3])
|
||||||
|
|
||||||
print("i = ", len(times))
|
print("i = ", len(times))
|
||||||
print("avg ping = ", Average(pings), "ms")
|
print("avg ping = ", Average(pings), "ms")
|
||||||
print("avg download = ", Average(downloads) / 1000000, "mbit/s")
|
print("avg download = ", Average(downloads) / 1000000, "mbit/s")
|
||||||
print("avg upload = ", Average(uploads) / 1000000, "mbit/s")
|
print("avg upload = ", Average(uploads) / 1000000, "mbit/s")
|
||||||
|
|
||||||
# plotall
|
# plotall
|
||||||
plt.plot(times, pings, label="Ping")
|
plt.plot(times, pings, label="Ping")
|
||||||
plt.plot(times, downloads, label="Download")
|
plt.plot(times, downloads, label="Download")
|
||||||
plt.plot(times, uploads, label="Upload")
|
plt.plot(times, uploads, label="Upload")
|
||||||
plt.title("bandwidth from mariadb")
|
plt.title("bandwidth from mariadb")
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
# plotping
|
# plotping
|
||||||
#plt.plot(times, pings, label="Ping")
|
#plt.plot(times, pings, label="Ping")
|
||||||
#plt.title("pings from mariadb")
|
#plt.title("pings from mariadb")
|
||||||
#plt.legend()
|
#plt.legend()
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|
||||||
# plotdownloads
|
# plotdownloads
|
||||||
#plt.plot(times, downloads, label="Download")
|
#plt.plot(times, downloads, label="Download")
|
||||||
#plt.title("downloads from mariadb")
|
#plt.title("downloads from mariadb")
|
||||||
#plt.legend()
|
#plt.legend()
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|
||||||
# plotuploads
|
# plotuploads
|
||||||
#plt.plot(times, uploads, label="Upload")
|
#plt.plot(times, uploads, label="Upload")
|
||||||
#plt.title("uploads from mariadb")
|
#plt.title("uploads from mariadb")
|
||||||
#plt.legend()
|
#plt.legend()
|
||||||
#plt.show()
|
#plt.show()
|
||||||
|
|||||||
Loading…
Reference in New Issue