Mobile broadband is often the best we have and is mostly reliable and fast enough - however over quota charges are horrendous. It is important to keep track of usage and remaining data allowance. There is no automatic way to do this on Linux, especially on a network used by multiple machines.
Three provides a web interface to latest data but it isn't always convenient and doesn't record a usage history - essential for tracking down extraordinary usage problems.
This simple script presents a solution, accessing the data from my.three.ie - storing the quota remaining in /var/log/threebroadband.log. Add it to /etc/cron.hourly as "threebroadband". I like to use Wanda-the-Fish on the Gnome panel to be able to quickly check on usage (add the custom command "tac /var/log/threebroadband.log" to the preferences instead of "fortune").
#!/bin/bash
# Check Three.ie broadband limit remaining.
# See /var/log/threebroadband.log for results (or add Wanda-the-Fish to the Gnome panel with the custom command "tac /var/log/threebroadband.log"
# Run automatically ever hour by adding to /etc/cron.hourly as threebroadband
# Login to my.three.ie
curl -s -c /tmp/cookie https://my3.three.ie/myaccount/selfcare.do > /dev/null
curl -s -b /tmp/cookie -c /tmp/cookie "$(curl -s -b /tmp/cookie -c /tmp/cookie https://my3.three.ie/mylogin//login?service=https%3A%2F%2Fmy3.three.ie%2Fmyaccount%2Fselfcare.do | grep Click | cut -f 2 --delimit="\"")" > /dev/null
# Extract limit to logs
echo $(date +"%y/%m/%d %H:%M") MB: $(curl -s -b /tmp/cookie -c /tmp/cookie https://my3.three.ie/myaccount/selfcare.do | grep "Mobile" -A "14" | tail -1 | cut -c 7-) >> /var/log/threebroadband.log
rm /tmp/cookie
Saturday, 18 July 2009
Log Broadband Use (Three.ie)
Labels:
linux,
log,
mobile broadband,
networking,
script,
three,
ubuntu
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment