How to write Perl plugins for collectd

This page describes how to write a simple Perl plugin for collectd. It fetches the numbers from a HTML page.

Screenshot of the DSL modem's info page. Be glad you 
	can't see how crappy these values are I needed this when I wanted to graph the line quality information from my Speedport 200 DSL Modem, but was fed up with my home-grown RRD graphing solution. The graphs (at least some of them) look as pretty as they can be, generating and drawing use the same config – but the configuration, almost pure RRD, is a pain. So I looked at collectd, which I wanted to do for a long time anyway.

The example plugin

If you just want a quick example without reading all this stuff, have a look at tecom.pm.

The Modem identifies itself as "Tiny Bridge DSL Modem" and is manufactured by Tecom. It only has one page, the status page. Login and pass are “admin”. Neither passord nor IP can be changed.

The plugin is named “tecom”. It loads the status page and extracts SN-ratio, attenuation and rate by using a simple regexp. In the HTML the numbers are found in the two lines below the title of the searched value.

How it works

An example

The explanation below looks more complicated than it really is. So here's the end result first. And this is how it looks like.
the resulting line quality graph the resulting rate graph

The gritty details

Pitfalls

Graphing

collection3 from the contrib-directory of the distribution is a quick way to see the graphs. In fact, it's a very nice solution to have a quick look at any RRD file! Except for the destination directory there's no configuration neccessary to do this. The time span can be changed with the scroll wheel, and there's a button to apply the timespan to all the rest of the graphs for better comparison.

Just throw it in a directory where .htaccess is allowed. The CGI-directory does not work, because ExecCGI can't be disabled by .htaccess. collection3 needs this to access its CSS-, js- and config-files. The DataDir in etc/collection.conf must be set to the directory which contains the hostname-directories.

See also

Licensed under the Creative Commons Attribution-Share Alike 3.0 License.