What's new

script to check dsl speed

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

rlj2

Senior Member
Sometimes one of my bonded dsl lines will go down, so made a stupid script to check speed and email if its below a specified limit.
So I can reboot the modem.
Drop it here in case someone could use it.

#!/bin/sh
# Emails if specified speed is not reached.
# Requires bc and spdMerlin (v3.3.2 or later)
# Use the following carrier domain email relays to send a SMS instead of email phonenumber@carrierdomain.com
# Wireless Carrier Domain Name
# At&T @txt.att.net
# Cricket @mms.mycricket.com
# Nextel @messaging.nextel.com
# Qwest @qwestmp.com
# Sprint @messaging.sprintpcs.com
# T-Mobile @tmomail.net
# US Cellular @email.uscc.net
# Verizon @vtext.com
# Virgin @vmobl.com
#
# add "cru a linetest "0 * * * * /jffs/scripts/linetest" to /jffs/scripts/post-mount so it will run every hour

Minimumspeed=18 #Mbps
email=yes

SMTP_SERVER=smtp.server.com
SMTP_PORT=587
MY_NAME=Administrator
MY_EMAIL=your@email.here
USE_TLS=true
SMTP_AUTH=LOGIN
SMTP_AUTH_USER=userlogin
SMTP_AUTH_PASS=userpasswd
SENDTO=emailtosendto

Speed="$(/jffs/addons/spdmerlin.d/ookla/speedtest -p no --accept-license| awk 'NR==7{print $2}')"
check()
{ if [ "$(echo "$Speed > $Minimumspeed" | bc)" -eq 1 ];
then
logger -t LineTest "Speed is ok! At $Speed Mbps"
else
logger -t LineTest "Speed below threshold @ $Speed Mbps!"
mail
fi
}

mail()
{ if [ "$email" == "yes" ];
then
rm /etc/email/email.conf
echo "SMTP_SERVER = '$SMTP_SERVER'" > /etc/email/email.conf
echo "SMTP_PORT = '$SMTP_PORT'" >> /etc/email/email.conf
echo "MY_NAME = '$MY_NAME'" >> /etc/email/email.conf
echo "MY_EMAIL = '$MY_EMAIL'" >> /etc/email/email.conf
echo "USE_TLS = '$USE_TLS'" >> /etc/email/email.conf
echo "SMTP_AUTH = '$SMTP_AUTH'" >> /etc/email/email.conf
echo "SMTP_AUTH_USER = '$SMTP_AUTH_USER'" >> /etc/email/email.conf
echo "SMTP_AUTH_PASS = '$SMTP_AUTH_PASS'" >> /etc/email/email.conf


echo "Speed below threshold @ $Speed Mbps!" | email -s "ROUTER" "$SENDTO"
fi
}

check
 
Last edited:
I wonder if it would be possible to have a google voice number send me a text message when this script detects a speed drop instance...?
SMS notifications vibrate my phone when silenced and show up on my screen; emails slide into my inbox with no notification.

please don't take this to be me denegrating this work; that is not my intention. I'm asking if a future version might be able to do what is more useful TO ME
 
I wonder if it would be possible to have a google voice number send me a text message when this script detects a speed drop instance...?
SMS notifications vibrate my phone when silenced and show up on my screen; emails slide into my inbox with no notification.

please don't take this to be me denegrating this work; that is not my intention. I'm asking if a future version might be able to do what is more useful TO ME

Changed the above script, should do what you want.
 
woah, cool...and Thanks! All those of us not on US carriers need to do is drop the appropriate address in the code, then, correct?

any chance this can get added to spdMerlin, @Jack Yaz ?
 
woah, cool...and Thanks! All those of us not on US carriers need to do is drop the appropriate address in the code, then, correct?

any chance this can get added to spdMerlin, @Jack Yaz ?
yes, long as it is a email sms relay it will do as you want.
 
I entered the above script, and I'm getting a text message, but the speed comparison is not working and I'm also getting an error message about the bc command not found. How can I fix it?
 
I entered the above script, and I'm getting a text message, but the speed comparison is not working and I'm also getting an error message about the bc command not found. How can I fix it?
Its in the notes, but "opkg install bc" should do it
 
Sorry I missed the notes. But that command did it, thanks.
 

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top