<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2800.1561" name=GENERATOR></HEAD>
<BODY
style="WORD-WRAP: break-word; khtml-nbsp-mode: space; khtml-line-break: after-white-space">
<DIV dir=ltr align=left>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial size=2>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:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>package Nagios::Plugin;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><SPAN
class=674253017-31082006><FONT face=Arial size=2>use
strict;</FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><SPAN
class=674253017-31082006></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><SPAN
class=674253017-31082006><FONT face=Arial size=2><SPAN
class=674253017-31082006><FONT face=Arial size=2><SPAN
class=674253017-31082006><FONT face=Arial size=2>our
%STAT=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4);</FONT></SPAN></FONT></SPAN></FONT></SPAN></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><SPAN
class=674253017-31082006><FONT face=Arial size=2><SPAN
class=674253017-31082006><FONT face=Arial size=2><SPAN
class=674253017-31082006></SPAN></FONT></SPAN></FONT></SPAN></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>BEGIN { <FONT size=2>$SIG{__DIE__} = sub { die_exit(@_) };
}</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>sub die_exit {</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2> my $fmt = shift;</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2> printf("Execution Error: " . $fmt,
@_);<BR> exit($STAT{UNKNOWN},);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>}</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>This way users would not have to include it in plugin
scripts.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>Best Regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=674253017-31082006><FONT face=Arial
size=2>Lynne Lawrence</FONT></SPAN></DIV></DIV><BR>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B>
nagiosplug-devel-bounces@lists.sourceforge.net
[mailto:nagiosplug-devel-bounces@lists.sourceforge.net] <B>On Behalf Of
</B>Vonnahme, Nathan<BR><B>Sent:</B> Thursday, August 31, 2006 1:07
PM<BR><B>To:</B> Nagios Plugin Development Mailing List<BR><B>Subject:</B> Re:
[Nagiosplug-devel] Nagios::Plugin api<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=775070417-31082006>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
</SPAN></FONT><FONT face=Arial color=#0000ff size=2><SPAN
class=775070417-31082006>I think die() would have to be exported by the module
and called functionally (it would also work as a method).</SPAN></FONT></DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=775070417-31082006></SPAN></FONT> </DIV>
<DIV dir=ltr align=left><FONT face=Arial color=#0000ff size=2><SPAN
class=775070417-31082006>I've messed with exit handlers before; after I get
through my current list of stuff I'll work on this.</SPAN></FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV>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?).</DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><BR
class=khtml-block-placeholder></DIV>
<DIV>Also, does that mean the object will return the data? Or all the setup
stuff is class data?<SPAN class=775070417-31082006><FONT face=Arial
color=#0000ff size=2> </FONT></SPAN></DIV>
<DIV><SPAN
class=775070417-31082006></SPAN> </DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>