[Nagios-devel] Bugfix for host ok on alarm() timeout

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] Bugfix for host ok on alarm() timeout

Post by Guest »

This is a multi-part message in MIME format.
--------------010109000003070307080908
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

attached is a path for a bug that occurs if plugins dont quit normally.
Return values aren't processed properly.

Best regards
Percy Jahn


--------------010109000003070307080908
Content-Type: text/plain;
name="signal.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="signal.patch"

--- nagios-2-x-cvs/base/utils.c.orig 2007-03-29 15:41:48.000000000 +0200
+++ nagios-2-x-cvs/base/utils.c 2007-03-29 15:47:39.000000000 +0200
@@ -2832,8 +2832,18 @@
/* report an error if we couldn't close the command */
if(status==-1)
result=STATE_CRITICAL;
- else
+ else {
result=WEXITSTATUS(status);
+ if(result==0 && WIFSIGNALED(status)) {
+ /* like bash */
+ result=128 + WTERMSIG(status);
+ snprintf(buffer,sizeof(buffer)-1,
+ "(Plugin received signal %d!)\n", WTERMSIG(status));
+ buffer[sizeof(buffer)-1]='\x0';
+ write(fd[1],buffer,strlen(buffer)+1);
+ buffer[0]='\x0';
+ }
+ }

/* write the output back to the parent process */
write(fd[1],buffer,strlen(buffer)+1);
--- nagios-2-x-cvs/base/checks.c.orig 2007-03-29 16:43:12.000000000 +0200
+++ nagios-2-x-cvs/base/checks.c 2007-03-29 16:55:50.000000000 +0200
@@ -523,6 +523,16 @@
svc_msg.exited_ok=FALSE;
svc_msg.early_timeout=FALSE;
}
+ else if(WEXITSTATUS(pclose_result)==0
+ && WIFSIGNALED(pclose_result) ){
+ snprintf(svc_msg.output,sizeof(svc_msg.output)-1,"(Plugin received signal %d!)\n",WTERMSIG(pclose_result));
+ svc_msg.output[sizeof(svc_msg.output)-1]='\x0';
+ svc_msg.exited_ok=TRUE;
+ svc_msg.early_timeout=FALSE;
+ /* like bash */
+ pclose_result=128+WTERMSIG(pclose_result);
+ svc_msg.return_code=pclose_result;
+ }

/* write check result to message queue */
write_svc_message(&svc_msg);

--------------010109000003070307080908--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked