User Tools

Site Tools


creating_the_speedtest_image_every_day

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
creating_the_speedtest_image_every_day [2024/02/23 17:09] stevecreating_the_speedtest_image_every_day [2025/01/16 23:06] (current) steve
Line 1: Line 1:
 ==== Creating the SpeedTest image every day ==== ==== Creating the SpeedTest image every day ====
-So, I like to see how much I'm getting for my $52 per month, so I wrote this script a long time ago to track upload, download and delay numbers across my Internet connection.+So, I like to see how much I'm getting for my $62 per month, so I wrote this script a long time ago to track upload, download and delay numbers across my Internet connection
 + 
 +It uses the node.js fast-cli script by Sindre Sorhus from [[https://github.com/sindresorhus/fast-cli|here]] or installed with ''%% npm install --global fast-cli %%''.
  
 First, there are two scripts in /usr/local/bin; First, there are two scripts in /usr/local/bin;
 One, in bash script; One, in bash script;
 <code bash SpeedTest> <code bash SpeedTest>
-#!/usr/bin/bash+#!/bin/bash
 # /usr/local/bin/SpeedTest # /usr/local/bin/SpeedTest
 # Quick and simple log file of connection speed tests # Quick and simple log file of connection speed tests
-# SRJ 2016-12-26 +# SRJ 2016-12-26 
-YM=$(date +%Y-%m) # 2019-07 +# In crontab; 
-MT=$(date -d "+6 hours" +%Y-%m) # Could be 2019-08 if this is the last of the month +# 09 */6 * * * /usr/local/bin/SpeedTest 
- +YM=$(date +%Y-%m) MT=$(date -d "+6 hours" +%Y-%m)
-# Where we store data+
 Log=~/.SpeedTest.log Log=~/.SpeedTest.log
-PLog=~/.PlotLog 
- 
-# Where we store images 
 ARG1="/var/www/html/SpeedTest" ARG1="/var/www/html/SpeedTest"
 ARG2="/var/www/html/${YM}-SpeedTest" ARG2="/var/www/html/${YM}-SpeedTest"
- +PLog=~/.PlotLog
-# Date format in the log file+
 Date=$(date +"%Y-%m-%d %H:%M") Date=$(date +"%Y-%m-%d %H:%M")
- +Data=($(/usr/local/bin/fast -u --json | grep -E 'latency|downloadSpeed|uploadSpeed' | cut -d : -f 2 | tr -d ',' | tr -d '\n' ; echo ""))
-# Install with; npm install --global fast-cli +
-Data=($(/usr/local/bin/fast -u --json +
-    | grep -E 'latency|downloadSpeed|uploadSpeed' +
-    | cut -d : -f 2 | tr -d ',' +
-    | tr -d '\n' ; echo ""))  +
- +
-# Formated data; delay, download, upload+
 FData="${Data[2]} ${Data[0]} ${Data[1]}" FData="${Data[2]} ${Data[0]} ${Data[1]}"
- 
-# Save it to the log like; 2019-07-20 12:09 14.72 514.17 134.54 
 echo "${Date} ${FData}" >> ${Log} echo "${Date} ${FData}" >> ${Log}
- 
-# Dump the last 128 lines into the plotlog 
 tail -128 ${Log} > ${PLog} tail -128 ${Log} > ${PLog}
- +/usr/local/bin/PlotSpeedTest 
-# Run the gnuplot script on the plotlog +if [ ${YM} != ${MT} ] 
-/usr/local/bin/PlotSpeedTest  +        then
- +
-# If this is the end of the month, copy the current image to an archive image. +
-if [ ${YM} != ${MT} ]  +
-        then +
         cp ${ARG1}.png ${ARG2}.png         cp ${ARG1}.png ${ARG2}.png
         fi         fi
Line 52: Line 34:
 <code gnuplot PlotSpeedTest> <code gnuplot PlotSpeedTest>
 #!/usr/bin/gnuplot #!/usr/bin/gnuplot
-# /usr/local/bin/PlotSpeedTest+# /usr/local/bin/PlotSpeedTest
 # # SRJ 2016-12-26 # # SRJ 2016-12-26
 fmt = '%Y-%m-%d %H:%M';        # Format used for printing out time fmt = '%Y-%m-%d %H:%M';        # Format used for printing out time
Line 65: Line 47:
 set format x "%b-%d" set format x "%b-%d"
 set xtics rotate set xtics rotate
-set xlabel "Time, tics are daily, samples are every six hours (09 */6 * * *)... +set xlabel "Time, tics are daily, samples are every six hours (09 */6 * * *)...\nTested using Sindre Sorhus' fast-cli."
-    Tested using Sindre Sorhus' fast-cli."+
 set autoscale y set autoscale y
 set autoscale xfix set autoscale xfix
Line 74: Line 55:
 set grid set grid
 set key bottom left set key bottom left
-set output "/dev/null"+set key opaque
  
 +set output "/dev/null"
 plot '/root/.PlotLog' using 1:4 plot '/root/.PlotLog' using 1:4
 max_Dn = GPVAL_DATA_Y_MAX max_Dn = GPVAL_DATA_Y_MAX
creating_the_speedtest_image_every_day.1708708166.txt.gz · Last modified: by steve