change paths, add png code
This commit is contained in:
@ -1,20 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# LibreNMS Speedtest plugin
|
# LibreNMS Speedtest plugin
|
||||||
|
RRDGraphsDir=/opt/librenms-speedtest/rrd
|
||||||
|
PNGImagesDir=/opt/librenms-speedtest/png
|
||||||
|
SpeedtestResultDir=/opt/librenms-speedtest/tmp
|
||||||
|
|
||||||
RRDGraphsLocation=/opt/librenms-speedtest/rrd
|
|
||||||
SpeedtestResulstTMP=/opt/librenms-speedtest/tmp
|
|
||||||
|
|
||||||
case $1 in (create)
|
case $1 in (create)
|
||||||
# Create the Ping measurement RRD
|
# Create the Latency measurement RRD
|
||||||
rrdtool create $RRDGraphsLocation/speedtest_ping.rrd -s 1800 \
|
rrdtool create $RRDGraphsDir/speedtest-latency.rrd -s 1800 \
|
||||||
DS:PING:GAUGE:3600:0:1000 \
|
DS:LATENCY:GAUGE:3600:0:1000 \
|
||||||
RRA:AVERAGE:0.5:1:576 \
|
RRA:AVERAGE:0.5:1:576 \
|
||||||
RRA:AVERAGE:0.5:6:672 \
|
RRA:AVERAGE:0.5:6:672 \
|
||||||
RRA:AVERAGE:0.5:24:732 \
|
RRA:AVERAGE:0.5:24:732 \
|
||||||
RRA:AVERAGE:0.5:144:1460
|
RRA:AVERAGE:0.5:144:1460
|
||||||
|
|
||||||
# Create the Bandwidth measurement RRD
|
# Create the Bandwidth measurement RRD
|
||||||
rrdtool create $RRDGraphsLocation/speedtest_bandwidth.rrd -s 1800 \
|
rrdtool create $RRDGraphsDir/speedtest-bandwidth.rrd -s 1800 \
|
||||||
DS:DOWN:GAUGE:3600:0:1000 \
|
DS:DOWN:GAUGE:3600:0:1000 \
|
||||||
DS:UP:GAUGE:3600:0:1000 \
|
DS:UP:GAUGE:3600:0:1000 \
|
||||||
RRA:AVERAGE:0.5:1:576 \
|
RRA:AVERAGE:0.5:1:576 \
|
||||||
@ -22,83 +23,42 @@ SpeedtestResulstTMP=/opt/librenms-speedtest/tmp
|
|||||||
RRA:AVERAGE:0.5:24:732 \
|
RRA:AVERAGE:0.5:24:732 \
|
||||||
RRA:AVERAGE:0.5:144:1460
|
RRA:AVERAGE:0.5:144:1460
|
||||||
;;
|
;;
|
||||||
(speedtest)
|
(run)
|
||||||
# Get the EPOCH date of the moment we start the test
|
# Get the date of the moment we start the test, in epoch format
|
||||||
DATE=$(/bin/date +%s)
|
DATE=$(/bin/date +%s)
|
||||||
|
|
||||||
# Generate speedtest results, store them in a temp file
|
# Generate speedtest results, store them in a temp file
|
||||||
speedtest-cli --simple --share > $SpeedtestResulstTMP/speedtest.results 2>/dev/null
|
speedtest-cli --simple --share > $SpeedtestResultDir/speedtest-results 2>/dev/null
|
||||||
|
|
||||||
# Get the Ping time
|
# Get the Latency
|
||||||
PingTime=$(cat $SpeedtestResulstTMP/speedtest.results | grep Ping | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"m" -f1)
|
Latency=$(cat $SpeedtestResultDir/speedtest-results | grep Ping | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"m" -f1)
|
||||||
|
|
||||||
# Get the Download speed
|
# Get the Download speed
|
||||||
DownloadSpeed=$(cat $SpeedtestResulstTMP/speedtest.results | grep Download | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"M" -f1)
|
DownloadSpeed=$(cat $SpeedtestResultDir/speedtest-results | grep Download | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"M" -f1)
|
||||||
|
|
||||||
# Get the Upload speed
|
# Get the Upload speed
|
||||||
UploadSpeed=$(cat $SpeedtestResulstTMP/speedtest.results | grep Upload | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"M" -f1)
|
UploadSpeed=$(cat $SpeedtestResultDir/speedtest-results | grep Upload | sed -r 's/\s+//g'| cut -d":" -f2 | cut -d"M" -f1)
|
||||||
|
|
||||||
# Update the RRD graphs
|
# Update the RRD graphs
|
||||||
rrdtool update $RRDGraphsLocation/speedtest_ping.rrd $DATE:$PingTime
|
rrdtool update $RRDGraphsDir/speedtest-latency.rrd $DATE:$Latency
|
||||||
rrdtool update $RRDGraphsLocation/speedtest_bandwidth.rrd $DATE:$DownloadSpeed:$UploadSpeed
|
rrdtool update $RRDGraphsDir/speedtest-bandwidth.rrd $DATE:$DownloadSpeed:$UploadSpeed
|
||||||
;;
|
;;
|
||||||
(graph)
|
(graph)
|
||||||
/usr/bin/rrdtool graph $RRDGraphsLocation/upload.png \
|
# Create the Latency PNG
|
||||||
--start "-3day" \
|
rrdtool graph $PNGImagesDir/speedtest-latency.png -J -a PNG -s -1day \
|
||||||
-c "BACK#000000" \
|
--title="LATENCY Test" \
|
||||||
-c "SHADEA#000000" \
|
--color CANVAS#000000 \
|
||||||
-c "SHADEB#000000" \
|
--vertical-label "ms" \
|
||||||
-c "FONT#DDDDDD" \
|
DEF:P=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:AVERAGE \
|
||||||
-c "CANVAS#202020" \
|
DEF:PMIN=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MIN \
|
||||||
-c "GRID#666666" \
|
DEF:PMAX=$RRDGraphsDir/speedtest-latency.rrd:LATENCY:MAX \
|
||||||
-c "MGRID#AAAAAA" \
|
VDEF:Pavg=P,AVERAGE \
|
||||||
-c "FRAME#202020" \
|
LINE1:Pavg#cc3300:"Average" \
|
||||||
-c "ARROW#FFFFFF" \
|
LINE2:P#3d61ab:"LATENCY (ms)\n" \
|
||||||
-u 1.1 -l 0 -v "Upload" -w 1100 -h 250 -t "Upload Speed - `/bin/date +%A", "%d" "%B" "%Y`" \
|
GPRINT:Pavg:"Average LATENCY %2.1lf ms\n" \
|
||||||
DEF:upload=$RRDGraphsLocation/upload.rrd:upload:AVERAGE \
|
-h 250 -w 525 -y1:2 \
|
||||||
AREA:upload\#FFFF00:"Upload speed (Mbit/s)" \
|
--color GRID#dddddd \
|
||||||
GPRINT:upload:MIN:"Min\: %3.2lf " \
|
--color MGRID#aaaaaa > /dev/null 2>&1
|
||||||
GPRINT:upload:MAX:"Max\: %3.2lf" \
|
|
||||||
GPRINT:upload:LAST:"Current\: %3.2lf\j" \
|
|
||||||
COMMENT:"\\n"
|
|
||||||
|
|
||||||
/usr/bin/rrdtool graph $RRDGraphsLocation/download.png \
|
|
||||||
--start "-3day" \
|
|
||||||
-c "BACK#000000" \
|
|
||||||
-c "SHADEA#000000" \
|
|
||||||
-c "SHADEB#000000" \
|
|
||||||
-c "FONT#DDDDDD" \
|
|
||||||
-c "CANVAS#202020" \
|
|
||||||
-c "GRID#666666" \
|
|
||||||
-c "MGRID#AAAAAA" \
|
|
||||||
-c "FRAME#202020" \
|
|
||||||
-c "ARROW#FFFFFF" \
|
|
||||||
-u 1.1 -l 0 -v "Download" -w 1100 -h 250 -t "Download Speed - `/bin/date +%A", "%d" "%B" "%Y`" \
|
|
||||||
DEF:download=$RRDGraphsLocation/download.rrd:download:AVERAGE \
|
|
||||||
AREA:download\#00FF00:"Download speed (Mbit/s)" \
|
|
||||||
GPRINT:download:MIN:"Min\: %3.2lf " \
|
|
||||||
GPRINT:download:MAX:"Max\: %3.2lf" \
|
|
||||||
GPRINT:download:LAST:"Current\: %3.2lf\j" \
|
|
||||||
COMMENT:"\\n"
|
|
||||||
|
|
||||||
/usr/bin/rrdtool graph $RRDGraphsLocation/echoreply.png \
|
|
||||||
--start "-3day" \
|
|
||||||
-c "BACK#000000" \
|
|
||||||
-c "SHADEA#000000" \
|
|
||||||
-c "SHADEB#000000" \
|
|
||||||
-c "FONT#DDDDDD" \
|
|
||||||
-c "CANVAS#202020" \
|
|
||||||
-c "GRID#666666" \
|
|
||||||
-c "MGRID#AAAAAA" \
|
|
||||||
-c "FRAME#202020" \
|
|
||||||
-c "ARROW#FFFFFF" \
|
|
||||||
-u 1.1 -l 0 -v "Ping" -w 1100 -h 250 -t "Ping Response - `/bin/date +%A", "%d" "%B" "%Y`" \
|
|
||||||
DEF:echoreply=$RRDGraphsLocation/echoreply.rrd:echoreply:AVERAGE \
|
|
||||||
AREA:echoreply\#FF0000:"Ping Response (ms)" \
|
|
||||||
GPRINT:echoreply:MIN:"Min\: %3.2lf " \
|
|
||||||
GPRINT:echoreply:MAX:"Max\: %3.2lf" \
|
|
||||||
GPRINT:echoreply:LAST:"Current\: %3.2lf\j" \
|
|
||||||
COMMENT:"\\n"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
(*)
|
(*)
|
||||||
|
Reference in New Issue
Block a user