verot.net - OzForces usage meter

http://www.verot.net/ozforces.print?lang=en-GB

OzForces is an ISP in Australia. Not too bad service, but they lack an usage meter. Update: they have closed shop, not surprisingly. They only provide an HTTPS web interface to see the monthly consumption.

So here's a little curl script to retrieve the upload and download status from the command line. You can use it to quickly see your usage, but also to use in MRTG for instance.

It takes no argument, only need the OzForces login and password to be changed (usr and pwd) at the top of the script. It then outputs two lines, upload and download.

$ ./ozforces.sh
7607.01
22012.57    


Here's the script. You can also download it here

Disclaimer: Your use of this script is at your sole risk. It is provided "as -is", without any warranty. I shall not be held responsible for the use you make of this script.

#!/bin/sh

#
# ozforces.sh v 0.1 
#
# Bash script to look up OzForces ADSL connection data
# OzForces is an Australian ISP, and the only interface is an HTTPS website
# The script returns two lines: upload and download, in MB
#
# by Colin Verot   colin@verot.net
#
# this script is free to use, just keep the copyright notice
#

usr=abc
pwd=xxx

cookies="/tmp/$(basename $0).$RANDOM.txt"
cookies2="/tmp/$(basename $0).$RANDOM.tmp"
params="-s -b $cookies -c $cookies"  # can add -v for debug, or remove -s for feedback
agent="Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.1) Gecko/20060305 Firefox/1.5.0.1"

# we log in, and get the key
key=`curl $params -A "$agent" -d "EvwIspDn=o%3DOzForces%2Cou%3DClients%2Co%3DDOTV&username=$usr&password=$pwd" https://isp.ozforces.com/frameset.vps | grep -o 'CgiTree\?.*" name' | sed -e 's/CgiTree?//' -e 's/" name//'`

# we load the splash page
splash=`curl $params -A "$agent" -G -e https://isp.ozforces.com/frameset.vps -d "ispDn=o%3DOzForces%2Cou%3DClients%2Co%3DDOTV" https://isp.ozforces.com/splash.jsp`

# we go through the menu
tree=`curl $params -A "$agent" -e https://isp.ozforces.com/frameset.vps -G -d "$key" https://isp.ozforces.com/cgi-bin/CgiTree`

tree=`curl $params -A "$agent" -G -d "$key+E2" https://isp.ozforces.com/cgi-bin/CgiTree`

tree=`curl $params -A "$agent" -G -d "$key+E8" https://isp.ozforces.com/cgi-bin/CgiTree`

frameright=`curl $params -A "$agent" -G -d "$key+V8" https://isp.ozforces.com/cgi-bin/CgiTree | grep -o 'location=".*";' | sed -e 's/location=//' -e 's/";//'`

# we change the cookie's path
sed -e 's/\//\/product\/extensions\/dialup\//g' < $cookies > $cookies2 && mv $cookies2 $cookies

# we get the accounts page
page=`curl $params -A "$agent" -G -e https://isp.ozforces.com/cgi-bin/CgiTree?$key+V8 -d "sessionkey=$key¤tTreeNodeId=8&parentTreeNodeId=2" https://isp.ozforces.com/product/extensions/dialup/installedConfig.vps`

# we carry on in the menu
frameright=`curl $params -A "$agent" -G -d "$key+V9" https://isp.ozforces.com/cgi-bin/CgiTree | grep -o 'location=".*";' | sed -e 's/location=//' -e 's/";//'`

# we get the page at last
page=`curl $params -A "$agent" -G -e https://isp.ozforces.com/cgi-bin/CgiTree?$key+V9 -d "sessionkey=$key¤tTreeNodeId=9&parentTreeNodeId=8" https://isp.ozforces.com/product/extensions/dialup/dialupAccount.vps`

# we parse the page to get the data
upload=`echo $page | grep -o 'Current Period: .* MB upload' | sed -e 's/Current Period: //' -e 's/ MB upload//'`
download=`echo $page | grep -o 'upload, .* MB download' | sed -e 's/upload, //' -e 's/ MB download//'`

echo $upload
echo $download

rm $cookies  


For some reason, we have to go through the whole menu, probably to set some session stuff. Plus the cookie. As a result, the script has to load quite a lot of pages before getting to the usage page, and is pretty slow. But it works :)

copyright 2001-2006 © Colin Verot - powered by The CMF