[Nagiosplug-devel] Nagios::Plugin api

Ton Voon ton.voon at altinity.com
Fri Sep 1 09:53:12 CEST 2006


I've had a thought - does overriding die cause a problem with  
embedded perl? Design-wise, Nagios::Plugin should play nicely with  
embedded perl.

Ton

On 31 Aug 2006, at 20:36, Lawrence, Lynne wrote:

> 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.
>

http://www.altinity.com
T: +44 (0)870 787 9243
F: +44 (0)845 280 1725
Skype: tonvoon


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nagios-plugins.org/archive/devel/attachments/20060901/b8127d3e/attachment.html>


More information about the Devel mailing list