diff --git a/Speedtest.inc.php b/Speedtest.inc.php index 2a4dddc..b206625 100644 --- a/Speedtest.inc.php +++ b/Speedtest.inc.php @@ -1,15 +1,15 @@ - +
- +
Last used Speedtest server:
- +
@@ -22,16 +22,16 @@
- +
- +
- +
- +
@@ -41,16 +41,16 @@
- +
- +
- +
- +
diff --git a/images/ookla-logo.png b/images/ookla-logo.png deleted file mode 100644 index e0d1da5..0000000 Binary files a/images/ookla-logo.png and /dev/null differ diff --git a/images/ookla-logo.svg b/images/ookla-logo.svg new file mode 100644 index 0000000..3107168 --- /dev/null +++ b/images/ookla-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/speedtest-logo.png b/images/speedtest-logo.png deleted file mode 100644 index 0b04451..0000000 Binary files a/images/speedtest-logo.png and /dev/null differ diff --git a/images/speedtest-logo.svg b/images/speedtest-logo.svg new file mode 100644 index 0000000..c303ca6 --- /dev/null +++ b/images/speedtest-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..3442e36 --- /dev/null +++ b/install.sh @@ -0,0 +1,25 @@ +# Install speedtest pkg +sudo apt-get install curl +sudo apt remove speedtest-cli +curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash +sudo apt-get install speedtest +# Go to your home dir +cd ~/ +# Clone this repository into your home dir +git clone https://git.oldgate.org/Sophia/librenms-speedtest +# Create the plugin directory into LibreNMS plugin folder +mkdir /opt/librenms/html/plugins/Speedtest +# Copy the LibreNMS speedtest plugin contents into the newly created directory +cp -r ~/librenms-speedtest/. /opt/librenms/html/plugins/Speedtest +# Ensure correct ownership and permissions on the Speedtest plugin directory and files +chown -R librenms:librenms /opt/librenms/html/plugins/Speedtest +chmod -R --reference=/opt/librenms/html/plugins /opt/librenms/html/plugins/Speedtest +chmod +x /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh +# Accept the speedtest EULA and GDPR notice (if applicable) and run an initial speedtest +su -c 'speedtest --accept-license --accept-gdpr' librenms +# Create the RRD files +su -c 'bash /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh create' librenms +# Test and run the speedtest script +su -c 'bash /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh run' librenms +# Output the speedtest results into PNG files +su -c 'bash /opt/librenms/html/plugins/Speedtest/librenms-speedtest.sh graph' librenms diff --git a/librenms-speedtest.sh b/librenms-speedtest.sh index 67a87fd..8dc911b 100644 --- a/librenms-speedtest.sh +++ b/librenms-speedtest.sh @@ -34,7 +34,7 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp DATE=$(/bin/date +%s) # Generate speedtest results, store them in a temp file - speedtest --accept-license --accept-gdpr -p no > $SpeedtestResultDir/speedtest-results 2>/dev/null + speedtest -p no > $SpeedtestResultDir/speedtest-results 2>/dev/null # Get the Latency Latency=$(cat $SpeedtestResultDir/speedtest-results | grep Latency | sed 's/.*Latency:\s*\([0-9]*.[0-9]*\).*/\1/') @@ -55,7 +55,6 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp (graph) # Create the Latency PNG of the last day rrdtool graph $PNGImagesDir/speedtest-latency-day.png -J -a PNG --start "-1day" \ - --title="Last Day" \ --vertical-label "ms" \ DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ @@ -74,13 +73,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Latency PNG of the last week rrdtool graph $PNGImagesDir/speedtest-latency-week.png -J -a PNG --start "-1week" \ - --title="Last Week" \ --vertical-label "ms" \ DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ @@ -99,13 +97,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Latency PNG of the last month rrdtool graph $PNGImagesDir/speedtest-latency-month.png -J -a PNG --start "-1month" \ - --title="Last Month" \ --vertical-label "ms" \ DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ @@ -124,13 +121,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Latency PNG of the last year rrdtool graph $PNGImagesDir/speedtest-latency-year.png -J -a PNG --start "-1year" \ - --title="Last Year" \ --vertical-label "ms" \ DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ @@ -149,13 +145,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Bandwidth PNG of the last day rrdtool graph $PNGImagesDir/speedtest-bandwidth-day.png -J -a PNG --start "-1day" \ - --title="Last Day" \ --vertical-label "Mbit/s" \ DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ @@ -188,13 +183,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Bandwidth PNG of the last week rrdtool graph $PNGImagesDir/speedtest-bandwidth-week.png -J -a PNG --start "-1week" \ - --title="Last Week" \ --vertical-label "Mbit/s" \ DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ @@ -227,13 +221,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Bandwidth PNG of the last month rrdtool graph $PNGImagesDir/speedtest-bandwidth-month.png -J -a PNG --start "-1month" \ - --title="Last Month" \ --vertical-label "Mbit/s" \ DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ @@ -266,13 +259,12 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 # Create the Bandwidth PNG of the last year rrdtool graph $PNGImagesDir/speedtest-bandwidth-year.png -J -a PNG --start "-1year" \ - --title="Last Year" \ --vertical-label "Mbit/s" \ DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ @@ -305,7 +297,255 @@ SpeedtestResultDir=$SpeedtestPluginDir/tmp -c FRAME#5e5e5e \ -c ARROW#5e5e5e \ -R normal \ - -c FONT#000000 \ + -c FONT#bdbfbfff \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Latency PNG of the last day + rrdtool graph $PNGImagesDir/speedtest-latency-light-day.png -J -a PNG --start "-1day" \ + --vertical-label "ms" \ + DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ + DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ + DEF:PMAX=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MAX \ + VDEF:Pavg=P,AVERAGE \ + LINE1:Pavg#cc3300:"Avg \n" \ + LINE2:P#3d61ab:"Last latency (ms)\n" \ + GPRINT:Pavg:"Avg latency %2.1lf ms\n" \ + -h 500 -w 1000 -y1:2 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Latency PNG of the last week + rrdtool graph $PNGImagesDir/speedtest-latency-light-week.png -J -a PNG --start "-1week" \ + --vertical-label "ms" \ + DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ + DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ + DEF:PMAX=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MAX \ + VDEF:Pavg=P,AVERAGE \ + LINE1:Pavg#cc3300:"Avg \n" \ + LINE2:P#3d61ab:"Last latency (ms)\n" \ + GPRINT:Pavg:"Avg latency %2.1lf ms\n" \ + -h 500 -w 1000 -y1:2 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Latency PNG of the last month + rrdtool graph $PNGImagesDir/speedtest-latency-light-month.png -J -a PNG --start "-1month" \ + --vertical-label "ms" \ + DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ + DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ + DEF:PMAX=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MAX \ + VDEF:Pavg=P,AVERAGE \ + LINE1:Pavg#cc3300:"Avg \n" \ + LINE2:P#3d61ab:"Last latency (ms)\n" \ + GPRINT:Pavg:"Avg latency %2.1lf ms\n" \ + -h 500 -w 1000 -y1:2 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Latency PNG of the last year + rrdtool graph $PNGImagesDir/speedtest-latency-light-year.png -J -a PNG --start "-1year" \ + --vertical-label "ms" \ + DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \ + DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \ + DEF:PMAX=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MAX \ + VDEF:Pavg=P,AVERAGE \ + LINE1:Pavg#cc3300:"Avg \n" \ + LINE2:P#3d61ab:"Last latency (ms)\n" \ + GPRINT:Pavg:"Avg latency %2.1lf ms\n" \ + -h 500 -w 1000 -y1:2 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Bandwidth PNG of the last day + rrdtool graph $PNGImagesDir/speedtest-bandwidth-light-day.png -J -a PNG --start "-1day" \ + --vertical-label "Mbit/s" \ + DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ + DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ + DEF:DMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MAX \ + DEF:U=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:AVERAGE \ + DEF:UMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MIN \ + DEF:UMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MAX \ + CDEF:Y0=U,0,* \ + CDEF:NegU=U,-1,* \ + VDEF:Yavg=Y0,AVERAGE \ + VDEF:Davg=D,AVERAGE \ + VDEF:Uavg=NegU,AVERAGE \ + VDEF:Uavg2=U,AVERAGE \ + AREA:D#61ab3d:"Download" \ + AREA:NegU#3d61ab:"Upload" \ + LINE1:Uavg#cc1100: \ + LINE1:Davg#cc3300:"Avg\n" \ + LINE1:Yavg#111111: \ + GPRINT:D:LAST:"Last download bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:U:LAST:"Last upload bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:Davg:"Avg download bandwidth %2.1lf Mb/s\n" \ + GPRINT:Uavg2:"Avg upload bandwidth %2.1lf Mb/s" \ + -h 500 -w 1000 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Bandwidth PNG of the last week + rrdtool graph $PNGImagesDir/speedtest-bandwidth-light-week.png -J -a PNG --start "-1week" \ + --vertical-label "Mbit/s" \ + DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ + DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ + DEF:DMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MAX \ + DEF:U=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:AVERAGE \ + DEF:UMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MIN \ + DEF:UMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MAX \ + CDEF:Y0=U,0,* \ + CDEF:NegU=U,-1,* \ + VDEF:Yavg=Y0,AVERAGE \ + VDEF:Davg=D,AVERAGE \ + VDEF:Uavg=NegU,AVERAGE \ + VDEF:Uavg2=U,AVERAGE \ + AREA:D#61ab3d:"Download" \ + AREA:NegU#3d61ab:"Upload" \ + LINE1:Uavg#cc1100: \ + LINE1:Davg#cc3300:"Avg\n" \ + LINE1:Yavg#111111: \ + GPRINT:D:LAST:"Last download bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:U:LAST:"Last upload bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:Davg:"Avg download bandwidth %2.1lf Mb/s\n" \ + GPRINT:Uavg2:"Avg upload bandwidth %2.1lf Mb/s" \ + -h 500 -w 1000 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Bandwidth PNG of the last month + rrdtool graph $PNGImagesDir/speedtest-bandwidth-light-month.png -J -a PNG --start "-1month" \ + --vertical-label "Mbit/s" \ + DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ + DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ + DEF:DMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MAX \ + DEF:U=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:AVERAGE \ + DEF:UMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MIN \ + DEF:UMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MAX \ + CDEF:Y0=U,0,* \ + CDEF:NegU=U,-1,* \ + VDEF:Yavg=Y0,AVERAGE \ + VDEF:Davg=D,AVERAGE \ + VDEF:Uavg=NegU,AVERAGE \ + VDEF:Uavg2=U,AVERAGE \ + AREA:D#61ab3d:"Download" \ + AREA:NegU#3d61ab:"Upload" \ + LINE1:Uavg#cc1100: \ + LINE1:Davg#cc3300:"Avg\n" \ + LINE1:Yavg#111111: \ + GPRINT:D:LAST:"Last download bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:U:LAST:"Last upload bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:Davg:"Avg download bandwidth %2.1lf Mb/s\n" \ + GPRINT:Uavg2:"Avg upload bandwidth %2.1lf Mb/s" \ + -h 500 -w 1000 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ + --font LEGEND:8:DejaVuSansMono \ + --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 + + # Create the Bandwidth PNG of the last year + rrdtool graph $PNGImagesDir/speedtest-bandwidth-light-year.png -J -a PNG --start "-1year" \ + --vertical-label "Mbit/s" \ + DEF:D=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:AVERAGE \ + DEF:DMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MIN \ + DEF:DMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:DOWN:MAX \ + DEF:U=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:AVERAGE \ + DEF:UMIN=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MIN \ + DEF:UMAX=$RRDGraphsDir/speedtest-bandwidth.rrd:UP:MAX \ + CDEF:Y0=U,0,* \ + CDEF:NegU=U,-1,* \ + VDEF:Yavg=Y0,AVERAGE \ + VDEF:Davg=D,AVERAGE \ + VDEF:Uavg=NegU,AVERAGE \ + VDEF:Uavg2=U,AVERAGE \ + AREA:D#61ab3d:"Download" \ + AREA:NegU#3d61ab:"Upload" \ + LINE1:Uavg#cc1100: \ + LINE1:Davg#cc3300:"Avg\n" \ + LINE1:Yavg#111111: \ + GPRINT:D:LAST:"Last download bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:U:LAST:"Last upload bandwidth\: %2.1lf Mb/s\n" \ + GPRINT:Davg:"Avg download bandwidth %2.1lf Mb/s\n" \ + GPRINT:Uavg2:"Avg upload bandwidth %2.1lf Mb/s" \ + -h 500 -w 1000 \ + -c BACK#EEEEEE00 \ + -c SHADEA#EEEEEE00 \ + -c SHADEB#EEEEEE00 \ + -c CANVAS#FFFFFF00 \ + -c GRID#a5a5a5 \ + -c MGRID#FF9999 \ + -c FRAME#5e5e5e \ + -c ARROW#5e5e5e \ + -R normal \ + -c FONT#000 \ --font LEGEND:8:DejaVuSansMono \ --font AXIS:7:DejaVuSansMono > /dev/null 2>&1 ;;