Perl-script to summarize stats from Dell PowerConnect 27xx
(and some other websmart switches)

Features:

Modularized as of v2. Should be easy to write support for other switches.
Summarizes bits/s and packets/s, errors, linkinfo (speed/duplex/flowcontrol/backpressure) and other available info in a single webpage (example)
You define which ports and how often to poll and generate the statpage.
Active but undefined ports can automatically be added.
Handles wrapping of the 32bit RMON-counters.
Logging and graphing possible via RRDTool by Tobias Oetiker.
Settings in external file (example).


General requirements:

A unix-box to run it on, should work in Windows (RRDs.pm might be a problem).
Perl modules: Storable and Time::HiRes. RRDs.pm (v1.2+) is needed to create graphs.


Currently supported products:

dell_28xx.pm
Supports the Dell PowerConnect 2824, hopefully others in the series as well.
Tested with firmware 1.0.0.38.
Very similar to the 2748, some differences in the web UI, same features.
Thanks to Michael Trogni for the access to his switch
Requires perl-modules: LWP::UserAgent, Net::HTTP
dell_27xx.pm
Supports the Dell PowerConnect 2708, 2716 and 2724.
Requires perl-modules: LWP::UserAgent, Net::HTTP, Digest::MD5
dell_2748.pm
Supports the Dell PowerConnect 2748.
Got a completely different web interface than the other 27xx.
The webpages doesn't contain statistics about traffic leaving the switch, only entering :-(
The mac-address-table is supported
Thanks to Jason Keltz for the access to his switch
Requires perl-modules: LWP::UserAgent, Net::HTTP
linksys_slm200x.pm
Supports the Linksys SLM2008, probably the 2005 too.
Only very basic statistics exist.
Untested since rewritten as a module (my switch is broken).
Requires perl-modules: LWP::UserAgent, Net::HTTP
netgear_gs108t.pm
Supports the Netgear GS108T.
Written by Ryan Mott, thanks!
Tested with firmware 3.0.4.7
Requires perl-modules: LWP::UserAgent, Net::HTTP, URI::Escape

Releases and history:
v2.03 - 2011-07-15
Minor change, only released to included the module for the Netgear GS108T provided by Ryan Mott.

Been tinkering with SNMP support but has ran into troubles with Net-SNMP for the moment. Anyway, that
program will use the retention-file to access the data. I however noticed that it didn't include
information about the switch itself (model, firmware, number of ports etc).
v2.02 - 2010-03-09
Why didn't I notice before that the numbers shown in shell for in/out was switched? :-)
"MAC 00:11:22:33:44:55 = Printer" should now work (did only accept the mac if written like 001122334455).
v2.01b - 2009-04-24
Added support for fetching and showing mac-address-table (only supported by the 2748)
Description per mac can be set with "MAC 00:11:22:33:44:55 = Printer".
Possible to include more settings-file by using "INCLUDE more_settings.txt".
That was primarily added so macs can be defined in a single file if polling several switches.
Also detects changes on included settings.
Fixed the momentary dropping of auto-added ports when changing the settings.

v2.00b - 2009-04-12
Big revision!
Different switches can be supported thru modules.
Uses Storable to save retention between runs. Such info that was previously lost
when restarted, like link-changes, can now be preserved.
This also allows us to run the script via cron instead of running continuos.
Keeps track of when last error occured, and the rate it occured (mouseover).
Rate also calculated for broadcast and multicast (mouseover).
Added suppport for Dell PowerConnect 2748 and Linksys SLM2008.
Can log out after the loop, but only the Linksys-module.

Has changed the directory structure and how the script is started.
All data related to a switch is kept in a own subdir now (defaults to my_switch)
cd /dir/of/fetch_stat
perl fetch_stat.pl my_switch
...or...
./safe_fetch_stat.sh my_switch


v1.42 - 2007-05-19
Possible to smooth the graphs if you don't like jaggies.
Possible to always show certain ports even if auto-hiding inactive ports.
Included a safe wrapper that restarts the script if it would die. For example,
if the switch cannot be contacted. Suggested way to start the script at boot:
cd /dir/of/script
./safe_fetch_stat.sh >safe_fetch_stat.log 2>&1 &

Have been runnig v1.41 beta for 9 months now without hickups, so no longer considered beta.

v1.41 beta - 2006-09-30
Local interfaces can (hopefully) be polled using ethtool.
This may fail due to divergent output of the command ethtool -S, I dunno.
With ethtool we get access to more error-counters.

This mainly applies if you use the 3-hour graph (where each poll equals 1 pixel):
I've noticed that the graphs isn't as pixel-sharp as I want them to be.
This I believe is due to when the data is polled, since RRD interpolates the
values to match exact intervals. If using a step of 30 seconds the data is
adjusted to whole and half seconds, thus using averages.
It's possible now to adjust the sleep so that the polling occurs at the right time.
Ofcourse syncing can only adjust when the poll-loop starts, so when in sync
each poll will be saved in the RRD using the time when the loop started.

v1.40 beta - 2006-08-27
Have made some small extensions/sidesteps to fit my own need.
Can poll simple stats about local interfaces, like eth0, eth1 etc.
Can poll bytes/packets from iptables' chains.
This allows me to include stats from my linuxrouter,
like usage of my internet-link and graphs over services etc.
Iptables uses 32bit-counters and I currently doesn't handle wraps.
I'm mainly interested in the graphs, so I may not bother to fix it either.
No changes are made to the switch-parts of the script.

v1.33 - 2006-07-30
Sorry people, I guess I got too much spare time recently :-)
Now the base is 1000 for packets, and 1024 for bit/byte. All used 1024 before.
Possible to hide inactive but defined ports in the HTML, but still poll, log and graph them.
When linkchange is detected it is marked in bold in the HTML.
Also, when we see traffic on a port with no link (according to last linkpoll) it is marked 'up?'
Possible to exclude ports from being logged and graphed but still show in the HTML.
Fixed a stupid typo in the HTML.
And done some minor cosmetical adjustments.

v1.32 - 2006-07-28
Quite happy with the graphing now.
Now possible to choose if and how often bps- and pps-graphs should be made.
Some improvements and changes to the graphing since the last beta.
Links to the graphs are moved left to the portnumber instead, looks cleaner.
Possible to adjust size of created graphs via the settings.
Updated the example to current version.
Enjoy!

v1.31 beta - 2006-07-26
Well, a good days work :-)
Can now generate graphs as well!
Graphs to create defineable in the settings.
Graphs bit/s and packets/s per port.
Creates overviews with choosable graphs.
Tuning of created rrd-files possible in the settings.
Minor graphical adjustments.

v1.30 beta - 2006-07-26
Can write to RRD-files for external graphing.
Determined that this was easier than to implement a SNMP-server :-)
My first acquaintance with rrdtools, so there will probably be some logical errors.
One RRD-file per port monitored, is autocreated if missing (step = 30s).
Writes kbps in/out, pps in/out error pps in/out.
Also some minor bugfixes; link-change wasn't always detected.
Now also includes when link last changed in the HTML.

v1.2 - 2006-07-08
Experimental support for trunks. Cannot fully test this yet, has no such nic.

v1.1 - 2006-07-01
Tries to compensate for wrapping of the 32bit counters.
Saves the wraps between restarts.
Logging of link-changes and when error-counters increases, if wanted.
Settings moved to a seperate file for easier polling of several switches.
Settings-file to use can be given as argument.
Settings are re-read automatically when modified.
Can autoadd ports when link are detected.
Verbosity-level changable.
User-definable thresholds for grey and bold marking in the HTML.
Uptime displayed in the HTML.

v1.0 - 2006-06-22
Initial release, has been running for a couple of months without problems.
Tested with a 2716 and fw 1.0.1.07.


History

I bought a Dell PowerConnect 2716 in the end of 2006, since it was the only switch that met my requirements:

I knew that the switch lacked SNMP, but what the hell, I've been using Perl since forever and it should be a simple task to poll the data and do something useful with it. It was a bit tricky, mostly due to a odd behaviour in LWP::UserAgent regarding POST and a lacking HTTP-server in the switch. LWP::UserAgent (or something) splits the request in two packets, headers in first packet and data in another. The switch responds before it gets the second packet. Funny.

Since I couldn't find any other script that does what this does, I thought I should share it with you people. And really, the web-interface sucks. Now you can stay away from it most of the time :-)

Future:

Since some switches doesn't have the full statistics I will likely make the HTML-page template-based.
Since we use Storable to save retention the statistics is available for other programs. It would be
cool to write a program that reads the retention and responds via SNMP.

I've used drraw by Christophe Kalt to learn RRDTool and testing graphs.

Please let me know if it works for you, and what firmware version you run.

/Joakim Andersson, joakim at iqcc dot se