master
Sascha 2022-08-10 19:09:53 +07:00
parent c40f378a55
commit 735465ba31
2 changed files with 66 additions and 66 deletions

@ -1,39 +1,39 @@
import matplotlib.pyplot as plt
import mysql.connector
def Average(lst):
return sum(lst) / len(lst)
# 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 = []
sum_ping = 0.0
for i in mariadbResult:
times.append(i[0])
pings.append(i[1])
downloads.append(i[2])
uploads.append(i[3])
print("i = ", len(times))
print("avg ping = ", Average(pings), " ms")
print("avg download = ", Average(downloads) / 1000000, " mbit/s")
print("avg upload = ", Average(uploads) / 1000000, " mbit/s")
# 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()
import matplotlib.pyplot as plt
import mysql.connector
def Average(lst):
return sum(lst) / len(lst)
# 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 = []
sum_ping = 0.0
for i in mariadbResult:
times.append(i[0])
pings.append(i[1])
downloads.append(i[2])
uploads.append(i[3])
print("i = ", len(times))
print("avg ping = ", Average(pings), " ms")
print("avg download = ", Average(downloads) / 1000000, " mbit/s")
print("avg upload = ", Average(uploads) / 1000000, " mbit/s")
# 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()

@ -1,27 +1,27 @@
#!/bin/bash
function writeMariaDB ()
{
echo "write data to mariadb"
mariadb-import --host server0 --user root -plungretter1 --local --fields-terminated-by=',' bandwidth speedtest.tmp
}
function runTest ()
{
# run speedtest against named server with csv output saved in tmp file
echo "running speedtest-cli"
speedtest-cli --secure --csv > speedtest.tmp
bat speedtest.tmp
# write output to db
writeMariaDB
# write output to csv
echo "write data to csv"
cat speedtest.tmp >> speedtest.csv
}
# main
echo "bandwidth V0.1 by DJh2o2"
runTest
echo "Ready!"
#!/bin/bash
function writeMariaDB ()
{
echo "write data to mariadb"
mariadb-import --host server0 --user root -plungretter1 --local --fields-terminated-by=',' bandwidth speedtest.tmp
}
function runTest ()
{
# run speedtest against named server with csv output saved in tmp file
echo "running speedtest-cli"
speedtest-cli --secure --csv > speedtest.tmp
bat speedtest.tmp
# write output to db
writeMariaDB
# write output to csv
echo "write data to csv"
cat speedtest.tmp >> speedtest.csv
}
# main
echo "bandwidth V0.1 by DJh2o2"
runTest
echo "Ready!"