Please note: This project is no longer active. The website is kept online for historic purposes only.
If you´re looking for a Linux driver for your Atheros WLAN device, you should continue here .

Graphing iwconfig with rrdtool

Using the rrdtool to log the Link Quality, Bit Rate, Signal level and Noise level. Then view the captured data.

Output

The graph from the wifi-daily.png will look similar to this:

Picture of wifi graph from rrdtool

Create

First create a rrdtool database using:

#! /bin/bash
# create-quality.sh

# check every 1 minute for 7 days
rrdtool create /var/lib/sensord/wifi-quality.rrd --start N \
  DS:link:GAUGE:120:U:U DS:rate:GAUGE:120:U:U \
  DS:signal:GAUGE:120:U:U \
  DS:noise:GAUGE:120:U:U \
  RRA:AVERAGE:0.5:1:10080

If you wish to graph the data more or less frequently then change 10080 and 120. 10080 is calculated by 7 days * 24 hours * 60 minutes. 120 is 2 minutes * 60 seconds and represents that when no data is added in 120 seconds then there is a break in the output. There is such a break in the graph where the machine was rebooted.

Update

Add a script to update the rrdtool database

#! /bin/bash
# update-quality.sh

# check every 1 minute for 7 days
link=$(/sbin/iwconfig ath0 | /bin/sed -n "s/.*Link Quality=\([0-9]*\).*/\1/p")
rate=$(/sbin/iwconfig ath0 | /bin/sed -n "s/.*Bit Rate[=:]\([0-9]*\).*/\1/p")
signal=$(/sbin/iwconfig ath0 | /bin/sed -n "s/.*Signal level=-\([0-9]*\).*/\1/p")
noise=$(/sbin/iwconfig ath0 | /bin/sed -n "s/.*Noise level=-\([0-9]*\).*/\1/p")
/usr/bin/rrdupdate /var/lib/sensord/wifi-quality.rrd N:${link}:${rate}:${signal}:${noise}

Then capture that data every minute with a cron job

*/1 * * * * update-quality.sh

Generate Graph

Graphing with python and the rrdtool module

#! /usr/bin/python
# graph-quality.py

import rrdtool

# Generate a graph of the last 24 hours of the link, rate and signal data
rrdtool.graph('wifi-daily.png',
    '--imgformat', 'PNG',
    '--height', '200', '--width', '800',
    '--lazy',
    '--title', 'Day Wifi Stats (ath0)',
    '--vertical-label', 'Link Quality/Bit Rate',
    '--start', '-1days',
    '--x-grid', 'HOUR:1:HOUR:3:HOUR:3:0:%b %d %H:00',
    'DEF:l=/var/lib/sensord/wifi-quality.rrd:link:AVERAGE',
    'DEF:r=/var/lib/sensord/wifi-quality.rrd:rate:AVERAGE',
    'DEF:s=/var/lib/sensord/wifi-quality.rrd:signal:AVERAGE',
    'DEF:n=/var/lib/sensord/wifi-quality.rrd:noise:AVERAGE',
    'LINE1:l#00FF00:Link Quality',
    'LINE1:r#0000FF:Bit Rate',
    'LINE1:s#FF0000:Signal Level\j',
    'GPRINT:l:LAST:Last Link Quality\:   %3.0lf/94',
    'GPRINT:r:LAST:   Last Bit Rate\:%3.0lf Mbps\j',
    'GPRINT:l:AVERAGE:Average Link Quality\:%3.0lf/94',
    'GPRINT:r:AVERAGE:Average Bit Rate\:%3.0lf Mbps\j',
    'GPRINT:s:LAST:Last Signal\:         %3.0lf dBm\j',
    'GPRINT:s:AVERAGE:Average Signal\:      %3.0lf dBm')

# Generate a graph of the last 7 days of the link, rate and signal data
rrdtool.graph('wifi-weekly.png',
    '--imgformat', 'PNG',
    '--height', '200', '--width', '800',
    '--lazy',
    '--title', 'Week Wifi Levels (ath0)',
    '--vertical-label', 'Signal/Noise Levels',
    '--start', '-1week',
    '--x-grid', 'HOUR:6:DAY:1:DAY:1:86400:%a %b %d',
    'DEF:s=/var/lib/sensord/wifi-quality.rrd:signal:AVERAGE',
    'DEF:n=/var/lib/sensord/wifi-quality.rrd:noise:AVERAGE',
    'LINE2:s#00FF00:Signal Level',
    'LINE2:n#0000FF:Noise Level\j',
    'GPRINT:s:LAST:Last Signal\:     %3.0lf dBm',
    'GPRINT:n:LAST:   Last Noise\: %3.0lf dBm\j',
    'GPRINT:s:AVERAGE:Average Signal\:  %3.0lf dBm',
    'GPRINT:n:AVERAGE:Average Noise\: %3.0lf dBm\j')

The command line version of graph is similar to above.

Note

rrdtool was patched so that it would correctly run. The patch was provided upstream to the developer of rrdtool and the python import is rrdtoolmodule.

See also

UserDocs/Tools/GraphingIwconfig

Attachments