Closed beastyrabbit closed 2 years ago
It is added when the first test runs.
Try
sudo /var/www/html/admin/scripts/pi-hole/speedtest/speedtest-official.sh
#!/bin/bash
start=$(date +"%Y-%m-%d %H:%M:%S")
readonly setupVars="/etc/pihole/setupVars.conf"
serverid=$(sed -n -e '/SPEEDTEST_SERVER/ s/.*\= *//p' $setupVars)
echo "Testing with ${serverid}"
function nointernet(){
sqlite3 /etc/pihole/speedtest.db "insert into speedtest values (NULL, '${start}', '${stop}', 'No Internet', '-', '$ exit
}
if [[ "$serverid" =~ ^[0-9]+$ ]]; then
/usr/bin/speedtest -s $serverid --accept-gdpr --accept-license -f json-pretty > /tmp/speedtest.log || nointernet
else
/usr/bin/speedtest --accept-gdpr --accept-license -f json-pretty > /tmp/speedtest.log || nointernet
fi
FILE=/tmp/speedtest.log
if [[ -f "$FILE" ]]; then
/usr/bin/speedtest -s $serverid --accept-gdpr --accept-license -f json-pretty > /tmp/speedtest.log || nointernet
else
/usr/bin/speedtest --accept-gdpr --accept-license -f json-pretty > /tmp/speedtest.log || nointernet
fi
FILE=/tmp/speedtest.log
if [[ -f "$FILE" ]]; then
stop=$(date +"%Y-%m-%d %H:%M:%S")
download=`cat /tmp/speedtest.log| jq -r '.download.bandwidth' | awk '{$1=$1*8/1000/1000; print $1;}'`
upload=`cat /tmp/speedtest.log| jq -r '.upload.bandwidth' | awk '{$1=$1*8/1000/1000; print $1;}'`
server_name=`cat /tmp/speedtest.log| jq -r '.server.name'`
isp=`cat /tmp/speedtest.log| jq -r '.isp'`
server_ip=`cat /tmp/speedtest.log| jq -r '.server.ip'`
from_ip=`cat /tmp/speedtest.log| jq -r '.interface.externalIp'`
server_ping=`cat /tmp/speedtest.log| jq -r '.ping.latency'`
share_url=`cat /tmp/speedtest.log| jq -r '.result.url'`
server_dist=0
rm /tmp/speedtest.log
sep="\t"
quote=""
opts=
# Output CSV results
sep="$quote$sep$quote"
printf "$quote$start$sep$stop$sep$isp$sep$from_ip$sep$server_name$sep$server_dist$sep$server_ping$sep$download$sep$$
sqlite3 /etc/pihole/speedtest.db "insert into speedtest values (NULL, '${start}', '${stop}', '${isp}', '${from_ip}$fi
Thats the Script on my RPI and i don't think it is in there. To COPY the DB.
I tryed running the script multiple Times always the Error
Error: no such table: speedtest
Thanks for letting me know.
Copy database code was in the run speedtest now command pihole -a -sn
. I have copied it to the Install section of Wiki.
Hi, after following your install instructions i got an Error when testing
Error: no such table: speedtest
After looking through your script and instructions i think i found the Error. In the install.sh your are moving the speedtest.db from /admin/scripts/pi-hole/speedtest to /etc/pihole/
This step is missing from the install instructions.
Regards Tobi