script to check dsl speed

  • ATTENTION! As of November 1, 2020, you are not able to reply to threads 6 months after the thread is opened if there are more than 500 posts in the thread.
    Threads will not be locked, so posts may still be edited by their authors.
    Just start a new thread on the topic to post if you get an error message when trying to reply to a thread.

rlj2

Regular Contributor
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 [email protected]
# 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=[email protected]
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:

heysoundude

Very Senior Member
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
 

rlj2

Regular Contributor
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.
 

heysoundude

Very Senior Member
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 ?
 

rlj2

Regular Contributor
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.
 

TonyK132

Senior Member
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?
 

rlj2

Regular Contributor
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
 

TonyK132

Senior Member
Sorry I missed the notes. But that command did it, thanks.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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