Last active
August 29, 2015 14:02
-
-
Save aeickho/2ddf949389689e1c84c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
url[0]="ftp://ftp5.gwdg.de/pub/linux/debian/debian/dists/wheezy/main/binary-i386/Packages.gz"; | |
url[1]="http://debian.morphium.info/debian/dists/wheezy/main/binary-i386/Packages.gz"; | |
url[2]="ftp://ftp.debian.com/debian/dists/wheezy/main/binary-i386/Packages.gz"; | |
kn="12345" # hier die Kundennummer eintragen | |
tn="" # und hier die Telefon Nummer | |
sleeptime=600 | |
echo " | |
set datafile separator \"\t\";\ | |
set timefmt \"%Y-%m-%d %H:%M:%S\"; | |
set xdata time; | |
set format x \"%d.%m\\n%H:%M:%S\"; | |
set output \"out.png\"; | |
set terminal png size 1024,800; | |
set key bmargin font \",8\"; | |
set ylabel \"Download Speed [MB/s]\" | |
set title \"Kundennummer: $kn / Rufnummer $tn\\nDownload Bandbreitenmessung\" | |
set datafile missing \"\"; | |
" > p.gnuplot | |
echo -n "plot " >> p.gnuplot | |
for (( i=0;i<${#url[@]};i++)) | |
do | |
echo -n "\"speed-log.csv\" using 1:(\$$(($i+2))) ti \"${url[$i]}\"" >> p.gnuplot | |
if (( $i<${#url[@]}-1 )); then echo ",\\" >> p.gnuplot ; fi | |
done | |
echo >>p.gnuplot | |
while [ true ]; | |
do | |
for (( n=0;n<${#url[@]};n++)) | |
do | |
for (( i=0;i<${#a[@]};i++)) | |
do | |
s[$i]=""; | |
done | |
echo Check N: $n ${url[$n]} | |
a=(`LC_ALL=C wget -4 -O /dev/null ${url[$n]} 2>&1 | tail -n2`) | |
date=`echo ${a[0]} ${a[1]}` | |
speed=`echo ${a[2]:1}` | |
unit=`echo ${a[3]:0:4}` | |
# double bibyte = 1000.0; // wget.. src/retr.c | |
if [ "$unit" == "KB/s" ]; | |
then | |
speedx=`echo "scale=2; $speed * 1000"| bc`; | |
elif [ "$unit" == "MB/s" ]; | |
then | |
speedx=`echo "scale=2; $speed * 1000000" | bc`; | |
fi | |
s[$n]=`echo "scale=2; $speedx / 1000000"| bc`; | |
echo -e -n "$date" >> speed-log.csv | |
for (( i=0;i<${#url[@]};i++)) | |
do | |
echo -e -n "\t${s[$i]}" >> speed-log.csv | |
done | |
echo "" >> speed-log.csv | |
done | |
gnuplot p.gnuplot | |
sleep $sleeptime | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment