Commit 98402cf5 authored by Adam Leyshon's avatar Adam Leyshon
Browse files

Added scripts.

parent 99f4d3ea
Pipeline #2 skipped
First make sure you have python3 and rrdtool installed.
On debian type distros: apt-get install python3 rrdtool
Then run setup.sh which will:
Make a new directory in the current directory called speed graph.
Download the speedtest-cli from GitHub
Make it executable.
Create a new rrd database for you.
Don't for get to edit checkspeed.sh and adjust the paths for where you
want the graphs to be copied to.
When that's done, add a new cron job like this:
@hourly cd /yourdirectory/speedgraph && ./checkspeed.sh #Speed Monitor
Done.
\ No newline at end of file
#!/bin/bash
bandwidth_checker(){
(./speedtest-cli --secure) > ./lastresult.txt
download_info=$(cat ./lastresult.txt | grep 'Download' | awk '{print $2}')
upload_info=$(cat ./lastresult.txt | grep 'Upload' | awk '{print $2}')
}
bandwidth_checker
rrdtool update speedtest.rrd --template download:upload N:"$download_info:$upload_info"
# Graph for last 24 hours
rrdtool graph speed_graph_24.png \
-w 785 -h 120 -a PNG \
--slope-mode \
--start -86400 --end now \
--font DEFAULT:7: \
--title "Internet Speed (24 Hours)" \
--watermark "`date`" \
--vertical-label "Speed (Mbps)" \
--right-axis-label "Speed (MBps)" \
--lower-limit 0 \
--right-axis 1:0 \
--x-grid MINUTE:10:HOUR:1:MINUTE:120:0:%R \
--alt-y-grid --rigid \
DEF:download=speedtest.rrd:download:MAX \
DEF:upload=speedtest.rrd:upload:MAX \
LINE1:download#0000FF:"Download" \
GPRINT:download:LAST:"Cur\: %5.2lf" \
GPRINT:download:AVERAGE:"Avg\: %5.2lf" \
GPRINT:download:MAX:"Max\: %5.2lf" \
GPRINT:download:MIN:"Min\: %5.2lf\t\t\t" \
LINE2:upload#FF0000:"Upload" \
GPRINT:upload:LAST:"Cur\: %5.2lf" \
GPRINT:upload:AVERAGE:"Avg\: %5.2lf" \
GPRINT:upload:MAX:"Max\: %5.2lf" \
GPRINT:upload:MIN:"Min\: %5.2lf"
# Graph for last 72 Hours
rrdtool graph speed_graph_72.png \
-w 785 -h 120 -a PNG \
--slope-mode \
--start -259200 --end now \
--font DEFAULT:7: \
--title "Internet Speed (72 Hours)" \
--watermark "`date`" \
--vertical-label "Speed (Mbps)" \
--right-axis-label "Speed (MBps)" \
--lower-limit 0 \
--right-axis 1:0 \
--x-grid MINUTE:10:HOUR:1:MINUTE:120:0:%R \
--alt-y-grid --rigid \
DEF:download=speedtest.rrd:download:MAX \
DEF:upload=speedtest.rrd:upload:MAX \
LINE1:download#0000FF:"Download" \
GPRINT:download:LAST:"Cur\: %5.2lf" \
GPRINT:download:AVERAGE:"Avg\: %5.2lf" \
GPRINT:download:MAX:"Max\: %5.2lf" \
GPRINT:download:MIN:"Min\: %5.2lf\t\t\t" \
LINE2:upload#FF0000:"Upload" \
GPRINT:upload:LAST:"Cur\: %5.2lf" \
GPRINT:upload:AVERAGE:"Avg\: %5.2lf" \
GPRINT:upload:MAX:"Max\: %5.2lf" \
GPRINT:upload:MIN:"Min\: %5.2lf"
## copy to the web directory
cp speed_graph_24.png /var/www/
cp speed_graph_72.png /var/www/
\ No newline at end of file
mkdir speedgraph
cd speedgraph/
wget -O speedtest-cli https://raw.github.com/sivel/speedtest-cli/master/speedtest_cli.py
rrdtool create ./speedtest.rrd --step 3600 \
DS:download:GAUGE:5400:0:200 \
DS:upload:GAUGE:5400:0:200 \
RRA:MAX:0.5:1:168
chmod +x speedtest-cli
chmod +x checkspeed.sh
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment