Ethan Galstad преди 22 години
родител
ревизия
b36afbe8be
променени са 7 файла, в които са добавени 581 реда и са изтрити 0 реда
  1. 69 0
      include/common.h
  2. 239 0
      include/config.h.in
  3. 25 0
      include/dh.h
  4. 33 0
      include/nrpe.h
  5. 62 0
      include/utils.h
  6. 138 0
      sample-config/nrpe.cfg.in
  7. 15 0
      sample-config/nrpe.xinetd.in

+ 69 - 0
include/common.h

@@ -0,0 +1,69 @@
+/************************************************************************
+ *
+ * COMMON.H - NRPE Common Include File
+ * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
+ * Last Modified: 03-05-2003
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ************************************************************************/
+
+#include "config.h"
+
+#define PROGRAM_VERSION "2.1"
+#define MODIFICATION_DATE "10-14-2003"
+
+#define OK		0
+#define ERROR		-1
+
+#define TRUE		1
+#define FALSE		0
+
+#define STATE_UNKNOWN  	3	/* service state return codes */
+#define	STATE_CRITICAL 	2
+#define STATE_WARNING 	1
+#define STATE_OK       	0
+
+
+#define DEFAULT_SOCKET_TIMEOUT	10	/* timeout after 10 seconds */
+
+#define MAX_INPUT_BUFFER	2048	/* max size of most buffers we use */
+#define MAX_FILENAME_LENGTH     256
+
+#define MAX_HOST_ADDRESS_LENGTH	256	/* max size of a host address */
+
+#define NRPE_HELLO_COMMAND      "_NRPE_CHECK"
+
+#define MAX_COMMAND_ARGUMENTS   16
+
+
+/**************** PACKET STRUCTURE DEFINITION **********/
+
+#define QUERY_PACKET		1		/* id code for a packet containing a query */
+#define	RESPONSE_PACKET		2		/* id code for a packet containing a response */
+
+#define NRPE_PACKET_VERSION_2   2               /* packet version identifier */
+#define NRPE_PACKET_VERSION_1	1		/* older packet version identifiers (no longer supported) */
+
+#define MAX_PACKETBUFFER_LENGTH	1024		/* max amount of data we'll send in one query/response */
+
+typedef struct packet_struct{
+	int16_t   packet_version;
+	int16_t   packet_type;
+	u_int32_t crc32_value;
+	int16_t   result_code;
+	char      buffer[MAX_PACKETBUFFER_LENGTH];
+        }packet;

+ 239 - 0
include/config.h.in

@@ -0,0 +1,239 @@
+/************************************************************************
+ *
+ * NRPE Common Header File
+ * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
+ * Last Modified: 10-13-2003
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ ************************************************************************/
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#define DEFAULT_SERVER_PORT	@nrpe_port@	/* default port to use */
+
+#undef ENABLE_COMMAND_ARGUMENTS
+
+#undef HAVE_LIBWRAP
+
+#undef STDC_HEADERS
+#undef HAVE_STRDUP
+#undef HAVE_STRSTR
+#undef HAVE_STRTOUL 
+#undef HAVE_INITGROUPS
+
+#undef SIZEOF_INT
+#undef SIZEOF_SHORT
+#undef SIZEOF_LONG
+
+/* stupid stuff for u_int32_t */
+#undef U_INT32_T_IS_USHORT
+#undef U_INT32_T_IS_UINT
+#undef U_INT32_T_IS_ULONG
+#undef U_INT32_T_IS_UINT32_T
+
+#ifdef U_INT32_T_IS_USHORT
+typedef unsigned short u_int32_t;
+#endif
+#ifdef U_INT32_T_IS_ULONG
+typedef unsigned long u_int32_t;
+#endif
+#ifdef U_INT32_T_IS_UINT
+typedef unsigned int u_int32_t;
+#endif
+#ifdef U_INT32_T_IS_UINT32_t
+typedef uint32_t u_int32_t;
+#endif
+
+/* stupid stuff for int32_t */
+#undef INT32_T_IS_SHORT
+#undef INT32_T_IS_INT
+#undef INT32_T_IS_LONG
+
+#ifdef INT32_T_IS_USHORT
+typedef short int32_t;
+#endif
+#ifdef INT32_T_IS_ULONG
+typedef long int32_t;
+#endif
+#ifdef INT32_T_IS_UINT
+typedef int int32_t;
+#endif
+
+
+#define SOCKET_SIZE_TYPE ""
+#define GETGROUPS_T ""
+#define RETSIGTYPE ""
+
+#undef HAVE_GETOPT_H
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
+#undef HAVE_STRINGS_H
+#undef HAVE_STRING_H
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#ifdef HAVE_STRINGS_H
+#include <string.h>
+#endif
+
+#undef HAVE_UNISTD_H
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+
+#undef HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#undef HAVE_SYSLOG_H
+#ifdef HAVE_SYSLOG_H
+#include <syslog.h>
+#endif
+
+#undef HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#undef HAVE_FCNTL_H
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#undef HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#undef HAVE_SYS_WAIT_H
+#ifdef HAVE_SYS_WAIT_H
+#include <sys/wait.h>
+#endif
+
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+#undef HAVE_ERRNO_H
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+/* needed for the time_t structures we use later... */
+#undef TIME_WITH_SYS_TIME
+#undef HAVE_SYS_TIME_H
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+
+#undef HAVE_SYS_SOCKET_H
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#undef HAVE_SOCKET_H
+#ifdef HAVE_SOCKET_H
+#include <socket.h>
+#endif
+
+#undef HAVE_TCPD_H
+#ifdef HAVE_TCPD_H
+#include <tcpd.h>
+#endif
+
+#undef HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#undef HAVE_ARPA_INET_H
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+
+#undef HAVE_NETDB_H
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+#undef HAVE_CTYPE_H
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#undef HAVE_PWD_H
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+ 
+#undef HAVE_GRP_H
+#ifdef HAVE_GRP_H
+#include <grp.h>
+#endif
+
+#undef HAVE_DIRENT_H
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#undef HAVE_SSL
+#ifdef HAVE_SSL
+#include <rsa.h>
+#include <crypto.h>
+#include <dh.h>
+#include <pem.h>
+#include <ssl.h>
+#include <err.h>
+#include <rand.h>
+#endif
+
+#undef HAVE_KRB5_H
+#ifdef HAVE_KRB5_H
+#include <krb5.h>
+#endif
+
+#undef HAVE_INTTYPES_H
+#undef HAVE_STDINT_H
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#endif
+
+#endif

+ 25 - 0
include/dh.h

@@ -0,0 +1,25 @@
+#ifndef HEADER_DH_H
+#include <openssl/dh.h>
+#endif
+DH *get_dh512()
+	{
+	static unsigned char dh512_p[]={
+		0x97,0xDD,0x59,0x8B,0x26,0x78,0x90,0xB1,0xCD,0x59,0xFD,0xB1,
+		0xE5,0x0E,0x71,0x17,0x89,0xD1,0x4E,0xAC,0x72,0x1E,0x2A,0x91,
+		0x8C,0x53,0xA3,0x8D,0xD8,0x82,0xB6,0x9B,0xBF,0xCF,0xA1,0xA7,
+		0xC4,0x98,0x78,0xC0,0xDB,0xA6,0xB5,0x5F,0xDA,0x05,0xE1,0xDE,
+		0xCE,0x5B,0x77,0xF2,0xD6,0xA3,0x71,0xA2,0x16,0xE8,0xB2,0x06,
+		0xFD,0xDB,0x1F,0x4B,
+		};
+	static unsigned char dh512_g[]={
+		0x02,
+		};
+	DH *dh;
+
+	if ((dh=DH_new()) == NULL) return(NULL);
+	dh->p=BN_bin2bn(dh512_p,sizeof(dh512_p),NULL);
+	dh->g=BN_bin2bn(dh512_g,sizeof(dh512_g),NULL);
+	if ((dh->p == NULL) || (dh->g == NULL))
+		{ DH_free(dh); return(NULL); }
+	return(dh);
+	}

+ 33 - 0
include/nrpe.h

@@ -0,0 +1,33 @@
+/************************************************************************
+ *
+ * NRPE.H - NRPE Include File
+ * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
+ * Last Modified: 10-09-2003
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ************************************************************************/
+
+
+/**************** COMMAND STRUCTURE DEFINITION **********/
+
+typedef struct command_struct{
+	char *command_name;
+	char *command_line;
+	struct command_struct *next;
+        }command;
+

+ 62 - 0
include/utils.h

@@ -0,0 +1,62 @@
+/************************************************************************************************
+ *
+ * UTILS.H - NRPE Utilities Include File
+ *
+ * License: GPL
+ * Copyright (c) 1999-2003 Ethan Galstad (nagios@nagios.org)
+ *
+ * Last Modified: 10-14-2003
+ *
+ * Description:
+ *
+ * This file contains common include files and function definitions used in many of the plugins.
+ *
+ * License Information:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ ************************************************************************************************/
+
+#ifndef _UTILS_H
+#define _UTILS_H
+
+#include "../include/config.h"
+
+
+void generate_crc32_table(void);
+unsigned long calculate_crc32(char *, int);
+
+void randomize_buffer(char *,int);
+
+int my_tcp_connect(char *,int,int *);
+int my_connect(char *,int,int *,char *);
+
+int my_inet_aton(register const char *,struct in_addr *);
+
+void strip(char *);
+
+int sendall(int,char *,int *);
+int recvall(int,char *,int *,int);
+
+char *my_strsep(char **,const char *);
+
+void display_license(void);
+
+#endif
+
+
+
+
+

+ 138 - 0
sample-config/nrpe.cfg.in

@@ -0,0 +1,138 @@
+#############################################################################
+# Sample NRPE Config File 
+# Written by: Ethan Galstad (nagios@nagios.org)
+# 
+# Last Modified: 10-13-2003
+#
+# 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.
+# 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=@nrpe_port@
+
+
+
+# SERVER ADDRESS
+# 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
+
+
+
+# NRPE USER
+# This determines the effective user that the NRPE daemon should run as.  
+# You can either supply a username or a UID.
+# 
+# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
+
+nrpe_user=@nrpe_user@
+
+
+
+# NRPE GROUP
+# This determines the effective group that the NRPE daemon should run as.  
+# You can either supply a group name or a GID.
+# 
+# NOTE: This option is ignored if NRPE is running under either inetd or xinetd
+
+nrpe_group=@nrpe_grp@
+
+
+
+# COMMAND ARGUMENT PROCESSING
+# This option determines whether or not the NRPE daemon will allow clients
+# to specify arguments to commands that are executed.  This option only works
+# if the daemon was configured with the --enable-command-args configure script
+# option.  
+#
+# *** ENABLING THIS OPTION IS A SECURITY RISK! *** 
+# Read the SECURITY file for information on some of the security implications
+# of enabling this variable.
+#
+# Values: 0=do not allow arguments, 1=allow command arguments
+
+dont_blame_nrpe=0
+
+
+
+# DEBUGGING OPTION
+# This option determines whether or not debugging messages are logged to the
+# syslog facility.
+# Values: 0=debugging off, 1=debugging on
+
+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
+
+
+
+# INCLUDE CONFIG FILE
+# This directive allows you to include definitions from an external config file.
+
+#include=<somefile.cfg>
+
+
+
+# INCLUDE CONFIG DIRECTORY
+# This directive allows you to include definitions from config files (with a
+# .cfg extension) in one or more directories (with recursion).
+
+#include_dir=<somedirectory>
+#include_dir=<someotherdirectory>
+
+
+
+# COMMAND DEFINITIONS
+# Command definitions that this daemon will run.  Definitions
+# are in the following format:
+#
+# command[<command_name>]=<command_line>
+#
+# When the daemon receives a request to return the results of <command_name>
+# it will execute the command specified by the <command_line> argument.
+#
+# Unlike Nagios, the command line cannot contain macros - it must be
+# typed exactly as it should be executed.
+#
+# Note: Any plugins that are used in the command lines must reside
+# on the machine that this daemon is running on!  The examples below
+# assume that you have plugins installed in a /usr/local/nagios/libexec
+# directory.  Also note that you will have to modify the definitions below
+# to match the argument format the plugins expect.  Remember, these are
+# examples only!
+
+# The following examples use hardcoded command arguments...
+
+command[check_users]=@libexecdir@/check_users -w 5 -c 10
+command[check_load]=@libexecdir@/check_load -w 15,10,5 -c 30,25,20
+command[check_disk1]=@libexecdir@/check_disk -w 20 -c 10 -p /dev/hda1
+command[check_disk2]=@libexecdir@/check_disk -w 20 -c 10 -p /dev/hdb1
+command[check_zombie_procs]=@libexecdir@/check_procs -w 5 -c 10 -s Z
+command[check_total_procs]=@libexecdir@/check_procs -w 150 -c 200 
+
+# The following examples allow user-supplied arguments and can
+# only be used if the NRPE daemon was compiled with support for 
+# command arguments *AND* the dont_blame_nrpe directive in this
+# config file is set to '1'...
+
+#command[check_users]=@libexecdir@/check_users -w $ARG1$ -c $ARG2$
+#command[check_load]=@libexecdir@/check_load -w $ARG1$ -c $ARG2$
+#command[check_disk]=@libexecdir@/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
+#command[check_procs]=@libexecdir@/check_procs -w $ARG1$ -c $ARG2$ -s $ARG3$

+ 15 - 0
sample-config/nrpe.xinetd.in

@@ -0,0 +1,15 @@
+# default: on
+# description: NRPE (Nagios Remote Plugin Executor)
+service nsca
+{
+       	flags           = REUSE
+        socket_type     = stream        
+       	wait            = no
+        user            = @nrpe_user@
+	group		= @nrpe_grp@
+       	server          = @bindir@/nrpe
+        server_args     = -c @sysconfdir@/nrpe.cfg --inetd
+       	log_on_failure  += USERID
+        disable         = no
+	only_from       = 127.0.0.1
+}