Statistics from Freebox Revolution into Xymon server

For those who may not know, the “Freebox Revolution” is the 6th release of the access box from the French ADSL/FTTH provider named “Free”. In my case, it provides Internet access via FTTH. The box has a Web management interface from where you can configure and check statistics. The only “sad” news is that it does not provide any SNMP service. The only way to keep a eye on what goes through the ports is to log on the Web interface.

Here’s how I use the Web interface to grab metrics and show them in Xymon.

Grab the metrics

The first thing to do is to be able to get the metrics from a script. What’s a bit tricky is that the Web interface doesn’t use authentication parameters through the session. You can only set them once and any non-authenticated request sends you back to the authentication page.

Hopefully, you can use Cookies to authenticate once and browse the interface pages.

In my particular case, I use the `wget` command. Mostly because it is available on (m)any OS.

The magic strings that grab the metrics are:

# populate data files FBOXCOO="/tmp/fbox_cookie" FBOXLOG="/tmp/fbox_login.log" FBOXWAN="/tmp/fbox_status.log" FBOXFTH="/tmp/fbox_ftth.log" FBOXLAN="/tmp/fbox_switch.log" WGETCMD="wget -q --load-cookies $FBOXCOO" $WGETCMD --save-cookies $FBOXCOO -O $FBOXLOG \ "http://mafreebox.freebox.fr/login.php?login=freebox&passwd=s3cr3t" $WGETCMD -O $FBOXWAN \ "http://mafreebox.freebox.fr/settings.php?page=conn_status" $WGETCMD -O $FBOXFTH \ "http://mafreebox.freebox.fr/settings.php?page=conn_ftth" $WGETCMD -O $FBOXLAN \ "http://mafreebox.freebox.fr/settings.php?page=net_ethsw_stats"

You now own 4 files which you can parse to get the metrics you want. Quite simple.

Format the Xymon output

As usual with Xymon, the first thing to do is to create your custom script. Mine is xymon/server/ext/fbox_net.sh.

Here’s the bit of code I use to tell Xymon if everything is correct or not:

# get the FTTH status FTTHOUT="\ `egrep "Module FTTH :|Signal FTTH :|Lien :|Alimentation :|Puissance" $FBOXFTH \ | sed -e 's;^.*

  • [ ]*;;' -e 's; : ;:;g' -e 's;
  • .*$;;'`" FTTHVAL=(`echo "$FTTHOUT" \ | awk '{ FS=":"; print $2 }' | xargs`) # set the status color [[ `expr "${FTTHVAL[0]}" : 'Pr.*sent'` -ne 8 ]] && \ COLOR="red" || FTTHVAL[0]="Installed" [[ `expr "${FTTHVAL[1]}" : 'Pr.*sent'` -ne 8 ]] && \ COLOR="red" || FTTHVAL[1]="Received" [[ `expr "${FTTHVAL[2]}" : 'Up'` -ne 2 ]] && COLOR="red" [[ `expr "${FTTHVAL[3]}" : 'Ok'` -ne 2 ]] && COLOR="red" # prints the FTTH status NETINFO="$NETINFO `printf "%-15s%10s" "FTTH module" "${FTTHVAL[0]}"` `printf "%-15s%10s" "FTTH signal" "${FTTHVAL[1]}"` `printf "%-15s%10s" "Link" "${FTTHVAL[2]}"` `printf "%-15s%10s" "Power supply" "${FTTHVAL[3]}"` `printf "%-15s%10s" "Received power" "${FTTHVAL[4]} ${FTTHVAL[5]}"` `printf "%-15s%10s" "Send power" "${FTTHVAL[6]} ${FTTHVAL[7]}"` " (...) # print the informations $BB $BBDISP "status $HOSTNAME.$COLUMN $COLOR `date` $NETINFO "

    Configure the Xymon polling

    Once the script produces whatever output you need, configure it to run every 5 minutes. In my xymon/server/etc/tasks.d/tasks.cfg, I added:

    [fbox_net] ENVFILE /usr/local/www/xymon/server/etc/xymonserver.cfg NEEDS xymond CMD $XYMONHOME/ext/fbox_net.sh LOGFILE $XYMONSERVERLOGS/fbox_net.log INTERVAL 5m

    Then, in the xymon/server/etc/hosts.cfg, I added the following line:

    192.168.0.1 freebox # fbox_net

    A few minutes later, I got such output:
    Xymon server, information from Freebox Server

    Graphing the metrics

    To get the metrics graphed, you first need to parse and convert them into a proper format. The Web interface gives you (french) “human-converted” string. So a part of the process is calculating proper Byte numbers and text conversion (if you want it to be English).

    Here’s the code I use for the “WAN” part ; the interface connected to the Internet:

    # get the WAN metrics WANOUT="\ `egrep "conn_rate_down|conn_rate_up" $FBOXWAN \ | sed -e 's;^.*conn_rate_[a-z]*">;;' -e 's; (max .*$;;' -e 's/,/\./g'`" WANVAL=($(echo "$WANOUT" \ | awk ' \ /Go/ { print $1*1073741824 } /Mo/ { print $1*1048576 } /Ko/ { print $1*1024 } /octet/ { print $1*1 } ' | xargs))

    To populate the RRD file, I use:

    $BB $BBDISP "data $HOSTNAME.trends [${BBHTAG}.wan.rrd] `echo "DS:in:GAUGE:600:0:U ${WANVAL[0]}"` `echo "DS:out:GAUGE:600:0:U ${WANVAL[1]}"` "

    To define the graph to render, I put the following lines in the xymon/server/etc/graphs.cfg:

    [fbox_net] FNPATTERN ^fbox_net.(.+).rrd TITLE Network traffic YAXIS Traffic (bps) -b 1000 DEF:ibyt@RRDIDX@=@RRDFN@:in:AVERAGE DEF:obyt@RRDIDX@=@RRDFN@:out:AVERAGE CDEF:ibit@RRDIDX@=ibyt@RRDIDX@,8,* CDEF:obit@RRDIDX@=obyt@RRDIDX@,8,* CDEF:nibit@RRDIDX@=ibit@RRDIDX@,-1,* COMMENT: COMMENT: Cur\: COMMENT:Min\: COMMENT:Avg\: COMMENT:Max\: \j AREA:nibit@RRDIDX@#66CC33CC:@RRDPARAM@ Download LINE:nibit@RRDIDX@#66CC33FF: GPRINT:ibit@RRDIDX@:LAST:%6.2lf%s GPRINT:ibit@RRDIDX@:MIN:%6.2lf%s GPRINT:ibit@RRDIDX@:AVERAGE:%6.2lf%s GPRINT:ibit@RRDIDX@:MAX:%6.2lf%s\j AREA:obit@RRDIDX@#3366CC99:@RRDPARAM@ Upload LINE:obit@RRDIDX@#3366CCFF: GPRINT:obit@RRDIDX@:LAST:%6.2lf%s GPRINT:obit@RRDIDX@:MIN:%6.2lf%s GPRINT:obit@RRDIDX@:AVERAGE:%6.2lf%s GPRINT:obit@RRDIDX@:MAX:%6.2lf%s\j COMMENT: \j

    Then, to have it rendered, edit the etc/xymonserver.cfg, locate the GRAPHS variable and add the graph description to the list. Because my script grabs data for 1 WAN and 4 LAN interfaces, I set “fbox_net::1” so that Xymon graphs one PNG per RRD file, hence interface.

    Wait a few hours and have a look at your graphs.

    The graphs may not be very precise as you get a flow rate at the polling time. But for operation that last more than 5 minutes, you should get real traffic values.

    Source

    An initial work is described, in French, here: Freebox v6 stats Cacti templates

    No Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    *

    %d bloggers like this: