Go to file
Timo Sugliani 0d234a15f3 Merge pull request #1 from rhaamo/master
xDSL stats, command line options
2016-12-21 16:44:06 +01:00
.gitignore Use argparse and ConfigParser to have only one script and automated creds saving 2016-12-16 22:53:00 +01:00
LICENSE Initial commit 2016-12-11 17:55:24 +01:00
README.md Add graph example 2016-12-17 11:12:29 +01:00
freebox_2days.png Freebox Revolution Monitoring - Initial commit 2016-12-11 20:02:37 +01:00
freebox_dashboard.png Freebox Revolution Monitoring - Initial commit 2016-12-11 20:02:37 +01:00
freebox_monitor.png Freebox Revolution Monitoring - Initial commit 2016-12-11 20:02:37 +01:00
freebox_monitor.py Add xDSL status (showtime, sync, etc.) to stats 2016-12-17 13:24:40 +01:00
freebox_registration.png Update README and screenshots 2016-12-17 00:12:05 +01:00
freebox_registration_status.png Update README and screenshots 2016-12-17 00:12:05 +01:00
freebox_xdsl_12h_1.png Add graph example 2016-12-17 11:12:29 +01:00
freebox_xdsl_12h_2.png Add graph example 2016-12-17 11:12:29 +01:00
seximonitor_register.jpg Freebox Revolution Monitoring - Initial commit 2016-12-11 20:02:37 +01:00
telegraf.conf Freebox Revolution Monitoring - Initial commit 2016-12-11 20:02:37 +01:00

README.md

freebox-revolution-monitoring

Simple Freebox Revolution Monitoring with SexiGraf

freebox monitoring dashboard

Based/Inspired by https://github.com/tuxtof/freebox-monitoring

The newer freebox devices don't offer the hosted file with all the data information usually accessible here http://mafreebox.freebox.fr/pub/fbx_info.txt

So this solution is leveraging the Freebox API but just focuses on the stats I'm interested in, if you want to extend the script check all the other things available here

Pre-requisites

This is what I used, you can of course adapt the collector script to talk to influxdb or whatever :-)

  • SexiGraf or any Grafana/Graphite stack
  • Telegraf
  • Python with json & requests libraries installed
  • Physical Access to the Freebox Server device

Step 1: Register an app with the Freebox device

First thing to do is to register an app, to generate a specific freebox_app_token.

Run python freebox_monitoring.py --register to do that.

PS: You can modify the app name/versions etc as shown below (Optional)

    app_info = {
        'app_id': 'fr.freebox.seximonitor',
        'app_name': 'SexiMonitor',
        'app_version': '0.4.2',
        'device_name': 'SexiServer'
    }

Once you execute this script, you will see something similar to this:

register

Head to your Freebox Server device.

Freebox Server Validation

Press the > to authorize the app registration process.

You can check the saved tokens with python freebox_monitor.py --register-status:

register-status

If you need to re-auth you can delete the authorization credentials by removing the file .credentials in the directory where freebox_monitor.py is.

Step 2: Use the script to display freebox statistics information

Once you have your freebox_app_token, the process to authenticate happens in 2 steps:

  • Fetch the current challenge. (basically a random generated string changing over time)
  • Compute a session password with the challenge and your freebox_app_token.

(This avoids sending the token over the network)

Then execute it, to make sure it connects and displays information.

freebox monitor

Step 3: Stats to get and show

By default it auto adapts beetween FFTH and xDSL, by using a switch indicated (python freebox_monitor.py 'indicated switch') you can get the listed stats.

  • FFTH and xDSL (no switch, default)

    • bytes up/down
    • rate up/down
    • bandwidth up/down
    • connection state
  • FTTH

    • sfp power rx/tx
  • xDSL (each for up, and down, except uptime)

    • uptime
    • errors: es, hec, crc, ses, fec
    • rate, attenuation, signal noise ratio, max rate
    • G.INP status, corrected and uncorrected
  • System infos (-H switch)

    • Fan RPM, temp SW, CPU B, CPU M, Box uptime
  • Switch status (-S switch)

    • for each switch port: link mode
  • Switch ports status (-P switch)

    • for each switch port: rx/tx bytes rate

Step 4: Leverage telegraf to call the script and send stats to Graphite

Install telegraf on the SexiGraf appliance.

wget https://dl.influxdata.com/telegraf/releases/telegraf_1.0.1_amd64.deb
dpkg -i telegraf_1.0.1_amd64.deb 

Generate a config file for our plugins exec and graphite.

telegraf --input-filter exec --output-filter graphite config > /etc/telegraf/telegraf.conf

Check & edit the configuration file to make it look as follows:

###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################

# Configuration for Graphite server to send metrics to
[[outputs.graphite]]
  ## TCP endpoint for your graphite instance.
  ## If multiple endpoints are configured, output will be load balanced.
  ## Only one of the endpoints will be written to with each iteration.
  servers = ["localhost:2003"]
  ## Prefix metrics name
  prefix = ""
  ## Graphite output template
  ## see https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_OUTPUT.md
  template = "host.tags.measurement.field"
  ## timeout in seconds for the write connection to graphite
  timeout = 2

###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################

# Read metrics from one or more commands that can output to stdout
[[inputs.exec]]
  ## Commands array
  command = "/usr/local/freebox-revolution-monitoring/freebox_monitor.py"

  ## Timeout for each command to complete.
  timeout = "5s"

  ## Data format to consume.
  ## Each data format has it's own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "graphite"

Copy your modified freebox_monitor.py script to /usr/local/freebox-revolution-monitoring/

Relaunch telegraf and check the logs

root@sexigraf:~# tail -f /var/log/telegraf/telegraf.log
2016/12/11 18:26:30 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675367. Total dropped metrics: 0.
2016/12/11 18:26:30 Output [graphite] wrote batch of 7 metrics in 165.892µs
2016/12/11 18:26:40 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675374. Total dropped metrics: 0.
2016/12/11 18:26:40 Output [graphite] wrote batch of 7 metrics in 169.849µs
2016/12/11 18:26:50 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675381. Total dropped metrics: 0.
2016/12/11 18:26:50 Output [graphite] wrote batch of 7 metrics in 183.453µs
2016/12/11 18:27:00 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675388. Total dropped metrics: 0.
2016/12/11 18:27:00 Output [graphite] wrote batch of 7 metrics in 156.956µs
2016/12/11 18:27:10 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675395. Total dropped metrics: 0.
2016/12/11 18:27:10 Output [graphite] wrote batch of 7 metrics in 170.216µs
2016/12/11 18:27:20 Output [graphite] buffer fullness: 7 / 10000 metrics. Total gathered metrics: 675402. Total dropped metrics: 0.
2016/12/11 18:27:20 Output [graphite] wrote batch of 7 metrics in 177.338µs

If the output is similar to this, you should be good to go and build your own dashboards in SexiGraf.

Here is a 2 day view of the download/upload stats.

dashboard 2days

Example of the xDSL graphs

xdsl_dash_12h_1 xdsl_dash_12h_2

Enjoy !