?Sending speedtest results to syslog
This is a script to execute a speedtest on an SD-WAN node and send the results to a remote syslog server. This works on the Fusion SD-WAN but it is also possible to implement on a pi being used as a diagnostics node.
First install the prerequisites.
sudo apt-get install netcat
Next install speedtest using this link.
Here is the script that is installed in /usr/local/sbin as docheckspeed.sh:
#!/bin/bash
cd /usr/local/sbin
note=`speedtest -p no`
URL=$( echo $note | sed 's/.*URL: //' )
download=$( echo $note | sed 's/^.*Download: //; s/ (data.*$//' )
upload=$( echo $note | sed 's/^.*Upload: //; s/ (data.*$//' )
latency=$( echo $note | sed 's/^.*Latency: //; s/ (.*$//' )
loss=$( echo $note | sed 's/^.*Loss: //; s/ Result.*$//' )
server=$( echo $note | sed 's/^.*Server: //; s/ (id.*$//' )
nc -w0 -u 2.2.1.6 514 <<< "Speedtest 157S D:'$download' U:'$upload' Lt:'$latency' Lo:'$loss' S:'$server'"
Update crontab to run the script every 4 hours:
领英推荐
#
# m h? dom mon dow?? command
11 */4 * * *???????? /usr/local/sbin/docheckspeed.sh
The speedtest result will now appear as an event in the syslog server.
Edit: Creating a script for Windows. Prerequisites is to install Windows NMAP which include ncat and the Windows versions of Ookla's cli version of speedtest.
Here is the script: docheckspeed.cmd
@echo off
speedtest -b -u Mibps -f csv > data.txt
for /f "tokens=1-7 delims=," %%a in (data.txt) do (
??? set "_S=%%a";
??? set "_I=%%b";
??? set "_La=%%c";
??? set "_J=%%d";
??? set "_Lo=%%e";
??? set "_D=%%f";
??? set "_U=%%g"
)
echo Speedtest 157S D: %_D% U: %_U% La: %_La% Lo: %_Lo% S: %_S% > banana.txt
ncat -u 1.1.2.6 514 < banana.txt
The script can be scheduled using the Windows Task Manager.
Ronald Bartels provides solutions to networking and last mile reliability problems. The solution from?Fusion Broadband?allows a business to stay 100% connected, avoid downtime and keep working. The Fusion Broadband solution has been installed in many vertical industries including state owned and private entities.In addition to the?IBM Beacon Award 2020 for Infrastructure Services, the solution is a mature software platform that has over 2000 installed instances of multiple site private wide area networking deployments.