39 lines
780 B
Bash
39 lines
780 B
Bash
#!/bin/bash
|
|
|
|
function writeSqlite3 ()
|
|
{
|
|
# now import the csv data in to sqlite db
|
|
echo "write data to sqlite3"
|
|
sqlite3 -batch bandwidth.db <<"EOF"
|
|
.separator ","
|
|
.import speedtest.tmp bandwidth
|
|
EOF
|
|
}
|
|
|
|
function writeMariaDB ()
|
|
{
|
|
echo "write data to mariadb"
|
|
mariadb-import --host server0 --user root -plungretter1 --local --fields-terminated-by=',' bandwidth /home/sascha/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
|
|
writeSqlite3
|
|
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!"
|