[Nagiosplug-devel] Nagios::Plugin api
Lawrence, Lynne
Lynne.G.Lawrence at uscg.mil
Thu Aug 31 21:36:21 CEST 2006
I believe that if you put the signal handler in the BEGIN{} block of
Nagios::Plugin it will take effect when the class is loaded with the
'use' statement, even before object creation:
package Nagios::Plugin;
use strict;
our
%STAT=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);
BEGIN { $SIG{__DIE__} = sub { die_exit(@_) }; }
.
.
.
sub die_exit {
my $fmt = shift;
printf("Execution Error: " . $fmt, @_);
exit($STAT{UNKNOWN},);
}
This way users would not have to include it in plugin scripts.
Best Regards,
Lynne Lawrence
________________________________
From: nagiosplug-devel-bounces at lists.sourceforge.net
[mailto:nagiosplug-devel-bounces at lists.sourceforge.net] On Behalf Of
Vonnahme, Nathan
Sent: Thursday, August 31, 2006 1:07 PM
To: Nagios Plugin Development Mailing List
Subject: Re: [Nagiosplug-devel] Nagios::Plugin api
You'd want it to work before an object was created, or if you
didn't have a Plugin object in the current scope, so I think die() would
have to be exported by the module and called functionally (it would also
work as a method).
I've messed with exit handlers before; after I get through my
current list of stuff I'll work on this.
I like the idea of overloading die - keeps it v simple -
but only if it doesn't need to be specified at the plugin script (eg,
can we get it automatically just by use Nagios::Plugin?).
Also, does that mean the object will return the data? Or
all the setup stuff is class data?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nagios-plugins.org/archive/devel/attachments/20060831/fd49d630/attachment.html>
More information about the Devel
mailing list