[Nagiosplug-devel] Plugins and embedded Perl
Ivan Fetch
ifetch at du.edu
Mon Nov 7 13:33:29 CET 2005
Hello,
Thank you again to folks who've responded about my earlier queries RE:
developing a Mailman plugin in PERL. I've got a few questions about the
embedded PERL section of the development guidelines:
1. Do not use BEGIN and END blocks since they will be called only once
(when Nagios starts and shuts down) with Embedded Perl (ePN). In
particular, do not
use BEGIN blocks to initialize variables.
-- I've been using an END sub to return exit value 3 when we exit
unexpectedly, such as when someone uses an incorrect option. This could
be avoided if there were a GetOpt function for this - I have read the docs
for Getopt::Long multiple times but don't see anything. Am I missing it
or does it not exist? Something like a what-to-call-when-Getopt-is-mad
sub.
2. To use utils.pm, you need to provide a full path to the module in
order for it to work.
-- If I have:
use lib utils.pm;
in the script, then add lines to configure.in so that it substitutes
utils.pm with the proper lib path, is that sufficient to properly
integrate my plugin?
4. ..... Explicitly initialize each variable in use. Otherwise with
caching enabled, the plugin will not be recompiled each time, and
therefore Perl will not reinitialize
all the variables. All old variable values will still be in effect.
-- Don't variables declared with my, within a sub, go away when that
sub exits? SO the above really only applies to "global variables?"
Thanks all for your help -- Ivan Fetch.
More information about the Devel
mailing list