Ver Fonte

Added command_timeout directive to config file

Ethan Galstad há 23 anos atrás
pai
commit
83cf6671da
3 ficheiros alterados com 16 adições e 5 exclusões
  1. 2 0
      Changelog
  2. 9 1
      nrpe.cfg.in
  3. 5 4
      src/nrpe.c

+ 2 - 0
Changelog

@@ -9,6 +9,8 @@ NRPE Changelog
 - Added sample init scripts for FreeBSD and Debian (Andrew Ryder)
 - Syntax changes (-H option specifies host name in check_nrpe, 
   -c option specifies config file in nrpe)
+- Added command_timeout directive to config file to allow user
+  to specify timeout for executing plugins
 
 
 1.5 - 06/03/2002

+ 9 - 1
nrpe.cfg.in

@@ -2,7 +2,7 @@
 # Sample NRPE Config File 
 # Written by: Ethan Galstad (nagios@nagios.org)
 # 
-# Last Modified: 06-03-2002
+# Last Modified: 10-24-2002
 #
 # NOTES:
 # This is a sample configuration file for the NRPE daemon.  It needs to be
@@ -74,6 +74,14 @@ debug=0
 
 
 
+# COMMAND TIMEOUT
+# This specifies the maximum number of seconds that the NRPE daemon will
+# allow plugins to finish executing before killing them off.
+
+command_timeout=60
+
+
+
 # COMMAND DEFINITIONS
 # Command definitions that this daemon will run.  Definitions
 # are in the following format:

+ 5 - 4
src/nrpe.c

@@ -4,7 +4,7 @@
  * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 07-08-2002
+ * Last Modified: 10-24-2002
  *
  * Command line: nrpe [--inetd | --standalone] -c <config_file>
  *
@@ -23,7 +23,7 @@
 #include "nrpe.h"
 #include "utils.h"
 
-#define COMMAND_TIMEOUT		60			/* timeout for execution of plugins */
+#define DEFAULT_COMMAND_TIMEOUT	60			/* default timeout for execution of plugins */
 #define MAXFD                   64
 
 
@@ -48,6 +48,7 @@ char    allowed_hosts[MAX_INPUT_BUFFER];
 int     server_port=DEFAULT_SERVER_PORT;
 char    server_address[16]="0.0.0.0";
 int     socket_timeout=DEFAULT_SOCKET_TIMEOUT;
+int     command_timeout=DEFAULT_COMMAND_TIMEOUT;
 
 command *command_list=NULL;
 
@@ -586,11 +587,11 @@ void handle_connection(int sock){
 
 			/* run the command */
 			strcpy(buffer,"");
-			result=my_system(temp_command->command_line,COMMAND_TIMEOUT,&early_timeout,buffer,sizeof(buffer));
+			result=my_system(temp_command->command_line,command_timeout,&early_timeout,buffer,sizeof(buffer));
 
 			/* see if the command timed out */
 			if(early_timeout==TRUE)
-				snprintf(buffer,sizeof(buffer)-1,"NRPE: Command timed out after %d seconds\n",COMMAND_TIMEOUT);
+				snprintf(buffer,sizeof(buffer)-1,"NRPE: Command timed out after %d seconds\n",command_timeout);
 			else if(!strcmp(buffer,""))
 				snprintf(buffer,sizeof(buffer)-1,"NRPE: Unable to read output\n");