32 lines
759 B
Python
32 lines
759 B
Python
import matplotlib.pyplot as plt
|
|
|
|
import matplotlib
|
|
import mysql.connector
|
|
matplotlib.use('tkAgg')
|
|
|
|
# mariadb
|
|
mariadbConnection = mysql.connector.connect(
|
|
host="server0", user="root", password="lungretter1", database="bandwidth")
|
|
mariadbCursor = mariadbConnection.cursor()
|
|
mariadbCursor.execute("SELECT times, ping, download, upload FROM speedtest")
|
|
mariadbResult = mariadbCursor.fetchall()
|
|
|
|
times = []
|
|
pings = []
|
|
downloads = []
|
|
uploads = []
|
|
|
|
for i in mariadbResult:
|
|
times.append(i[0])
|
|
pings.append(i[1])
|
|
downloads.append(i[2])
|
|
uploads.append(i[3])
|
|
|
|
# plot
|
|
plt.plot(times, pings, label="Ping")
|
|
plt.plot(times, downloads, label="Download")
|
|
plt.plot(times, uploads, label="Upload")
|
|
plt.legend()
|
|
plt.title("bandwidth from mariadb")
|
|
plt.show()
|