add single plots foreach

master
DJh2o2 2022-08-18 10:24:40 +07:00
commit ad60a7f77f
1 changed files with 57 additions and 39 deletions

@ -8,7 +8,7 @@ def Average(lst):
# mariadb # mariadb
mariadbConnection = mysql.connector.connect( mariadbConnection = mysql.connector.connect(
host="server0", user="root", password="lungretter1", database="bandwidth") host="server0", 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()
@ -30,10 +30,28 @@ 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")
# plot # 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.legend()
plt.title("bandwidth from mariadb") plt.title("bandwidth from mariadb")
plt.legend()
plt.show()
# plotping
plt.plot(times, pings, label="Ping")
plt.title("pings from mariadb")
plt.legend()
plt.show()
# plotdownloads
plt.plot(times, downloads, label="Download")
plt.title("downloads from mariadb")
plt.legend()
plt.show()
# plotuploads
plt.plot(times, uploads, label="Upload")
plt.title("uploads from mariadb")
plt.legend()
plt.show() plt.show()