[Nagiosplug-devel] Alarm problems

Jason Abraham nagios at its.washco.utah.gov
Tue Sep 22 00:44:56 CEST 2009


Perhaps I was not very clear with my question.
Nagios::Plugin::GetOpt defines a $SIG{ALRM} handler.
I use this alarm handler in my code: alarm($np->opt>timeout)
I realize that I can call alarm(0) to disable the alarm.

However, if my plugin makes multiple network calls shouldn't the 
timeout value apply to the entire plugin and not each individual 
network call?  

If I wish to accomplish a global plugin network timeout I can 
start my network code section with alarm($np->opt>timeout) 
and end it with alarm(0).  However, inside this code I have
various tests which result in calls to nagios_exit/nagios_die.  
As things stand I would have to proceed each nagios_exit/die call 
With alarm(0) which can quickly become cumbersome.

Why doesn't Nagios:Plugin:Functions call alarm(0) by default on exit?
A lingering alarm may be no problem when a script is executed standalone.
But won't a lingering alarm cause problems with Nagios's embedded perl
engine?

Jason Abraham

-----Original Message-----
From: Jason Abraham [mailto:Jason.Abraham at washco.utah.gov] 
Sent: Tuesday, September 15, 2009 1:18 PM
To: nagiosplug-devel at lists.sourceforge.net
Subject: [Nagiosplug-devel] Alarm problems

I have created a plugin which uses SNMP
(http://www.washco.utah.gov/meej/check_3com_alive.txt) 
and as such I have employed the recommended alarm safe-guard

----
# start counting down to timeout
alarm $plugin->opts->timeout;
your_long_check_step_that_might_time_out();
----

I use Nagios::Plugin to handle my exit state (nagios_exit).  When testing
the plugin with 
new_mini_epn it functions correctly and returns the correct codes.  However,
if I execute 
my plugin via new_mini_epn and then wait I eventually get the an alarm
error:

-----
./new_mini_epn
plugin command line: check_3com_alive.pl -H 10.0.0.10 -C  pass -n 3
embedded perl plugin return code and output was: 0 & 3COM_ALIVE OK - 3 of 3
units in stack

plugin command line: CHECK_3COM_ALIVE.PL UNKNOWN - plugin timed out (timeout
15s)
ExitTrap: 3 (Redefine exit to trap plugin exit with eval BLOCK) at p1.pl
line 61, <FIN> line 1.
-----

Obviously, the alarm timer is still left running even after calling
nagios_exit.  Is this a problem 
with my code, Nagios::Plugin, or is it even a problem at all?

I am using nagios-plugins-1.4.13

Thanks,
Jason









More information about the Devel mailing list