qrdn

quite random domain name

Sep 26, 2024

Monitoring a freifunk node

I own/operate a freifunk router, running the Freifunk Darmstadt firmware which is based on gluon, which itself is based on OpenWRT.

I'd like to monitor the operation of my node (e.g. wifi client count on 2.4 and 5 GHz), but I want to avoid building my own firmware image. I already have prometheus and grafana running, so all I need is a node_exporter on the device exporting metrics over HTTP. I can install such with opkg install prometheus-node-exporter-lua, but whenever the autoupdater installs a new firmware version (often), I'd have to manually repeat that installation.

As noted in the gluon wiki this can be automated using /etc/rc.local which is run on each boot. Just add the following snippet (before the closing exit 0):

if ! test -e /usr/bin/prometheus-node-exporter-lua ; then
sh -c 'sleep 60 && \
  logger "installing prometheus-node-exporter-lua"
  opkg update
  opkg install prometheus-node-exporter-lua \
    prometheus-node-exporter-lua-nat_traffic \
    prometheus-node-exporter-lua-netstat \
    prometheus-node-exporter-lua-openwrt \
    prometheus-node-exporter-lua-wifi \
    prometheus-node-exporter-lua-wifi_stations
  logger "installing prometheus-node-exporter-lua returned $?"
' &
fi

Waiting 60 seconds after boot hopefully is enough for the WAN network to be up.

Correct operation can be tested by running the file manually: bash /etc/rc.local and checking for the "installing ... returned ..." line with logread -f.