Freebox (6) Revolution statistics in your Web page
253 words, 2 minutes
The Freebox Revolution has a nice management GUI which provides metrics about in/out traffic. Unfortunately, it can only be seen from the management pages when you’ve been authenticated.
Here’s a way to script the grab of the traffic pictures to show them in any Web page.
You will need a UNIX/Linux system and the wget
tool.
The first bit of magic is to authenticate and use the cookie to grab the network pictures:
FBOXCOO="/tmp/fbox_cookie"
WGETCMD="wget -q --load-cookies $FBOXCOO"
$WGETCMD --save-cookies $FBOXCOO -O /dev/null \
"http://mafreebox.freebox.fr/login.php?login=freebox&passwd=secret"
You are now authenticated and can use the $FBOXCOO
cookie to get more data.
Here’s my set of loops that allows grabbing every graphics for every network interfaces. Note that I have customized the size and colors of the graph ; just for fun:
for PERIOD in hour day week; do
for PORT in 0 1 2 3 4; do
if [ "$PORT" == "0" ]; then # WAN
DIRLIST=(up down)
DB="db=fbxconnman"
NAME="wan"
else
DIRLIST=(tx rx) # LAN
DB="db=fbxios&port=$PORT"
NAME="lan$PORT"
fi
for DIR in ${DIRLIST[0]} ${DIRLIST[1]}; do
# Download is green, Upload is blue
[ "$DIR" == "up" -o "$DIR" == "tx" ] \
&& COLOR="3366CC" || COLOR="66CC33"
$WGETCMD -O "$REPO/$NAME-$DIR-$PERIOD.png" \
"http://mafreebox.freebox.fr/rrd.cgi?$DB&dir=$DIR&w=320&h=90\
&color1=$COLOR&color2=FF9999&period=$PERIOD"
done
done
done
That’s it! You now have every PNG files in your script directory.
You may now generate an HTML page from this script or use the image from some
other Web page. I’ve done a quick and dirty HTML page that shows every graphs.
Here’s how it looks:
Now, you do it!