-
Notifications
You must be signed in to change notification settings - Fork 12
/
speedtest.sh
executable file
·35 lines (31 loc) · 1.18 KB
/
speedtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#/bin/bash
#When you have Installed the speedtest-cli via apt use this code
#vf=$(speedtest --simple --server 4617)
#When you have use the binary like the Readme Discribe use this line of Code
work_dir="`pwd`"
script_dir="`dirname $0`"; cd "${script_dir}"; script_dir="`pwd`"
cd "${work_dir}"
# When no connection, this is practically equivalent to an infinite ping
# and nul speeds
no_connection="999.0;0.0;0.0"
#old version
#vf=$(speedtest-cli --simple --server 4617)
#new version because of https://github.com/Wlanfr3ak/auto-speedtest/issues/5
#vf=$(/usr/local/bin/speedtest --simple --server 4617) <-- Server ID is outdated :-(
vf=$(/usr/local/bin/speedtest --simple)
#ip=$(wget http://checkip.dyndns.org/ -q -O - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>')
echo $ip
DATE=$(date +"%Y-%m-%d")
TIME=$(date +"%H:%M:%S")
IN=$(echo $vf)
SPEED=$(echo $IN | tr "[:alpha:]+[/:]" "\n")
OUT="${DATE} ${TIME} ${SPEED}"
vf2=$(echo ${OUT} | tr ' ' ';')
ping=$(echo "${vf2}" | cut -d';' -f3)
# If this field is empty, assume no connection:
if [ "${ping}" = "" ]; then
vf2="${vf2};${no_connection}"
fi
echo "${vf2}" >> "${script_dir}/`hostname -s`-${DATE}.csv"
#DisplayOutpum
#mython3 display.py $OUT