Giter Site home page Giter Site logo

jamesorlakin / bt-smarthub-exporter Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 193 KB

A really bad attempt at a Prometheus exporter for the BT Smart Hub 2 router

License: GNU General Public License v2.0

Go 44.83% Dockerfile 1.04% JavaScript 54.13%
bt prometheus-exporter smarthub exporter hacktoberfest

bt-smarthub-exporter's Introduction

BT Smart Hub (2) Exporter

(It goes without saying but this definitely isn't anything official by BT!)

This is a simple attempt at a Prometheus exporter for the BT Smart Hub 2 router. Other variants of the Smart Hub router are completely untested but feel free to report if it works and open pull requests for fixes and/or additional metrics.

Usage

Run the executable with the environment variable SMARTHUB_HOST set to the IP address of the router (typically 192.168.1.254). The exporter will then listen on port 9101 for the HTTP path /metrics.

Docker/Kubernetes

The image tag is jamesorlakin/smarthub-exporter:v0.1.0

An example Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: smarthub-exporter
  namespace: monitoring
  labels:
    app: smarthub-exporter
spec:
  selector:
    matchLabels:
      app: smarthub-exporter
  replicas: 1
  template:
    metadata:
      labels:
        app: smarthub-exporter
      annotations:
        prometheus.io/port: "9101"
        prometheus.io/scrape: "true"
        prometheus.io/path: "/metrics"
    spec:
      containers:
        - name: exporter
          image: jamesorlakin/smarthub-exporter:v0.1.0
          livenessProbe:
            periodSeconds: 10
            timeoutSeconds: 5
            httpGet:
              path: /metrics
              port: 9101
          ports:
            - containerPort: 9101
              name: metrics
              protocol: TCP
          env:
            - name: SMARTHUB_HOST
              value: "192.168.1.254"
          resources:
            limits:
              cpu: 50m
              memory: 50Mi

Metrics

The merics are those provided by the browser-based web console. These are reverse engineered from the browser dev tools and not the BT app - the consequence of which means to grab LAN device data this exporter executes returned JavaScript from the Smart Hub using the embedded Otto library. Yes, executes JavaScript. There'll be a better way - please feel free to tweak!

Metrics Description
up Whether the scrape target is accessible (set to 0 if parsing/connecting is unsuccessful)
smarthub_connected Whether the WAN link of the Smart Hub is connected (this was tested against an FTTP-based installation using Ethernet port 4 - ADSL should work but this could do with verification)
smarthub_uptime How many seconds the system has been up for
smarthub_connection_uptime How many seconds the WAN connection has been up for
smarthub_downloaded_bytes How many bytes have been received over the lifetime of the WAN connection (or is it reboot of the router?)
smarthub_uploaded_bytes How many bytes have been sent over the lifetime of the WAN connection (or is it reboot of the router?)
smarthub_upload_rate The synchronized connection speed for upload (for FTTP this is likely the Gigabit connection to the modem, not the subscribed speed)
smarthub_download_rate The synchronized connection speed for download (for FTTP this is likely the Gigabit connection to the modem, not the subscribed speed)
smarthub_lan_downloaded_bytes The number of bytes downloaded from the internet by each LAN device since the router restarted. Labels include mac, hostname, and ip.
smarthub_lan_uploaded_bytes The number of bytes downloaded to the internet by each LAN device since the router restarted. Labels include mac, hostname, and ip.

Grafana Dashboard

An attempt at a Grafana dashboard lives in Grafana Dashboard.json:

Dashboard screenshot

TODO

  • Option to turn off LAN metrics (e.g. executing JS is undesireable)
  • More testing
  • ARM64 build
  • More metrics(?)

bt-smarthub-exporter's People

Contributors

jamesorlakin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.