martybugs.net Wireless Info
 navigation
. MartyBugs home
. wireless home
 
 antenna
. Conifer antenna modifications
. my mast & antenna install
. my old mast & antenna install
. Marcus' mast & antenna install
. biquad antenna construction
. double biquad antenna
. compact collinear antenna
. anatomy of rubber ducky
. using antennas
 
 antenna testing
. Conifer antenna testing
. more Conifer testing
. antenna comparison
 
 software
. OpenWrt Wireless Router
. Linux Wireless Router
. Link Monitoring with RRDTool
. Traffic Monitoring with RRDTool
. Bandwidth Monitoring with ipac-ng
. HDD Temp Monitoring with RRDTool
 
 installation
. RedHat 7.3 on Dell Optiplex GXi
. RedHat 7.3 on PPro VS440FX
. RedHat 9.0 on Celeron 466
. Aironet PCI4800
 
 site search
Custom Search
 
Wireless Link Monitoring with RRDTool

This page details the use of RRDTool for monitoring the status of a wireless network link.

Contents:   Background | Screen Shots | Requirements | Getting Data | Automating | Viewing | Data Storage | References | Other Links

Background
See my Installing RRDTool page for detailed info on installing and configuring RRDTool.

Note that this page assumes all directories and installation locations are as per the page mentioned above.
If your configuration is different, you may need to adjust some parts of the installation instructions appropriately.

Screen Shots
Here's a screen shot of the overview page. This page displays the daily trends for the SNR (top trend), signal and noise levels (middle trend), and the link rate (bottom trend).


the overview page, showing daily trends

And here's a screen shot showing the daily, weekly, monthly and yearly trends for the signal and noise.


daily, weekly, monthly and yearly signal/noise trends


Requirements
You'll need:
  • a Linux box with a wireless card in it
  • a web server running on the Linux box
  • a working installation of RRDTool, including the shared RRD perl module
  • my rrd_wlan.pl script for data collection and graph generation
  • my wlan.cgi webpage for viewing the graphs
  • an SCP client (such as WinSCP, or SSH Secure File Transfer Client, part of SSH Secure Shell) for copying files onto your linux box.
  • a way of getting a command-line prompt on your linux box (either by logging directly onto your linux box, using a SSH client such as PuTTY or SSH Secure Shell).
Note that I'm using a custom installation of Red Hat 7.3 linux, along with an Enterasys RoamAbout wireless pcmcia card, and orinoco_cs drivers.
If your configuration is different, you may need to adjust some parts of the script appropriately.

Getting Data
The first task is to determine how to obtain the data we want to insert into the RRD database.
Some shell scripting can easily be used to obtain the items of information required. The statements below will return the SNR, signal, noise and rate respectively (assuming your wireless interface is eth2).

iwconfig eth2|grep Quality|cut -d"=" -f2|cut -d"/" -f1
iwconfig eth2|grep Signal|cut -d"=" -f3|cut -d" " -f1
iwconfig eth2|grep Signal|cut -d"=" -f4|cut -d" " -f1
iwconfig eth2|grep Rate|cut -d"M" -f1|cut -b20-24

Run these from a command prompt to verify that each command will return a single number.
Note that you may need to replace the "=" with ":", depending on the version of Wireless Tools that you have installed.

Automating Data Collection
To automate data collection, I wrote a Perl script which performs the following tasks:
  • create RRD database
  • retrieve data
  • store data into the RRD database
  • generate daily, weekly, monthly and yearly graphs
You can download a copy of my rrd_wlan.pl script.

Rename it to rrd_wlan.pl, and save it in /usr/local/bin/.
Make it executable by changing the file permissions on it:

chmod 755 /usr/local/bin/rrd_wlan.pl

and adjust the settings defined at the top of the script to make them appropriate for your linux box (and make sure these directories exist):

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
# define location of images
my $img = '/var/www/html/rrdtool';

The following lines in rrd_traffic.pl specify for which wireless network interfaces data will be collected. Add/modify/delete any lines here as appropriate (lines can be commented out with a "#" character).

# process data for each interface (add/delete as required)
&ProcessInterface("eth2", "MartinMast link");

The linux box I'm running this on has a one wireless interface, eth2, linking to a remote access point.
If you have more wireless interfaces, just duplicate the line shown above, and adjust the values as required.

Also specify the description of each interface. This description will be printed on the top of each graph generated by this script.

Test the script by executing it from a command prompt:

/usr/local/bin/rrd_wlan.pl

The first time the script is run, it'll create an RRD database for each interface, so you should see output similar to this (assuming the script has been configured to monitor eth2):

[root@elrond rrd]# /usr/local/bin/rrd_wlan.pl
eth2 link stats: snr: 9 dB, signal: -94 dBm, noise: -103 dBm, rate: 2 Mbits/s
creating rrd database for eth2 interface...

On any subsequent executions, you should see similar output, but without the creating rrd database... line.

Once you've verified the operation of the script, it can be automatically scheduled to run periodically. To get it to run every 5 minutes, add the following to /etc/crontab:

# get wireless link details
*/5 * * * * root /usr/local/bin/rrd_wlan.pl > /dev/null

Note that if you find your graphs are being created, but with no data, it's probably because your cron paths aren't setup to include paths to all of the shell commands used in rrd_wlan.pl. To correct this, you'll have to either:
  • edit /usr/local/bin/rrd_wlan.pl to reference the full pathname for iwconfig, cut and grep,
or
  • edit the PATH definition in /etc/crontab to include the paths of those commands.
Viewing the Graphs
Each time the script is executed, if required, it'll update the graphs of SNR, signal, noise and the link rate.

These graphs are being created in /var/www/html/rrdtool/, and assuming you've got a webserver running, they'll be accessible via http://your_ip/rrdtool/.

To provide a much cleaner way to view these graphs, I've written a simple webpage for displaying all the daily trends, as well as displaying the daily, weekly, and yearly trends when a user clicks on one of the daily trends.

You can download a copy of my wlan.cgi webpage.

Rename it to wlan.cgi, and save it in /var/www/html/rrdtool/.
Make it executable by changing the file permissions on it:

chmod 755 /var/www/html/rrdtool/wlan.cgi

and adjust the settings defined at the top of the script to make them appropriate for your linux box, in particular, the interface name:

# define the wireless interface
my $iface = 'eth2';

# get the server name (or you could hard code some description here)
my $svrname = $ENV{'SERVER_NAME'};

Note that I'm assuming you've got your web server appropriately configured to handle .cgi scripts. if not, refer to the inline documentation in your httpd.conf or the Apache documentation for more information.

You should now be able to point your web browser at http://your_ip/rrdtool/wlan.cgi and you should be rewarded with a page displaying the daily trends for your wireless interface.

Comments on Data Storage
This script uses a single RRD database to hold the SNR, signal, noise and link rate details for the wireless interface. The rrd_wlan.pl script uses the following syntax to create the RRD database:

rrdtool create /var/lib/rrd/weth2.rrd -s 300	\
         DS:snr:GAUGE:600:0:60			\
         DS:signal:GAUGE:600:-256:0		\
         DS:noise:GAUGE:600:-256:0		\
         DS:rate:GAUGE:600:0:100		\
         RRA:AVERAGE:0.5:1:576			\
         RRA:AVERAGE:0.5:6:672			\
         RRA:AVERAGE:0.5:24:732			\
         RRA:AVERAGE:0.5:144:1460

This will create an RRD database with the following attributes:
  • 5 minute step (base interval with which data will be fed into the RRD)
  • 4 data sources (snr, signal, noise, rate)
  • 10 minute heartbeat for each data source
  • 2 days of 5 minute averages
  • 2 weeks of 1/2 hour averages
  • 2 months of 2 hour averages
  • 2 years of 12 hour averages
Refer to the rrdcreate manpage for more information on these options.

References
Installing RRDTool
About RRD Tool
RRD Tool Documentation

Other Links
Oooops | rrdtool - a slightly different implementation of my sample code, using rrdcgi to generate the graphs on the fly at view-time


last updated 27 Dec 2012
 
.