graphite<->collectd<->nl80211n setup

While providing a working wireless network you want some statistics data. This small howto will create a small statistic setup using graphite and collectd.

We'll use the kernel interface nl80211 which is also used by hostapd to collect all statistics data from AP. A collectd plugin will communicate with the kernel via nl80211 at AP. Collectd will also transfer these data over network to our statistics host where graphite runs. On the graphite host will be a collectd which receive statistics and push it into graphite.

'picture made with dia shows kernel,nl80211,ap,network,collectd,graphitehost,graphite'

Install statistics host

Install graphite

Let setup our graphite host. I will use a debian testing, because of a newer collectd version. Collectd v5 contians a plugin for graphite. Collectd v4 can only used via python plugin.

graphite install: code:

apt-get install python-django-tagging python-cairo libapache2-mod-wsgi python-twisted python-memcache python-pysqlite2 python-simplejson python-django
pip install whisper
pip install carbon
pip install graphite-web

cd /opt/graphite/conf
cp carbon.conf.example carbon.conf
cp storage-schemas.conf.example storage-schemas.conf
cd /opt/graphite/webapp/graphite/
python syncdb

You should change at least the storage-schemas.conf. Increase default retentions upto 14 days.

/opt/graphite/bin/ start


Install collectd

collectd install:

apt-get install collectd-core

Add these lines to types.db ( /usr/share/collectd/types.db )

stations        value:GAUGE:0:256
nl_station     connection_time:GAUGE:0:4294967295 inactive_time:GAUGE:0:4294967295 rx_bytes:GAUGE:0:4294967295 tx_bytes:GAUGE:0:4294967295 rx_packages:GAUGE:0:4294967295 tx_packages:GAUGE:0:4294967295 tx_retried:GAUGE:0:4294967295 tx_failed:GAUGE:0:4294967295 signal:GAUGE:-255:255 nl80211_mask:GAUGE:0:4294967295 nl80211_beacon_loss:GAUGE:0:4294967295 signal_avg:GAUGE:-255:255
nl_survey      noise:GAUGE:-255:255 active:GAUGE:0:18446744073709551615 busy:GAUGE:0:18446744073709551615 extbusy:GAUGE:0:18446744073709551615  transmit:GAUGE:0:18446744073709551615 receive:GAUGE:0:18446744073709551615 inuse:GAUGE:0:1

add following lines to /etc/collectd.conf

LoadPlugin network
LoadPlugin write_graphite
<Plugin network>
    Listen "" "25826"
<Plugin write_graphite>
    Host "localhost"
    Port "2003"


/etc/init.d/collectd restart

We are done with our graphite host. Start within screen the django development server. For production setup of graphite use memcache + wsgi.

cd /opt/graphite/webapp/graphite/
python runserver

Configuring AP

You can build your own openWRT image or use this one.

Howto build our openWRT image

mkdir openwrt-collectd
cd openwrt-collectd
git clone git://
cd openwrt
./scripts/feeds update
./scripts/feeds install collectd
cd ..

git clone git://
cd collectd-nl80211
cp 999-nl80211.patch ../openwrt/feeds/packages/utils/collectd/patches
cd ../openwrt/feeds/packages/
cat $SRCROOT/collectd-nl80211/openwrt-collectd-makefile.patch | patch -p0
cd $SRCROOT/openwrt

This will patch collectd Makefile. You can select now nl80211 within openwrt build system With make menuconfig select from collectd the nl80211 module. Make sure you compiled collectd + collectd-mod-network + collectd-mod-nl80211 hard into your image and not as module.

Flash your AP

scp $SRCROOT/openwrt/bin/ar71xx/openwrt-ar71xx-generic-tl-wdr4300-v1-jffs2-sysupgrade.bin root@
ssh root@
sysupgrade /tmp/openwrt-ar71xx-generic-tl-wdr4300-v1-jffs2-sysupgrade.bin

Configuring openWRT


# enable default wireless OpenWRT
uci set wireless.radio0.disabled=0
uci commit
# modify network config + wifi interface to match your configuration
scp collectd-example.conf root@