Przeglądaj źródła

Doc, sample config, and return code updates

Ethan Galstad 24 lat temu
rodzic
commit
928841d886
6 zmienionych plików z 76 dodań i 37 usunięć
  1. 6 0
      Changelog
  2. 36 12
      README
  3. 5 5
      common/common.h
  4. 23 14
      nrpe.cfg
  5. 1 1
      src/check_nrpe.c
  6. 5 5
      src/nrpe.c

+ 6 - 0
Changelog

@@ -3,6 +3,12 @@ NRPE Changelog
 **************
 
 
+1.4 - 06/01/2002
+----------------
+- Changed STATE_UNKNOWN to value of 3 instead of -1 (old style)
+- Minor doc and sample config file changes
+
+
 1.3 - 02/21/2002
 ----------------
 - Name and version change

+ 36 - 12
README

@@ -76,12 +76,25 @@ Running Under INETD or XINETD
 If you plan on running nrpe under inetd or xinetd and making use
 of TCP wrappers, you need to do the following things:
 
+
+
 1) Add a line to your /etc/services file as follows (modify the port
    number as you see fit)
 
 	nrpe            5666/tcp	# NRPE
 
-2) If your system uses the inetd superserver, add an entry to 
+
+
+2) Add entries for the NRPE daemon to either your inetd or xinetd
+   configuration files.  Which one your use will depend on which
+   superserver is installed on your system.  Both methods are described
+   below.  NOTE: If you run nrpe under inetd or xinetd, the server_port
+   and allowed_hosts variables in the nrpe configuration file are
+   ignored.
+
+
+   ***** INETD *****
+   If your system uses the inetd superserver, add an entry to 
    /etc/inetd.conf as follows:
 
 
@@ -95,7 +108,9 @@ of TCP wrappers, you need to do the following things:
    - Replace <nrpecfg> with the path to the nrpe config file on your system.
 	Example: /usr/local/nagios/nrpe.cfg
 
-3) If your system uses xinetd instead of inetd, you'll probably
+
+   ***** XINETD *****
+   If your system uses xinetd instead of inetd, you'll probably
    want to create a file called 'nrpe' in your /etc/xinetd.d
    directory that contains the following entries:
 
@@ -123,22 +138,22 @@ of TCP wrappers, you need to do the following things:
      are allowed to connect to the NRPE daemon.  This only works if xinetd was
      compiled with support for wrappers.
 
-4) Restart inetd or xinetd will the following command (pick the
+
+
+3) Restart inetd or xinetd will the following command (pick the
    on that is appropriate for your system:
 
 	/etc/rc.d/init.d/inet restart
 
 	/etc/rc.d/init.d/xinetd restart
 
-5) Add entries to your /etc/hosts.allow and /etc/hosts.deny
+
+
+4) Add entries to your /etc/hosts.allow and /etc/hosts.deny
    file to enable TCP wrapper protection for the nrpe service.
    This is optional, although highly recommended.
 
 
-Note: If you run nrpe under inetd or xinetd, the server_port
-      and allowed_hosts variables in the nrpe configuration 
-      file are ignored.
-
 
 
 Configuring Things On The Nagios Host
@@ -152,13 +167,22 @@ to use the check_nrpe plugin from within Nagios, you'll have
 to define a few things in the host config file.  An example
 command definition for the check_nrpe plugin would look like this:
 
-command[check_nrpe]=/usr/local/nagios/libexec/check_nrpe $HOSTADDRESS$ -c $ARG1$
+define command{
+	command_name	check_nrpe
+	command_line	/usr/local/nagios/libexec/check_nrpe $HOSTADDRESS$ -c $ARG1$
+	}
 
 In any service definitions that use the nrpe plugin/daemon to
 get their results, you would set the service check command portion
-of the definition to something like this:
-
-check_nrpe!yourcommand
+of the definition to something like this (sample service definition
+is simplified for this example):
+
+define service{
+	host_name		someremotehost
+	service_description	someremoteservice
+	check_command		check_nrpe!yourcommand
+	... etc ...
+	}
 
 where "yourcommand" is a name of a command that you define in 
 your nrpe.cfg file on the remote host (see the docs in the 

+ 5 - 5
common/common.h

@@ -2,7 +2,7 @@
  *
  * COMMON.H - NRPE Common Include File
  * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
- * Last Modified: 02-21-2002
+ * Last Modified: 06-01-2002
  *
  * License:
  *
@@ -22,8 +22,8 @@
  ************************************************************************/
 
 
-#define PROGRAM_VERSION "1.3"
-#define MODIFICATION_DATE "02-21-2002"
+#define PROGRAM_VERSION "1.4"
+#define MODIFICATION_DATE "06-01-2002"
 
 #define OK		0
 #define ERROR		-1
@@ -31,10 +31,10 @@
 #define TRUE		1
 #define FALSE		0
 
-#define	STATE_CRITICAL 	2	/* service state return codes */
+#define STATE_UNKNOWN  	3	/* service state return codes */
+#define	STATE_CRITICAL 	2
 #define STATE_WARNING 	1
 #define STATE_OK       	0
-#define STATE_UNKNOWN  	-1
 
 
 #define DEFAULT_SOCKET_TIMEOUT	10	/* timeout after 10 seconds */

+ 23 - 14
nrpe.cfg

@@ -1,24 +1,30 @@
-####################################################
+#############################################################################
 # Sample NRPE Config File 
 # Written by: Ethan Galstad (nagios@nagios.org)
 # 
-# Last Modified: 02-21-2002
-####################################################
+# Last Modified: 06-01-2002
+#
+# NOTES:
+# This is a sample configuration file for the NRPE daemon.  It needs to be
+# located on the remote host that is running the NRPE daemon, not the host
+# from which the check_nrpe client is being executed.
+#############################################################################
 
 
 
 # PORT NUMBER
 # Port number we should wait for connections on.
-# This must be a non-priveledged port (i.e. > 1024).
+# NOTE: This must be a non-priviledged port (i.e. > 1024).
+# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
 
 server_port=5666
 
 
 
 # SERVER ADDRESS
-# Address that nrpe has to bind to in case there are
-# more as one interface and we do not want nrpe to bind
-# (thus listen) on all interfaces.
+# Address that nrpe should bind to in case there are more than one interface
+# and you do not want nrpe to bind on all interfaces.
+# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
 
 #server_address=192.168.1.1
 
@@ -28,18 +34,21 @@ server_port=5666
 # This is a comma-delimited list of IP address of hosts that are allowed
 # to talk to the NRPE daemon.
 #
-# Note: The daemon only does rudimentary checking of the client's IP
-# address.  I would highly recommend adding entries in your /etc/hosts.allow
-# file to allow only the specified host to connect to the port
-# you are running this daemon on.
+# NOTE: The daemon only does rudimentary checking of the client's IP
+#       address.  I would highly recommend adding entries in your
+#	/etc/hosts.allow file to allow only the specified host to connect
+#	to the port you are running this daemon on.
+#
+# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
 
-allowed_hosts=127.0.0.1,192.168.0.2
+allowed_hosts=127.0.0.1
 
 
 
 # DEBUGGING OPTION
-# This option determines whether or not debugging
-# messages are logged to the syslog facility. 0=off, 1=on
+# This option determines whether or not debugging messages are logged to the
+# syslog facility.
+# Values: 0=debugging off, 1=debugging on
 
 debug=0
 

+ 1 - 1
src/check_nrpe.c

@@ -6,7 +6,7 @@
  * License: GPL
  * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
  *
- * Last Modified: 02-21-2002
+ * Last Modified: 06-01-2002
  *
  * Command line: CHECK_NRPE <host_address> [-p port] [-c command] [-wt warn_time] \
  *                          [-ct crit_time] [-to to_sec]

+ 5 - 5
src/nrpe.c

@@ -4,7 +4,7 @@
  * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 03-19-2002
+ * Last Modified: 06-01-2002
  *
  * Command line: nrpe [-i | -d] <config_file>
  *
@@ -94,8 +94,8 @@ int main(int argc, char **argv){
 		printf("Notes:\n");
 		printf("This program is designed to process requests from the check_nrpe\n");
 		printf("plugin on the host(s) running Nagios.  It can run as a service\n");
-		printf("under inetd (read the docs for info on this), or as a standalone\n");
-		printf("daemon if you wish. Once a request is received from an authorized\n");
+		printf("under inetd or xinetd (read the docs for info on this), or as a\n");
+		printf("standalone daemon. Once a request is received from an authorized\n");
 		printf("host, NRPE will execute the command/plugin (as defined in the\n");
 		printf("config file) and return the plugin output and return code to the\n");
 		printf("check_nrpe plugin.\n");
@@ -592,7 +592,7 @@ void handle_connection(int sock){
 			buffer[sizeof(buffer)-1]='\x0';
 
 			/* check return code bounds */
-			if((result<-1) || (result>2)){
+			if((result<0) || (result>3)){
 
 				/* log error to syslog facility */
 				syslog(LOG_ERR,"Bad return code for [%s]: %d", buffer,result);
@@ -808,7 +808,7 @@ int my_system(char *command,int timeout,int *early_timeout,char *output,int outp
 			result=STATE_UNKNOWN;
 
 		/* check bounds on the return value */
-		if(result<-1 || result>2)
+		if(result<0 || result>3)
 			result=STATE_UNKNOWN;
 
 		/* try and read the results from the command output (retry if we encountered a signal) */