[Nagiosplug-devel] Please can I have GIT access

Jose Luis Martinez jlmartinez-lists-nagplug-devel at capside.com
Fri Sep 4 16:41:44 CEST 2009


Hi,

    I wrote a mini-module for doing the same in Perl plugins. Haven't
CPANned it yet, so take this as a call for community revision.

    It's called Nagios::Plugin::Differences, and I'll discuss the design
so that maybe you can lift some ideas for the C API, or that my module
gets benefitted from the discussion in place.

   - Each plugin is responsable for it's storage. I don't like FD passing
either.

   - The serializer is the Perl Storable class. Well-proven, and core
module. I use the lock_store method to serialize data to the files (so
appropiate locks get placed). There are not methods in place to change
storage type, but it can be done via subclassing (overriding persist and
load_last).

   - The temporary file is defaulted to '/tmp/_nagios_plugin_%s.tmp',
where %s is the filename name of the plugin when the object gets
constructed.

   - It's plugins responsibility to choose a different temp file if it's
anticipated there will be temporary file collisions. For example:

"check_disk_io --dev sda" and "check_disk_io --dev sdb", being executed
on the same machine will pick up one anothers temp file. They would have
to construct the Nagios::Plugin::Differences object requesting a
tempfile like /tmp/_nagios_plugin_check_disk_io_sda.tmp and
/tmp/_nagios_plugin_check_disk_io_sdb.tmp.

   - The method for persisting data automatically adds the timestamp to
the reading, you can override it if you want.

   - There are helper methods for doing the "dirty" work of calculating
differences and rates between now and the last reading.

   - Plugins with incompatible datastructures in different versions can
be detected with the plugin just storing 'struct_version' as one of the
values to be persisted and taking appropiate action (up to the plugin).

   I attach the pm file so you can inspect it (also, if you wan't I can
attach test files too). I'm open to feedback, corrections and
discussion. Please don't use or publish a plugin that uses this module
until it's CPANned, as the API is open to change.

Just my 2 cents,

Jose Luis Martinez
jlmartinez at capside.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Differences.pm
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20090904/65c2d73a/attachment.ksh>


More information about the Devel mailing list