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
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!"
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: