How to see your NowTV routers total bandwidth usage with unix shell

Posted Comment

Since it is too difficult to login to my router's console to check total bandwidth usage so far, I spent almost an hour trying to write my first shell script that logins to NowTV router console and extract total bandwidth usage for me. I must say any sort of automation is fun!

Here is the script

# An unix shell script to display total transmitted data through you NowTV router (in the UK),
# should work with Sky router with a little bit of modification
# Refresh every 2 seconds, press Ctrl+C to stop.
# Replace the `admin:nowtv` with the username:password of your NowTV router's admin credential if you've changed it.

while true; \
do \
  curl  --user admin:nowtv  http://192.168.0.1/Now_TV_system.html  2>/dev/null  \
    | grep -ioE "(\d{4,}) " \
    | grep -o '[0-9]*' \
    | sed '/^\s*$/d' \
    | awk '{print ($1*10)/1024/1024}' \
    | tail -r \
    | sed '4q;d' \
    | awk '{print "Total transmitted data: "$1" GB"}'; \
  sleep 2; \
done

The script is also available as gist

What's New Facebook & Twitter

Panacea Lead Software Engineer, since 2015

Team Rapture Team Member, since 2011