[Nagios-checkins] SF.net SVN: nagios:[2031] nagioscore/trunk

ageric at users.sourceforge.net ageric at users.sourceforge.net
Thu Aug 2 00:43:50 UTC 2012


Revision: 2031
          http://nagios.svn.sourceforge.net/nagios/?rev=2031&view=rev
Author:   ageric
Date:     2012-08-02 00:43:50 +0000 (Thu, 02 Aug 2012)
Log Message:
-----------
core: Remove embedded perl

For several years it's been the most complex, the buggiest and the
least tested part of Nagios, and people experiencing problems with
the Nagios core have always gotten the suggestion to disable the
embedded perl interpreter and its broken caching, and it's been
all but impossible to test its functionality with all the different
versions of Perl available.

Besides; Since we run checks through workers now instead of forking
directly and larger processes cause slower fork()'s, it's likely we
already have better check performance than adding X MiB's of heap
memory that we'd have to earmark for caching pre-compiled perl
plugins if we were to support it again.

A much more feasible way forward is to use a module to distribute
certain checks to a specialized worker. Using the newly introduced
libnagios, it shouldn't take very long to write such a one.

Signed-off-by: Andreas Ericsson <ae at op5.se>

Modified Paths:
--------------
    nagioscore/trunk/Makefile.in
    nagioscore/trunk/base/Makefile.in
    nagioscore/trunk/base/checks.c
    nagioscore/trunk/base/config.c
    nagioscore/trunk/base/nagios.c
    nagioscore/trunk/base/utils.c
    nagioscore/trunk/configure.in
    nagioscore/trunk/contrib/Makefile.in
    nagioscore/trunk/include/config.h.in
    nagioscore/trunk/include/locations.h.in
    nagioscore/trunk/t-tap/test_nagios_config.c
    nagioscore/trunk/t-tap/test_timeperiods.c

Removed Paths:
-------------
    nagioscore/trunk/OutputTrap.pm
    nagioscore/trunk/contrib/epn_nagios.h
    nagioscore/trunk/contrib/mini_epn.c
    nagioscore/trunk/contrib/new_mini_epn.c
    nagioscore/trunk/contrib/p1.pl
    nagioscore/trunk/p1.pl

Modified: nagioscore/trunk/Makefile.in
===================================================================
--- nagioscore/trunk/Makefile.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/Makefile.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -37,13 +37,10 @@
 INIT_DIR=@init_dir@
 INIT_OPTS=-o root -g root
 CGICFGDIR=$(CGIDIR)
-PERLDIR=@PERLDIR@
 
 USE_EVENTBROKER=@USE_EVENTBROKER@
 USE_LIBTAP=@USE_LIBTAP@
 
-INSTALLPERLSTUFF=@INSTALLPERLSTUFF@
-
 CGIEXTRAS=@CGIEXTRAS@
 
 SNPRINTF_O=@SNPRINTF_O@
@@ -244,9 +241,6 @@
 	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(LOGDIR)
 	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(LOGDIR)/archives
 	$(INSTALL) -m 775 $(INSTALL_OPTS) -d $(DESTDIR)$(CHECKRESULTDIR)
-	if [ $(INSTALLPERLSTUFF) = yes ]; then \
-		$(INSTALL) -m 664 $(INSTALL_OPTS) p1.pl $(DESTDIR)$(BINDIR); \
-	fi;
 
 	@echo ""
 	@echo "*** Main program, CGIs and HTML files installed ***"

Deleted: nagioscore/trunk/OutputTrap.pm
===================================================================
--- nagioscore/trunk/OutputTrap.pm	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/OutputTrap.pm	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,39 +0,0 @@
-package OutputTrap;
-#
-# Methods for use by tied STDOUT in embedded PERL module.
-#
-# Simply redirects STDOUT to a temporary file associated with the
-# current child/grandchild process.
-#
- 
-use strict;
-# Perl before 5.6 does not seem to have warnings.pm ???
-#use warnings;
-use IO::File;
-
-sub TIEHANDLE {
-	my ($class, $fn) = @_;
-	my $handle = new IO::File "> $fn" or die "Cannot open embedded work filei $!\n";
-	bless { FH => $handle, Value => 0}, $class;
-}
-
-sub PRINT {
-	my $self = shift;
-	my $handle = $self -> {FH};
-	print $handle join("", at _);
-}
-
-sub PRINTF {
-	my $self = shift;
-	my $fmt = shift;
-	my $handle = $self -> {FH};
-	printf $handle ($fmt, at _);
-}
-
-sub CLOSE {
-	my $self = shift;
-	my $handle = $self -> {FH};
-	close $handle;
-}
-1;
-__END__

Modified: nagioscore/trunk/base/Makefile.in
===================================================================
--- nagioscore/trunk/base/Makefile.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/base/Makefile.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -48,8 +48,6 @@
 HTMURL=@htmurl@
 
 MATHLIBS=-lm
-PERLLIBS=@PERLLIBS@
-PERLXSI_O=@PERLXSI_O@
 SOCKETLIBS=@SOCKETLIBS@
 THREADLIBS=@THREADLIBS@
 BROKERLIBS=@BROKERLIBS@
@@ -123,7 +121,7 @@
 DDATADEPS=$(DDATALIBS)
 
 
-OBJS=$(BROKER_O) $(SRC_COMMON)/shared.o workers.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o skiplist.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS) $(SNPRINTF_O) $(PERLXSI_O)
+OBJS=$(BROKER_O) $(SRC_COMMON)/shared.o workers.o checks.o config.o commands.o events.o flapping.o logging.o macros-base.o netutils.o notifications.o sehandlers.o skiplist.o utils.o $(RDATALIBS) $(CDATALIBS) $(ODATALIBS) $(SDATALIBS) $(PDATALIBS) $(DDATALIBS) $(BASEEXTRALIBS) $(SNPRINTF_O)
 OBJDEPS=$(ODATADEPS) $(ODATADEPS) $(RDATADEPS) $(CDATADEPS) $(SDATADEPS) $(PDATADEPS) $(DDATADEPS) $(BROKER_H)
 
 all: nagios nagiostats
@@ -183,7 +181,7 @@
 	$(MAKE) -C $(SRC_LIB)
 
 nagios: nagios.c $(OBJS) $(OBJDEPS) $(SRC_INCLUDE)/nagios.h $(SRC_INCLUDE)/locations.h libnagios
-	$(CC) $(CFLAGS) -o $@ nagios.c $(OBJS) $(BROKER_LDFLAGS) $(LDFLAGS) $(PERLLIBS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS) $(SRC_LIB)/libnagios.a
+	$(CC) $(CFLAGS) -o $@ nagios.c $(OBJS) $(BROKER_LDFLAGS) $(LDFLAGS) $(MATHLIBS) $(SOCKETLIBS) $(THREADLIBS) $(BROKERLIBS) $(LIBS) $(SRC_LIB)/libnagios.a
 
 nagiostats: nagiostats.c $(SRC_INCLUDE)/locations.h
 	$(CC) $(CFLAGS) -o $@ nagiostats.c $(LDFLAGS) $(MATHLIBS) $(LIBS)

Modified: nagioscore/trunk/base/checks.c
===================================================================
--- nagioscore/trunk/base/checks.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/base/checks.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -38,10 +38,6 @@
 /*#define DEBUG_HOST_CHECKS 1*/
 
 
-#ifdef EMBEDDEDPERL
-#include "../include/epn_nagios.h"
-#endif
-
 #ifdef USE_EVENT_BROKER
 #include "../include/neberrors.h"
 #endif
@@ -120,14 +116,9 @@
 
 extern unsigned long max_debug_file_size;
 
-#ifdef EMBEDDEDPERL
-extern int      use_embedded_perl;
-#endif
 
 
 
-
-
 /******************************************************************/
 /********************** CHECK REAPER FUNCTIONS ********************/
 /******************************************************************/

Modified: nagioscore/trunk/base/config.c
===================================================================
--- nagioscore/trunk/base/config.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/base/config.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -39,8 +39,6 @@
 extern char     *check_result_path;
 extern char     *lock_file;
 extern char	*log_archive_path;
-extern char     *auth_file;
-extern char	*p1_file;
 
 extern char     *nagios_user;
 extern char     *nagios_group;
@@ -181,9 +179,6 @@
 extern int      free_child_process_memory;
 extern int      child_processes_fork_twice;
 
-extern int      enable_embedded_perl;
-extern int      use_embedded_perl_implicitly;
-
 extern int      date_format;
 extern char     *use_timezone;
 
@@ -246,6 +241,13 @@
 	return OK;
 	}
 
+static void obsoleted_warning(const char *key, const char *msg)
+{
+	if (msg)
+		logit(NSLOG_CONFIG_WARNING, TRUE, "Warning: %s is deprecated and will be removed. %s\n", key, msg);
+	else
+		logit(NSLOG_CONFIG_WARNING, TRUE, "Warning: %s is deprecated and will be removed.\n", key);
+}
 
 /* process the main configuration file */
 int read_main_config_file(char *main_config_file) {
@@ -1211,18 +1213,6 @@
 			use_timezone = (char *)strdup(value);
 			}
 
-		else if(!strcmp(variable, "p1_file")) {
-
-			if(strlen(value) > MAX_FILENAME_LENGTH - 1) {
-				asprintf(&error_message, "P1 file is too long");
-				error = TRUE;
-				break;
-				}
-
-			my_free(p1_file);
-			p1_file = (char *)strdup(value);
-			}
-
 		else if(!strcmp(variable, "event_broker_options")) {
 
 			if(!strcmp(value, "-1"))
@@ -1283,28 +1273,16 @@
 		else if(!strcmp(variable, "child_processes_fork_twice"))
 			child_processes_fork_twice = (atoi(value) > 0) ? TRUE : FALSE;
 
-		else if(!strcmp(variable, "enable_embedded_perl")) {
+		/*** embedded perl variables are deprecated now ***/
+		else if(!strcmp(variable, "enable_embedded_perl"))
+			obsoleted_warning(variable, NULL);
+		else if(!strcmp(variable, "use_embedded_perl_implicitly"))
+			obsoleted_warning(variable, NULL);
+		else if(!strcmp(variable, "auth_file"))
+			obsoleted_warning(variable, NULL);
+		else if(!strcmp(variable, "p1_file"))
+			obsoleted_warning(variable, NULL);
 
-			if(strlen(value) != 1 || value[0] < '0' || value[0] > '1') {
-				asprintf(&error_message, "Illegal value for enable_embedded_perl");
-				error = TRUE;
-				break;
-				}
-
-			enable_embedded_perl = (atoi(value) > 0) ? TRUE : FALSE;
-			}
-
-		else if(!strcmp(variable, "use_embedded_perl_implicitly")) {
-
-			if(strlen(value) != 1 || value[0] < '0' || value[0] > '1') {
-				asprintf(&error_message, "Illegal value for use_embedded_perl_implicitly");
-				error = TRUE;
-				break;
-				}
-
-			use_embedded_perl_implicitly = (atoi(value) > 0) ? TRUE : FALSE;
-			}
-
 		else if(!strcmp(variable, "external_command_buffer_slots"))
 			external_command_buffer_slots = atoi(value);
 
@@ -1314,19 +1292,6 @@
 		else if(!strcmp(variable, "bare_update_check"))
 			bare_update_check = (atoi(value) > 0) ? TRUE : FALSE;
 
-		/*** AUTH_FILE VARIABLE USED BY EMBEDDED PERL INTERPRETER ***/
-		else if(!strcmp(variable, "auth_file")) {
-
-			if(strlen(value) > MAX_FILENAME_LENGTH - 1) {
-				asprintf(&error_message, "Auth file is too long");
-				error = TRUE;
-				break;
-				}
-
-			my_free(auth_file);
-			auth_file = (char *)strdup(value);
-			}
-
 		/* warn about old variables */
 		else if(!strcmp(variable, "comment_file") || !strcmp(variable, "xcddefault_comment_file")) {
 			logit(NSLOG_CONFIG_WARNING, TRUE, "Warning: comment_file variable ignored.  Comments are now stored in the status and retention files.");

Modified: nagioscore/trunk/base/nagios.c
===================================================================
--- nagioscore/trunk/base/nagios.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/base/nagios.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -65,8 +65,6 @@
 char            *check_result_path = NULL;
 char            *lock_file = NULL;
 char            *log_archive_path = NULL;
-char            *p1_file = NULL;  /**** EMBEDDED PERL ****/
-char            *auth_file = NULL; /**** EMBEDDED PERL INTERPRETER AUTH FILE ****/
 char            *nagios_user = NULL;
 char            *nagios_group = NULL;
 
@@ -233,10 +231,6 @@
 int             free_child_process_memory = -1;
 int             child_processes_fork_twice = -1;
 
-int             enable_embedded_perl = DEFAULT_ENABLE_EMBEDDED_PERL;
-int             use_embedded_perl_implicitly = DEFAULT_USE_EMBEDDED_PERL_IMPLICITLY;
-int             embedded_perl_initialized = FALSE;
-
 int             date_format = DATE_FORMAT_US;
 char            *use_timezone = NULL;
 
@@ -276,8 +270,6 @@
 
 
 
-
-/* Following main() declaration required by older versions of Perl ut 5.00503 */
 int main(int argc, char **argv, char **env) {
 	int result;
 	int error = FALSE;
@@ -722,10 +714,6 @@
 
 					/* close and delete the external command file FIFO */
 					close_command_file();
-
-					/* cleanup embedded perl interpreter */
-					if(embedded_perl_initialized == TRUE)
-						deinit_embedded_perl();
 					}
 
 #ifdef USE_EVENT_BROKER
@@ -736,22 +724,6 @@
 				exit(ERROR);
 				}
 
-
-
-			/* initialize embedded Perl interpreter */
-			/* NOTE 02/15/08 embedded Perl must be initialized if compiled in, regardless of whether or not its enabled in the config file */
-			/* It compiled it, but not initialized, Nagios will segfault in readdir() calls, as libperl takes this function over */
-			if(embedded_perl_initialized == FALSE) {
-				/*				if(enable_embedded_perl==TRUE){*/
-#ifdef EMBEDDEDPERL
-				init_embedded_perl(env);
-#else
-				init_embedded_perl(NULL);
-#endif
-				embedded_perl_initialized = TRUE;
-				/*					}*/
-				}
-
 			/* handle signals (interrupts) */
 			setup_sighandler();
 
@@ -899,10 +871,6 @@
 				close_command_file();
 				}
 
-			/* cleanup embedded perl interpreter */
-			if(sigrestart == FALSE)
-				deinit_embedded_perl();
-
 			/* shutdown stuff... */
 			if(sigshutdown == TRUE) {
 

Modified: nagioscore/trunk/base/utils.c
===================================================================
--- nagioscore/trunk/base/utils.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/base/utils.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -36,12 +36,6 @@
 #include "../include/workers.h"
 
 
-#ifdef EMBEDDEDPERL
-#include "../include/epn_nagios.h"
-static PerlInterpreter *my_perl = NULL;
-int use_embedded_perl = TRUE;
-#endif
-
 extern char	*config_file;
 extern char	*log_file;
 extern char     *command_file;
@@ -51,8 +45,6 @@
 extern char     *check_result_path;
 extern char     *lock_file;
 extern char	*log_archive_path;
-extern char     *auth_file;
-extern char	*p1_file;
 
 extern char     *nagios_user;
 extern char     *nagios_group;
@@ -230,9 +222,6 @@
 extern int      free_child_process_memory;
 extern int      child_processes_fork_twice;
 
-extern int      enable_embedded_perl;
-extern int      use_embedded_perl_implicitly;
-
 extern int      date_format;
 
 extern contact		*contact_list;
@@ -302,18 +291,6 @@
 	dbuf output_dbuf;
 	int dbuf_chunk = 1024;
 	int flags;
-#ifdef EMBEDDEDPERL
-	char *temp_buffer = NULL;
-	char fname[512] = "";
-	char *args[5] = {"", DO_CLEAN, "", "", NULL };
-	SV *plugin_hndlr_cr = NULL;
-	char *perl_output = NULL;
-	int use_epn = FALSE;
-#ifdef aTHX
-	dTHX;
-#endif
-	dSP;
-#endif
 
 
 	log_debug_info(DEBUGL_FUNCTIONS, 0, "my_system_r()\n");
@@ -330,71 +307,6 @@
 
 	log_debug_info(DEBUGL_COMMANDS, 1, "Running command '%s'...\n", cmd);
 
-#ifdef EMBEDDEDPERL
-
-	/* get"filename" component of command */
-	strncpy(fname, cmd, strcspn(cmd, " "));
-	fname[strcspn(cmd, " ")] = '\x0';
-
-	/* should we use the embedded Perl interpreter to run this script? */
-	use_epn = file_uses_embedded_perl(fname);
-
-	/* if yes, do some initialization */
-	if(use_epn == TRUE) {
-
-		args[0] = fname;
-		args[2] = "";
-
-		if(strchr(cmd, ' ') == NULL)
-			args[3] = "";
-		else
-			args[3] = cmd + strlen(fname) + 1;
-
-		/* call our perl interpreter to compile and optionally cache the compiled script. */
-
-		ENTER;
-		SAVETMPS;
-		PUSHMARK(SP);
-
-		XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-		XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-		XPUSHs(sv_2mortal(newSVpv(args[2], 0)));
-		XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-		PUTBACK;
-
-		call_pv("Embed::Persistent::eval_file", G_EVAL);
-
-		SPAGAIN;
-
-		if(SvTRUE(ERRSV)) {
-			/*
-			 * XXXX need pipe open to send the compilation failure message back to Nagios ?
-			 */
-			(void) POPs ;
-
-			asprintf(&temp_buffer, "%s", SvPVX(ERRSV));
-
-			log_debug_info(DEBUGL_COMMANDS, 0, "Embedded perl failed to compile %s, compile error %s\n", fname, temp_buffer);
-
-			logit(NSLOG_RUNTIME_WARNING, TRUE, "%s\n", temp_buffer);
-
-			my_free(temp_buffer);
-
-			return STATE_UNKNOWN;
-			}
-		else {
-			plugin_hndlr_cr = newSVsv(POPs);
-
-			log_debug_info(DEBUGL_COMMANDS, 0, "Embedded perl successfully compiled %s and returned plugin handler (Perl subroutine code ref)\n", fname);
-
-			PUTBACK ;
-			FREETMPS ;
-			LEAVE ;
-			}
-		}
-#endif
-
 	/* create a pipe */
 	pipe(fd);
 
@@ -454,56 +366,6 @@
 		signal(SIGALRM, my_system_sighandler);
 		alarm(timeout);
 
-
-		/******** BEGIN EMBEDDED PERL CODE EXECUTION ********/
-
-#ifdef EMBEDDEDPERL
-		if(use_epn == TRUE) {
-
-			/* execute our previously compiled script - by call_pv("Embed::Persistent::eval_file",..) */
-			ENTER;
-			SAVETMPS;
-			PUSHMARK(SP);
-
-			XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-			XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-			XPUSHs(plugin_hndlr_cr);
-			XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-			PUTBACK;
-
-			call_pv("Embed::Persistent::run_package", G_ARRAY);
-			/* count is a debug hook. It should always be two (2), because the persistence framework tries to return two (2) args */
-
-			SPAGAIN;
-
-			perl_output = POPpx ;
-			strip(perl_output);
-			strncpy(buffer, (perl_output == NULL) ? "" : perl_output, sizeof(buffer));
-			buffer[sizeof(buffer) - 1] = '\x0';
-			status = POPi ;
-
-			PUTBACK;
-			FREETMPS;
-			LEAVE;
-
-			log_debug_info(DEBUGL_COMMANDS, 0, "Embedded perl ran command %s with output %d, %s\n", fname, status, buffer);
-
-			/* write the output back to the parent process */
-			write(fd[1], buffer, strlen(buffer) + 1);
-
-			/* close pipe for writing */
-			close(fd[1]);
-
-			/* reset the alarm */
-			alarm(0);
-
-			_exit(status);
-			}
-#endif
-		/******** END EMBEDDED PERL CODE EXECUTION ********/
-
-
 		/* run the command */
 		fp = (FILE *)popen(cmd, "r");
 
@@ -2963,134 +2825,6 @@
 
 
 /******************************************************************/
-/******************** EMBEDDED PERL FUNCTIONS *********************/
-/******************************************************************/
-
-/* initializes embedded perl interpreter */
-int init_embedded_perl(char **env) {
-#ifdef EMBEDDEDPERL
-	char **embedding;
-	int exitstatus = 0;
-	int argc = 2;
-	struct stat stat_buf;
-
-	/* make sure the P1 file exists... */
-	if(p1_file == NULL || stat(p1_file, &stat_buf) != 0) {
-
-		use_embedded_perl = FALSE;
-
-		logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: p1.pl file required for embedded Perl interpreter is missing!\n");
-		}
-
-	else {
-
-		embedding = malloc(2 * sizeof(char *));
-		if(embedding == NULL)
-			return ERROR;
-		*embedding = strdup("");
-		*(embedding + 1) = strdup(p1_file);
-
-		use_embedded_perl = TRUE;
-
-		PERL_SYS_INIT3(&argc, &embedding, &env);
-
-		if((my_perl = perl_alloc()) == NULL) {
-			use_embedded_perl = FALSE;
-			logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Could not allocate memory for embedded Perl interpreter!\n");
-			}
-		}
-
-	/* a fatal error occurred... */
-	if(use_embedded_perl == FALSE) {
-
-		logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to errors encountered while initializing the embedded Perl interpreter. (PID=%d)\n", (int)getpid());
-
-		cleanup();
-		exit(ERROR);
-		}
-
-	perl_construct(my_perl);
-	exitstatus = perl_parse(my_perl, xs_init, 2, (char **)embedding, env);
-	if(!exitstatus)
-		exitstatus = perl_run(my_perl);
-
-#endif
-	return OK;
-	}
-
-
-/* closes embedded perl interpreter */
-int deinit_embedded_perl(void) {
-#ifdef EMBEDDEDPERL
-
-	PL_perl_destruct_level = 0;
-	perl_destruct(my_perl);
-	perl_free(my_perl);
-	PERL_SYS_TERM();
-
-#endif
-	return OK;
-	}
-
-
-/* checks to see if we should run a script using the embedded Perl interpreter */
-int file_uses_embedded_perl(char *fname) {
-#ifndef EMBEDDEDPERL
-	return FALSE;
-#else
-	int line;
-	FILE *fp = NULL;
-	char buf[256] = "";
-
-	if(enable_embedded_perl != TRUE)
-		return FALSE;
-
-	/* open the file, check if its a Perl script and see if we can use epn  */
-	fp = fopen(fname, "r");
-	if(fp == NULL)
-		return FALSE;
-
-	/* grab the first line - we should see Perl. go home if not */
-	if (fgets(buf, 80, fp) == NULL || strstr(buf, "/bin/perl") == NULL) {
-		fclose(fp);
-		return FALSE;
-	}
-
-	/* epn directives must be found in first ten lines of plugin */
-	for(line = 1; line < 10; line++) {
-		if(fgets(buf, sizeof(buf) - 1, fp) == NULL)
-			break;
-
-		buf[sizeof(buf) - 1] = '\0';
-
-		/* skip lines not containing nagios 'epn' directives */
-		if(strstr(buf, "# nagios:")) {
-			char *p;
-			p = strstr(buf + 8, "epn");
-			if (!p)
-				continue;
-
-			/*
-			 * we found it, so close the file and return
-			 * whatever it shows. '+epn' means yes. everything
-			 * else means no
-			 */
-			fclose(fp);
-			return *(p - 1) == '+' ? TRUE : FALSE;
-			}
-		}
-
-	fclose(fp);
-
-	return use_embedded_perl_implicitly;
-#endif
-	}
-
-
-
-
-
-/******************************************************************/
 /************************ THREAD FUNCTIONS ************************/
 /******************************************************************/
 
@@ -3941,8 +3675,6 @@
 	my_free(check_result_path);
 	my_free(command_file);
 	my_free(lock_file);
-	my_free(auth_file);
-	my_free(p1_file);
 	my_free(log_archive_path);
 
 	return;
@@ -3977,8 +3709,6 @@
 	check_result_path = (char *)strdup(DEFAULT_CHECK_RESULT_PATH);
 	command_file = (char *)strdup(DEFAULT_COMMAND_FILE);
 	lock_file = (char *)strdup(DEFAULT_LOCK_FILE);
-	auth_file = (char *)strdup(DEFAULT_AUTH_FILE);
-	p1_file = (char *)strdup(DEFAULT_P1_FILE);
 	log_archive_path = (char *)strdup(DEFAULT_LOG_ARCHIVE_PATH);
 	debug_file = (char *)strdup(DEFAULT_DEBUG_FILE);
 
@@ -4104,9 +3834,6 @@
 
 	additional_freshness_latency = DEFAULT_ADDITIONAL_FRESHNESS_LATENCY;
 
-	enable_embedded_perl = DEFAULT_ENABLE_EMBEDDED_PERL;
-	use_embedded_perl_implicitly = DEFAULT_USE_EMBEDDED_PERL_IMPLICITLY;
-
 	external_command_buffer_slots = DEFAULT_EXTERNAL_COMMAND_BUFFER_SLOTS;
 
 	debug_level = DEFAULT_DEBUG_LEVEL;

Modified: nagioscore/trunk/configure.in
===================================================================
--- nagioscore/trunk/configure.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/configure.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -647,58 +647,6 @@
 fi
 
 
-USEPERL=no;
-INSTALLPERLSTUFF=no;
-AC_ARG_ENABLE(embedded-perl,--enable-embedded-perl will enable embedded Perl interpreter,[
-	USEPERL=$enableval
-	]
-	,USEPERL=no)
-
-PERLCACHE=yes;
-AC_ARG_WITH(perlcache,--with-perlcache turns on cacheing of internally compiled Perl scripts,[
-	PERLCACHE=$withval
-	]
-	,[
-	AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl])
-	PERLCACHE=yes;
-	])
-
-dnl Is embedded Perl being compiled in?
-if test x$USEPERL = xyes; then
-
-	AC_DEFINE_UNQUOTED(EMBEDDEDPERL,,[Is embedded Perl being compiled in?])
-	PERLLIBS="`perl -MExtUtils::Embed -e ldopts`" 
-	PERLDIR="`perl -MConfig -e 'print $Config{installsitearch}'`" 
-	CFLAGS="${CFLAGS} `perl -MExtUtils::Embed -e ccopts`" 
-	USEPERL=yes
-	INSTALLPERLSTUFF=yes;
-	PERLXSI_O=perlxsi.o
-	OBJS="${OBJS} ${PERLXSI_O}"
-	echo "creating base/perlxsi.c"
-	perl -MExtUtils::Embed -e xsinit -- -o base/perlxsi.c
-
-	echo "Embedded Perl interpreter will be compiled in..."
-
-	dnl Is caching enabled?
-	if test x$PERLCACHE = xyes; then
-		AC_DEFINE(DO_CLEAN,"0",[whether to clean cached compiled perl])
-		PERLCACHE=yes;
-		echo "Internally compiled Perl scripts will be cached..."
-	else
-		AC_DEFINE(DO_CLEAN,"1",[whether to clean cached compiled perl])
-		echo "Internally compiled Perl scripts will NOT be cached..."
-	fi
-fi
-
-dnl Test if we're using threaded Perl (patch by Chip Ach)
-if test x$USEPERL = xyes; then
-	if (perl -e 'use Config;exit -1 unless ($Config{'usethreads'});'); then
-		echo "Using threaded perl"
-		AC_DEFINE_UNQUOTED(THREADEDPERL,,[defined if we're using threaded Perl])
-	fi
-fi
-
-
 dnl Option for compiling under CYGWIN
 nagios_name=nagios
 nagiostats_name=nagiostats
@@ -781,12 +729,8 @@
 AC_SUBST(USE_LIBTAP)
 AC_SUBST(CGIEXTRAS)
 AC_SUBST(GDLIBS)
-AC_SUBST(PERLLIBS)
-AC_SUBST(PERLDIR)
-AC_SUBST(PERLXSI_O)
 AC_SUBST(BASEEXTRALIBS)
 AC_SUBST(INITDIR)
-AC_SUBST(INSTALLPERLSTUFF)
 AC_SUBST(USE_EVENTBROKER)
 
 AC_PATH_PROG(PERL,perl)
@@ -832,15 +776,6 @@
 AC_MSG_RESULT([        Nagios executable:  $nagios_name])
 AC_MSG_RESULT([        Nagios user/group:  $nagios_user,$nagios_grp])
 AC_MSG_RESULT([       Command user/group:  $command_user,$command_grp])
-if test x$USEPERL = xyes; then
-if test x$PERLCACHE = xyes; then
-AC_MSG_RESULT([            Embedded Perl:  yes, with caching])
-else
-AC_MSG_RESULT([            Embedded Perl:  yes, without caching])
-fi
-else
-AC_MSG_RESULT([            Embedded Perl:  no])
-fi
 if test x$USE_EVENTBROKER = xyes; then
 AC_MSG_RESULT([             Event Broker:  yes])
 else

Modified: nagioscore/trunk/contrib/Makefile.in
===================================================================
--- nagioscore/trunk/contrib/Makefile.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/contrib/Makefile.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -40,7 +40,7 @@
 all: $(ALL)
 
 clean:
-	rm -f convertcfg daemonchk.cgi mini_epn new_mini_epn core *.o
+	rm -f convertcfg daemonchk.cgi core *.o
 	rm -f */*/*~
 	rm -f */*~
 	rm -f *~
@@ -65,18 +65,6 @@
 daemonchk.o: daemonchk.c
 	$(CC) $(CLFAGS) -c -o $@ $< -I$(SRC_INCLUDE)
 
-mini_epn: mini_epn.c
-	perl -MExtUtils::Embed -e xsinit
-	$(CC) $(CFLAGS) -c perlxsi.c  `perl -MExtUtils::Embed -e ccopts`
-	$(CC) $(CFLAGS) -c mini_epn.c `perl -MExtUtils::Embed -e ccopts`
-	$(CC) $(CFLAGS) $(LDFLAGS) perlxsi.o mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` -o $@
-
-new_mini_epn: new_mini_epn.c
-	perl -MExtUtils::Embed -e xsinit
-	$(CC) $(CFLAGS) -c perlxsi.c  `perl -MExtUtils::Embed -e ccopts`
-	$(CC) $(CFLAGS) -c new_mini_epn.c `perl -MExtUtils::Embed -e ccopts`
-	$(CC) $(CFLAGS) $(LDFLAGS) perlxsi.o new_mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` -o $@
-
 ##############################################################################
 # dependencies
 

Deleted: nagioscore/trunk/contrib/epn_nagios.h
===================================================================
--- nagioscore/trunk/contrib/epn_nagios.h	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/contrib/epn_nagios.h	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,26 +0,0 @@
-/******** BEGIN EMBEDDED PERL INTERPRETER DECLARATIONS ********/
-
-#include <EXTERN.h>
-#include <perl.h>
-
-#include <fcntl.h>
-#undef ctime    /* don't need perl's threaded version */
-#undef printf   /* can't use perl's printf until initialized */
-
-/* In perl.h (or friends) there is a macro that defines sighandler as Perl_sighandler, so we must #undef it so we can use our sighandler() function */
-#undef sighandler
-
-
-/* and we don't need perl's reentrant versions */
-#undef localtime
-#undef getpwnam
-#undef getgrnam
-#undef strerror
-
-#ifdef aTHX
-EXTERN_C void xs_init(pTHX);
-#else
-EXTERN_C void xs_init(void);
-#endif
-
-/******** END EMBEDDED PERL INTERPRETER DECLARATIONS ********/

Deleted: nagioscore/trunk/contrib/mini_epn.c
===================================================================
--- nagioscore/trunk/contrib/mini_epn.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/contrib/mini_epn.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,122 +0,0 @@
-/*
-	mini_epn.c
-
-*/
-
-#include <EXTERN.h>
-#include <perl.h>
-#include "epn_nagios.h"
-
-#define MAX_INPUT_CHARS 1024
-
-static PerlInterpreter *my_perl = NULL;
-
-int main(int argc, char **argv, char **env) {
-
-	/*
-	#ifdef aTHX
-		dTHX;
-	#endif
-	*/
-
-	char *embedding[] = { "", "p1.pl" };
-	char *plugin_output ;
-	char fname[MAX_INPUT_CHARS];
-	char *args[] = {"", "0", "", "", NULL };
-	char command_line[MAX_INPUT_CHARS];
-	int exitstatus;
-	int pclose_result;
-
-	if((my_perl = perl_alloc()) == NULL) {
-		printf("%s\n", "Error: Could not allocate memory for embedded Perl interpreter!");
-		exit(1);
-		}
-	perl_construct(my_perl);
-	exitstatus = perl_parse(my_perl, xs_init, 2, embedding, NULL);
-	if(!exitstatus) {
-
-		exitstatus = perl_run(my_perl);
-
-		while(printf("Enter file name: ") && fgets(command_line, MAX_INPUT_CHARS - 1, stdin)) {
-			SV *plugin_hndlr_cr;
-			STRLEN n_a;
-			int count = 0 ;
-
-			dSP;
-
-			command_line[strlen(command_line) - 1] = '\0';
-
-			strncpy(fname, command_line, strcspn(command_line, " "));
-			fname[strcspn(command_line, " ")] = '\x0';
-			args[0] = fname ;
-			args[3] = command_line + strlen(fname) + 1 ;
-
-			args[2] = "";
-
-			/* call our perl interpreter to compile and optionally cache the command */
-
-			ENTER;
-			SAVETMPS;
-			PUSHMARK(SP);
-
-			XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-			XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-			XPUSHs(sv_2mortal(newSVpv(args[2], 0)));
-			XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-			PUTBACK;
-
-			count = call_pv("Embed::Persistent::eval_file", G_SCALAR | G_EVAL);
-
-			SPAGAIN;
-
-			/* check return status  */
-			if(SvTRUE(ERRSV)) {
-				(void) POPs;
-
-				pclose_result = -2;
-				printf("embedded perl ran %s with error %s\n", fname, SvPVX(ERRSV));
-				continue;
-				}
-			else {
-				plugin_hndlr_cr = newSVsv(POPs);
-
-				PUTBACK;
-				FREETMPS;
-				LEAVE;
-				}
-
-			ENTER;
-			SAVETMPS;
-			PUSHMARK(SP);
-
-			XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-			XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-			XPUSHs(plugin_hndlr_cr);
-			XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-			PUTBACK;
-
-			count = perl_call_pv("Embed::Persistent::run_package", G_EVAL | G_ARRAY);
-
-			SPAGAIN;
-
-			plugin_output = POPpx ;
-			pclose_result = POPi ;
-
-			printf("embedded perl plugin return code and output was: %d & '%s'\n", pclose_result, plugin_output);
-
-			PUTBACK;
-			FREETMPS;
-			LEAVE;
-
-			}
-
-		}
-
-
-	PL_perl_destruct_level = 0;
-	perl_destruct(my_perl);
-	perl_free(my_perl);
-	exit(exitstatus);
-	}

Deleted: nagioscore/trunk/contrib/new_mini_epn.c
===================================================================
--- nagioscore/trunk/contrib/new_mini_epn.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/contrib/new_mini_epn.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,255 +0,0 @@
-/*
-	new_mini_epn.c
-
-*/
-
-#include <EXTERN.h>
-#include <perl.h>
-#include "epn_nagios.h"
-
-/*
- * DO_CLEAN must be a pointer to a char string
- */
-
-#define DO_CLEAN "0"
-
-static PerlInterpreter *my_perl = NULL;
-
-/*
- *                                                      <=== Align Right
- *                                                      56 spaces from left margin
- *    Do  N  O  T  use  T  A  B  S  in  #define  code.
- *
- *    Indent level == 4 spaces
- */
-
-#define DO_READLINE                                     \
-    "$_ = defined($term) "                              \
-    "        ? $term->readline($prompt) "               \
-    "        : do    { "                                \
-    "                    print $prompt; "               \
-    "                    chomp($_ = <>); "              \
-    "                    $_; "                          \
-    "                }; "                               \
-    "die qq(That's all folks.\\n) "                     \
-    "    unless $_ && ! /^\\s*$/ ; "                    \
-    "$_; "
-
-#define INIT_TERM_READLINE                              \
-    "use vars qw($term $prompt $OUT); "                 \
-                                                        \
-    "eval { require Term::ReadLine; }; "                \
-    "unless ($@) { "                                    \
-    "    $term = new Term::ReadLine 'new_mini_epn'; "   \
-    "} else { "                                         \
-    "    warn qq(Install Term::ReadLine for arrow key access to history, filename completion etc.); " \
-    "} "                                                \
-                                                        \
-    "$OUT = $term->OUT "                                \
-    "    if defined($term); "                           \
-    "$prompt = 'plugin command line: '; "
-
-void run_plugin(char *command_line) {
-
-#ifdef aTHX
-	dTHX;
-#endif
-
-	SV *plugin_hndlr_cr ;
-	STRLEN n_a ;
-	int count = 0 ;
-	int pclose_result;
-	char *plugin_output;
-	char fname[128];
-	char *args[] = {"", "", "", "", NULL };
-
-	dSP;
-
-	strncpy(fname, command_line, strcspn(command_line, " "));
-	fname[strcspn(command_line, " ")] = '\0';
-
-	/*
-	 * Arguments passsed to Perl sub Embed::Persistent::run_package
-	 */
-
-	/*
-	 * filename containing plugin
-	 */
-	args[0] = fname ;
-	/*
-	 * Do _not_ cache the compiled plugin
-	 */
-	args[1] = DO_CLEAN ;
-	/*
-	 * pointer to plugin arguments
-	 */
-
-	args[3] = command_line + strlen(fname) + 1 ;
-
-	ENTER;
-	SAVETMPS;
-	PUSHMARK(SP);
-
-	XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-	XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-	XPUSHs(sv_2mortal(newSVpv(args[2], 0)));
-	XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-	PUTBACK;
-
-	call_pv("Embed::Persistent::eval_file", G_SCALAR | G_EVAL);
-
-	SPAGAIN ;
-
-	if(SvTRUE(ERRSV)) {
-		(void) POPs;
-
-		printf("embedded perl compiled plugin %s with error: %s - skipping plugin\n", fname, SvPVX(ERRSV));
-		return;
-		}
-	else {
-		plugin_hndlr_cr = newSVsv(POPs);
-
-		PUTBACK ;
-		FREETMPS ;
-		LEAVE ;
-		}
-	/*
-	 * Push the arguments to Embed::Persistent::run_package onto
-	 * the Perl stack.
-	 */
-	ENTER;
-	SAVETMPS;
-	PUSHMARK(SP);
-
-	XPUSHs(sv_2mortal(newSVpv(args[0], 0)));
-	XPUSHs(sv_2mortal(newSVpv(args[1], 0)));
-	XPUSHs(plugin_hndlr_cr);
-	XPUSHs(sv_2mortal(newSVpv(args[3], 0)));
-
-	PUTBACK;
-
-	count = call_pv("Embed::Persistent::run_package", G_ARRAY);
-
-	SPAGAIN;
-
-	plugin_output = POPpx ;
-	pclose_result = POPi ;
-
-	printf("embedded perl plugin return code and output was: %d & %s\n", pclose_result, plugin_output) ;
-
-	PUTBACK;
-	FREETMPS;
-	LEAVE;
-
-	return ;
-
-	}
-
-SV * my_eval_pv(char *pv) {
-
-	SV* result;
-
-	/*
-	 * eval_pv(..., TRUE) means die if Perl traps an error
-	 */
-	result = eval_pv(pv, TRUE) ;
-	return result ;
-	}
-
-char * get_command_line(void) {
-
-	/* debug
-	 * printf("%s\n", INIT_TERM_READLINE) ;
-	 */
-	SV *cmd_line ;
-	char *command_line ;
-
-	cmd_line	= my_eval_pv(DO_READLINE) ;
-	command_line	= SvPVX(cmd_line) ;
-	/* command_line	= SvPV(cmd_line, n_a) ; */
-	return command_line ;
-	}
-
-void init_term_readline(void) {
-	(void) my_eval_pv(INIT_TERM_READLINE) ;
-	}
-
-void init_embedded_perl(void) {
-	char *embedding[] = { "", "p1.pl" };
-	/* embedding takes the place of argv[] ($argv[0] is the program name.
-	 * - which is not given to Perl).
-	 * Note that the number of args (ie the number of elements in embedding
-	 * [argc] is the third argument of perl_parse().
-	 */
-	int exitstatus;
-	char buffer[132];
-
-	if((my_perl = perl_alloc()) == NULL) {
-		snprintf(buffer, sizeof(buffer), "Error: Could not allocate memory for embedded Perl interpreter!\n");
-		buffer[sizeof(buffer) - 1] = '\x0';
-		printf("%s\n", buffer);
-		exit(1);
-		}
-
-	perl_construct(my_perl);
-	exitstatus = perl_parse(my_perl, xs_init, 2, embedding, NULL);
-	PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
-	/* Why is perl_run() necessary ?
-	 * It is needed if the code parsed by perl_parse() has
-	 * any runtime semantics (eg code that gets eval'd,
-	 * behaviour that depends on constants etc).
-	 */
-	exitstatus = perl_run(my_perl);
-
-	if(exitstatus) {
-		printf("%s\n", "perl_run() failed.");
-		exit(1);
-		}
-	}
-
-void deinit_embedded_perl(void) {
-
-	PL_perl_destruct_level = 0;
-	perl_destruct(my_perl);
-	perl_free(my_perl);
-	}
-
-
-int main(int argc, char **argv, char **env) {
-
-	init_embedded_perl();
-	/* Calls Perl to load and construct a new
-	 * Term::ReadLine object.
-	 */
-
-	init_term_readline();
-
-	while(1) {
-		/*
-		 * get_command_line calls Perl to get a scalar from stdin
-		 */
-
-		/* Perl Term::ReadLine::readline() method chomps the "\n"
-		 * from the end of the input.
-		 */
-		char *cmd, *end;
-		/* Allow any length command line */
-		cmd = (get_command_line()) ;
-
-		// Trim leading whitespace
-		while(isspace(*cmd)) cmd++;
-
-		// Trim trailing whitespace
-		end = cmd + strlen(cmd) - 1;
-		while(end > cmd && isspace(*end)) end--;
-
-		// Write new null terminator
-		*(end + 1) = 0;
-
-		run_plugin(cmd) ;
-		}
-
-	deinit_embedded_perl();
-	}
-

Deleted: nagioscore/trunk/contrib/p1.pl
===================================================================
--- nagioscore/trunk/contrib/p1.pl	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/contrib/p1.pl	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,851 +0,0 @@
- package Embed::Persistent;
-
-# $Id$
-
-# $Log$
-# Revision 1.5  2005-01-18 13:52:15+11  anwsmh
-# 1 Set log level back to RETICENT and log file name to a placeholder for dist.
-#
-# Revision 1.4  2005-01-18 13:26:12+11  anwsmh
-# 1 Major changes for Perl >= 5.6
-#   1.1 tieing STDERR to ErrorTrap caused a SEGV in libperl because of
-#       misuse of the open statement.
-#   1.2 STDERR is now aliased to the handle associated with a log file
-#       opened if logging is enabled.
-#
-
-
-# p1.pl for Nagios 2.0
-
-# Only major changes are that STDOUT is redirected to a scalar
-# by means of a tied filehandle so that it can be returned to Nagios
-# without the need for a syscall to read()
-#
-
-use strict ;
-use vars '%Cache' ;
-use Text::ParseWords qw(parse_line) ;
-
-use constant RETICENT	=> 1 ;
-use constant GARRULOUS	=> 0 ;
-use constant DEBUG		=> 0 ;
-
-use constant EPN_STDERR_LOG => '/Path/to/embedded/Perl/Nagios/Logfile' ;
-
-use constant TEXT_RETICENT	=> <<'RETICENT' ;
-
-package OutputTrap;
-
-#
-# Methods for use by tied STDOUT in embedded PERL module.
-#
-# Simply ties STDOUT to a scalar and emulates serial semantics.
-#
- 
-sub TIEHANDLE {
-	my ($class) = @_;
-        my $me ;
-	bless \$me, $class;
-}
-
-sub PRINT {
-	my $self = shift;
-	$$self .= join("", at _);
-}
-
-sub PRINTF {
-	my $self = shift;
-	my $fmt = shift;
-	$$self .= sprintf($fmt, at _);
-}
-
-sub READLINE {
-	my $self = shift;
-	# Perl code other than plugins may print nothing; in this case return "(No output!)\n".
-	return(defined $$self ? $$self : "(No output!)\n");
-}
-
-sub CLOSE {
-	my $self = shift;
-}
-
-package Embed::Persistent;
-
-sub valid_package_name {
-	my($string) = @_;
-	$string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
-	# second pass only for words starting with a digit
-	$string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
-	
-	# Dress it up as a real package name
-	$string =~ s|/|::|g;
-	return "Embed::" . $string;
- }
-
-# Perl 5.005_03 only traps warnings for errors classed by perldiag
-# as Fatal (eg 'Global symbol """"%s"""" requires explicit package name').
-# Therefore treat all warnings as fatal.
-
-sub throw_exception {
-	my $warn = shift ;
-	return if $warn =~ /^Subroutine CORE::GLOBAL::exit redefined/ ;
-	die $warn ;
-}
-
-sub eval_file {
-	my $filename = shift;
-	my $delete = shift;
-
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $mtime = -M $filename ;
-	if ( defined $Cache{$package}{mtime} &&
-	     $Cache{$package}{mtime} <= $mtime) {
-		# we have compiled this subroutine already,
-		# it has not been updated on disk, nothing left to do
-	}
-	else {
-		local *FH;
-		# FIXME - error handling
-		open FH, $filename or die "'$filename' $!";
-		local($/) = undef;
-		my $sub = <FH>;
-		close FH;
-		# cater for routines that expect to get args without progname
-		# and for those using @ARGV
-		$sub = qq(\nshift(\@_);\n\@ARGV=\@_;\nlocal \$^W=1;\n$sub) ;
-
-		# cater for scripts that have embedded EOF symbols (__END__)
-		$sub =~ s/__END__/\;}\n__END__/;
-
-		# wrap the code into a subroutine inside our unique package
-		my $eval = qq{
-			package main;
-			use subs 'CORE::GLOBAL::exit';
-			sub CORE::GLOBAL::exit { die "ExitTrap: \$_[0] ($package)"; }
-			package $package; sub hndlr { $sub }
-			};
-		$Cache{$package}{plugin_error} = 0 ;
-		# suppress warning display.
-		local $SIG{__WARN__} = \&throw_exception ;
-		{
-			# hide our variables within this block
-			my ($filename, $mtime, $package, $sub);
-			eval $eval;
-		}
-		# $@ is set for any warning and error. This guarantees that the plugin will not be run.
-		if ($@) {
-			# Log eval'd text of plugin.
-			# Correct the line number of the error by removing the lines added (the subroutine prologue) by Embed::eval_file.
-			my $i = 1 ;
-			$eval =~ s/^/sprintf('%10d  ', $i++)/meg ;
-			$Cache{$package}{plugin_error} = $@ ;
-        		$Cache{$package}{mtime} = $mtime unless $delete;
-			# If the compilation fails, leave nothing behind that may affect subsequent compilations.
-			die;
-		
-		}
-
-        	#cache it unless we're cleaning out each time
-        	$Cache{$package}{mtime} = $mtime unless $delete;
-
-	}
-}
-
-sub run_package {
-	my $filename = shift;
-	my $delete = shift;
-	my $tmpfname = shift;
-	my $ar = shift;
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $res = 3;
-
-	tie (*STDOUT, 'OutputTrap');
-
-	my @a = &parse_line('\s+', 0, $ar) ;
-
-	if ( $Cache{$package}{plugin_error} ) {
-		untie *STDOUT;
-		# return unknown
-		return (3, '**ePN' . " '$pn' " . $Cache{$package}{plugin_error} . "\n") ;
-	}
-     
-	local $SIG{__WARN__} = \&throw_exception ;
-	eval { $package->hndlr(@a); };
-
-	if ($@) {
-		if ($@ =~ /^ExitTrap:  /) {
-			# For normal plugin exit the  ExitTrap string is set by the 
-			# redefined CORE::GLOBAL::exit sub calling die to return a string =~ /^ExitTrap: -?\d+ $package/
-			# However, there is only _one_ exit sub so the last plugin to be compiled sets _its_
-			# package name.
-			$res = 0;
-		} else {
-              		# get return code (which may be negative)
-			if ($@ =~ /^ExitTrap: (-?\d+)/) {
-				$res = $1;
-			} else {
-				# run time error/abnormal plugin termination; exit was not called in plugin
-				# return unknown
-				$res = 3;
-				
-				chomp $@ ;
-				# correct line number reported by eval for the prologue added by eval_file
-				$@ =~ s/(\d+)\.$/($1 - 8)/e ;
-				print STDOUT '**ePN', " '$pn' ",  $@, "\n" ;
-				# Don't run it again until the plugin is recompiled (clearing $Cache{$package}{plugin_error})
-				# Note that the plugin should be handle any run time errors (such as timeouts)
-				# that may occur in service checking.
-
-				# FIXME - doesn't work under both 5.005 and 5.8.0. The cached value of plugin error is reset somehow.
-				# $Cache{$package}{plugin_error} = $@ ;
-			}
-		}
-	}
-	# !!
-	my $plugin_output = <STDOUT> ;
-	untie *STDOUT;
-	return ($res, $plugin_output) ;
-}
-
-1;
-
-RETICENT
-
-use constant TEXT_GARRULOUS	=> <<'GARRULOUS' ;
-
-BEGIN {
-	open STDERRLOG, '>> ' . EPN_STDERR_LOG 
-		or die "Can't open '" . EPN_STDERR_LOG . " for append: $!" ;
-}
-
-package OutputTrap;
-
-#
-# Methods for use by tied STDOUT in embedded PERL module.
-#
-# Simply ties STDOUT to a scalar and emulates serial semantics.
-#
- 
-sub TIEHANDLE {
-	my ($class) = @_;
-        my $me ;
-	bless \$me, $class;
-}
-
-sub PRINT {
-	my $self = shift;
-	$$self .= join("", at _);
-}
-
-sub PRINTF {
-	my $self = shift;
-	my $fmt = shift;
-	$$self .= sprintf($fmt, at _);
-}
-
-sub READLINE {
-	my $self = shift;
-	# Perl code other than plugins may print nothing; in this case return "(No output!)\n".
-	return(defined $$self ? $$self : "(No output!)\n");
-}
-
-sub CLOSE {
-	my $self = shift;
-}
-
-package Embed::Persistent;
-
-sub valid_package_name {
-	my($string) = @_;
-	$string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
-	# second pass only for words starting with a digit
-	$string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
-	
-	# Dress it up as a real package name
-	$string =~ s|/|::|g;
-	return "Embed::" . $string;
- }
-
-# Perl 5.005_03 only traps warnings for errors classed by perldiag
-# as Fatal (eg 'Global symbol """"%s"""" requires explicit package name').
-# Therefore treat all warnings as fatal.
-
-sub throw_exception {
-	my $warn = shift ;
-	return if $warn =~ /^Subroutine CORE::GLOBAL::exit redefined/ ;
-	die $warn ;
-}
-
-sub eval_file {
-	my $filename = shift;
-	my $delete = shift;
-
-	*STDERR = *STDERRLOG ;
-	
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $mtime = -M $filename ;
-	if ( defined $Cache{$package}{mtime} &&
-	     $Cache{$package}{mtime} <= $mtime) {
-		# we have compiled this subroutine already,
-		# it has not been updated on disk, nothing left to do
-	}
-	else {
-		local *FH;
-		# FIXME - error handling
-		open FH, $filename or die "'$filename' $!";
-		local($/) = undef;
-		my $sub = <FH>;
-		close FH;
-		# cater for routines that expect to get args without progname
-		# and for those using @ARGV
-		$sub = qq(\nshift(\@_);\n\@ARGV=\@_;\nlocal \$^W=1;\n$sub) ;
-
-		# cater for scripts that have embedded EOF symbols (__END__)
-		$sub =~ s/__END__/\;}\n__END__/;
-
-		# wrap the code into a subroutine inside our unique package
-		my $eval = qq{
-			package main;
-			use subs 'CORE::GLOBAL::exit';
-			sub CORE::GLOBAL::exit { die "ExitTrap: \$_[0] ($package)"; }
-			package $package; sub hndlr { $sub }
-			};
-		$Cache{$package}{plugin_error} = 0 ;
-		# suppress warning display.
-		local $SIG{__WARN__} = \&throw_exception ;
-		{
-			# hide our variables within this block
-			my ($filename, $mtime, $package, $sub);
-			eval $eval;
-		}
-		# $@ is set for any warning and error. This guarantees that the plugin will not be run.
-		if ($@) {
-			# Log eval'd text of plugin.
-			# Correct the line number of the error by removing the lines added (the subroutine prologue) by Embed::eval_file.
-			my $i = 1 ;
-			$eval =~ s/^/sprintf('%10d  ', $i++)/meg ;
-			print STDERR '[', time(), ']', qq( **ePN '$pn' error '$@' in text "\n$eval"\n) ;
-			$Cache{$package}{plugin_error} = $@ ;
-        		$Cache{$package}{mtime} = $mtime unless $delete;
-			# If the compilation fails, leave nothing behind that may affect subsequent compilations.
-			die;
-		
-		}
-
-        	#cache it unless we're cleaning out each time
-        	$Cache{$package}{mtime} = $mtime unless $delete;
-
-	}
-}
-
-sub run_package {
-	my $filename = shift;
-	my $delete = shift;
-	my $tmpfname = shift;
-	my $ar = shift;
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $res = 3;
-
-	tie (*STDOUT, 'OutputTrap');
-
-	my @a = &parse_line('\s+', 0, $ar) ;
-
-	if ( $Cache{$package}{plugin_error} ) {
-		untie *STDOUT;
-		# return unknown
-		return (3, '**ePN' . " '$pn' " . $Cache{$package}{plugin_error} . "\n") ;
-	}
-     
-	local $SIG{__WARN__} = \&throw_exception ;
-	eval { $package->hndlr(@a); };
-
-	if ($@) {
-		if ($@ =~ /^ExitTrap:  /) {
-			# For normal plugin exit the  ExitTrap string is set by the 
-			# redefined CORE::GLOBAL::exit sub calling die to return a string =~ /^ExitTrap: -?\d+ $package/
-			# However, there is only _one_ exit sub so the last plugin to be compiled sets _its_
-			# package name.
-			$res = 0;
-		} else {
-              		# get return code (which may be negative)
-			if ($@ =~ /^ExitTrap: (-?\d+)/) {
-				$res = $1;
-			} else {
-				# run time error/abnormal plugin termination; exit was not called in plugin
-				# return unknown
-				$res = 3;
-				
-				chomp $@ ;
-				# correct line number reported by eval for the prologue added by eval_file
-				$@ =~ s/(\d+)\.$/($1 - 8)/e ;
-				print STDOUT '**ePN', " '$pn' ",  $@, "\n" ;
-				# Don't run it again until the plugin is recompiled (clearing $Cache{$package}{plugin_error})
-				# Note that the plugin should be handle any run time errors (such as timeouts)
-				# that may occur in service checking.
-
-				# FIXME - doesn't work under both 5.005 and 5.8.0. The cached value of plugin error is reset somehow.
-				# $Cache{$package}{plugin_error} = $@ ;
-			}
-		}
-	}
-	# !!
-	my $plugin_output = <STDOUT> ;
-	untie *STDOUT;
-	return ($res, $plugin_output) ;
-}
-
-1;
-
-GARRULOUS
-
-use constant TEXT_DEBUG		=> <<'DEBUG' ;
-
-BEGIN {
-	open STDERRLOG, '>> ' . EPN_STDERR_LOG
-		or die "Can't open '" . EPN_STDERR_LOG . " for append: $!" ;
-}
-
-package OutputTrap;
-
-#
-# Methods for use by tied STDOUT in embedded PERL module.
-#
-# Simply ties STDOUT to a scalar and emulates serial semantics.
-#
- 
-sub TIEHANDLE {
-	my ($class) = @_;
-        my $me ;
-	bless \$me, $class;
-}
-
-sub PRINT {
-	my $self = shift;
-	$$self .= join("", at _);
-}
-
-sub PRINTF {
-	my $self = shift;
-	my $fmt = shift;
-	$$self .= sprintf($fmt, at _);
-}
-
-sub READLINE {
-	my $self = shift;
-	# Perl code other than plugins may print nothing; in this case return "(No output!)\n".
-	return(defined $$self ? $$self : "(No output!)\n");
-}
-
-sub CLOSE {
-	my $self = shift;
-}
-
-package Embed::Persistent;
-
-sub valid_package_name {
-	my($string) = @_;
-	$string =~ s/([^A-Za-z0-9\/])/sprintf("_%2x",unpack("C",$1))/eg;
-	# second pass only for words starting with a digit
-	$string =~ s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
-	
-	# Dress it up as a real package name
-	$string =~ s|/|::|g;
-	return "Embed::" . $string;
- }
-
-# Perl 5.005_03 only traps warnings for errors classed by perldiag
-# as Fatal (eg 'Global symbol """"%s"""" requires explicit package name').
-# Therefore treat all warnings as fatal.
-
-sub throw_exception {
-	my $warn = shift ;
-	return if $warn =~ /^Subroutine CORE::GLOBAL::exit redefined/ ;
-	print STDERR " ... throw_exception: calling die $warn\n" ;
-	die $warn ;
-}
-
-sub eval_file {
-	my $filename = shift;
-	my $delete = shift;
-
-	*STDERR = *STDERRLOG ;
-	
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $mtime = -M $filename ;
-	if ( defined $Cache{$package}{mtime} &&
-	     $Cache{$package}{mtime} <= $mtime) {
-		# we have compiled this subroutine already,
-		# it has not been updated on disk, nothing left to do
-		print STDERR "(I) \$mtime: $mtime, \$Cache{$package}{mtime}: '$Cache{$package}{mtime}' - already compiled $package->hndlr.\n";
-	}
-	else {
-		print STDERR "(I) \$mtime: $mtime, \$Cache{$package}{mtime}: '$Cache{$package}{mtime}' - Compiling or recompiling \$filename: $filename.\n" ;
-		local *FH;
-		# FIXME - error handling
-		open FH, $filename or die "'$filename' $!";
-		local($/) = undef;
-		my $sub = <FH>;
-		close FH;
-		# cater for routines that expect to get args without progname
-		# and for those using @ARGV
-		$sub = qq(\nshift(\@_);\n\@ARGV=\@_;\nlocal \$^W=1;\n$sub) ;
-
-		# cater for scripts that have embedded EOF symbols (__END__)
-		$sub =~ s/__END__/\;}\n__END__/;
-
-		# wrap the code into a subroutine inside our unique package
-		my $eval = qq{
-			package main;
-			use subs 'CORE::GLOBAL::exit';
-			sub CORE::GLOBAL::exit { die "ExitTrap: \$_[0] ($package)"; }
-			package $package; sub hndlr { $sub }
-			};
-		$Cache{$package}{plugin_error} = 0 ;
-		# suppress warning display.
-		local $SIG{__WARN__} = \&throw_exception ;
-		{
-			# hide our variables within this block
-			my ($filename, $mtime, $package, $sub);
-			eval $eval;
-		}
-		# $@ is set for any warning and error. This guarantees that the plugin will not be run.
-		if ($@) {
-			# Log eval'd text of plugin.
-			# Correct the line number of the error by removing the lines added (the subroutine prologue) by Embed::eval_file.
-			# $@ =~ s/line (\d+)\.\n/'line ' . ($1 - 8) . ".\n"/ge ;
-			my $i = 1 ;
-			$eval =~ s/^/sprintf('%10d  ', $i++)/meg ;
-			print STDERR '[', time(), ']', qq( **ePN '$pn' error '$@' in text "\n$eval"\n) ;
-			$Cache{$package}{plugin_error} = $@ ;
-        		$Cache{$package}{mtime} = $mtime unless $delete;
-			# If the compilation fails, leave nothing behind that may affect subsequent compilations.
-			die;
-		
-		}
-
-        	#cache it unless we're cleaning out each time
-        	$Cache{$package}{mtime} = $mtime unless $delete;
-
-	}
-}
-
-sub run_package {
-	my $filename = shift;
-	my $delete = shift;
-	my $tmpfname = shift;
-	my $ar = shift;
-	my $pn = substr($filename, rindex($filename,"/")+1);
-	my $package = valid_package_name($pn);
-	my $res = 3;
-
-	use Data::Dumper ;
-	print STDERR Data::Dumper->Dump([\%Cache], [qw(%Cache)]) ;
-
-	tie (*STDOUT, 'OutputTrap');
-
-	my @a = &parse_line('\s+', 0, $ar) ;
-
-	if ( $Cache{$package}{plugin_error} ) {
-		untie *STDOUT;
-		# return unknown
-		print STDERR " ... eval failed in eval_file, run_package returning (3, **ePN '$pn' '$Cache{$package}{plugin_error}'\\n)\n" ;
-		return (3, '**ePN' . " '$pn' " . $Cache{$package}{plugin_error} . "\n") ;
-	}
-     
-	local $SIG{__WARN__} = \&throw_exception ;
-	eval { $package->hndlr(@a); };
-
-	if ($@) {
-		if ($@ =~ /^ExitTrap:  /) {
-			# For normal plugin exit the  ExitTrap string is set by the 
-			# redefined CORE::GLOBAL::exit sub calling die to return a string =~ /^ExitTrap: -?\d+ $package/
-			# However, there is only _one_ exit sub so the last plugin to be compiled sets _its_
-			# package name.
-			$res = 0;
-		} else {
-              		# get return code (which may be negative)
-			if ($@ =~ /^ExitTrap: (-?\d+)/) {
-				$res = $1;
-			} else {
-				# run time error/abnormal plugin termination; exit was not called in plugin
-				# return unknown
-				$res = 3;
-				
-				chomp $@ ;
-				# correct line number reported by eval for the prologue added by eval_file
-				$@ =~ s/(\d+)\.$/($1 - 8)/e ;
-				print STDOUT '**ePN', " '$pn' ",  $@, "\n" ;
-				# Don't run it again until the plugin is recompiled (clearing $Cache{$package}{plugin_error})
-				# Note that the plugin should be handle any run time errors (such as timeouts)
-				# that may occur in service checking.
-
-				# FIXME - doesn't work under both 5.005 and 5.8.0. The cached value of plugin error is reset somehow.
-				# $Cache{$package}{plugin_error} = $@ ;
-			}
-		}
-	}
-	# !!
-	my $plugin_output = <STDOUT> ;
-	untie *STDOUT;
-	print STDERR " ... run_package returning ('$res', '$plugin_output')\n" ;
-	return ($res, $plugin_output) ;
-}
-
-1;
-
-DEBUG
-
-SWITCH: {
-	eval TEXT_RETICENT,	last SWITCH if RETICENT ;
-	eval TEXT_GARRULOUS,	last SWITCH if GARRULOUS ;
-	eval TEXT_DEBUG,	last SWITCH if DEBUG ;
-	die "Please set one of (use constant statements) RETICENT, GARRULOUS or DEBUG in code.\n" ;
-} 
-
-1 ;
-
-=head1 NAME
-
-p1.pl - Perl program to provide Perl code persistence for the Nagios project (http://www.Nagios.Org).
-
-This program attempts to provide a mod_perl like facility for Nagios.
-
-=head1 SYNOPSIS
-
-Edit the text to set the values of (the 'use constant' statements) the log path, B<EPN_STDERR_LOG>, and any one
-(only) of the boolean log level flags B<GARRULOUS>, B<DEBUG>, and B<RETICENT>. The default is to set RETICENT, and
-to use S<<path_to_Nagios>/var/epn_stderr.log> as the log path.
-
-The log level flags determine the amount and type of messages logged in the log path.
-
-The RETICENT log level results in similar behaviour to former versions of p1.pl.
-In particular, the log file EPN_STDERR_LOG will B<not> be opened.
-
-=head1 DESCRIPTION
-
-Nagios is a program to monitor service availability; it does this by scheduling 'plugins' - discrete programs
-that check a service and output a line of text describing the service state intended for
-those responsible for the service and exit with a coded value to relay the same information to Nagios.
-
-Plugins, like CGIs, can be coded in Perl. The persistence framework embeds a Perl interpreter in Nagios to
-
-=over 4
-
-=item * reduce the time taken for the Perl compile and execute cycle.
-
-=item * eliminate the need for the shell to fork and exec Perl.
-
-=item * eliminate the need for Nagios to fork a process (with popen) to run the Perl code.
-
-=item * eliminate reloading of frequently used modules.
-
-=back
-
-and all the good things mentioned in the B<perlembed> man page under 'Maintaining a persistent interpreter'.
-
-Plugin syntax errors (possibly introduced when the plugin is transformed by the persistence framework) and run-time
-errors are logged depending on the log level flags.
-
-Regardless of the log level, plugin run-time and syntax errors, are returned to Nagios as the 'plugin output'. These messages
-appear in the Nagios log like S<**ePN 'check_test' Global symbol "$status" requires explicit package name at (eval 54) line 15.>
-
-=over 4
-
-=item * GARRULOUS
-
-=over 8
-
-=item 1 opens an extra output stream in the path given by the value of EPN_STDERR_LOG.
-
-=item 2 logs a listing of plugin errors, followed by a dump of the plugin source - as transformed by
-the persistence framework - each time the plugin source file modification time stamp is changed (either
-by correcting the syntax error or touching the file).
-
-=back
-
-An example of such a listing is
-
- [1074760243] **ePN 'check_test' error 'Global symbol "$status" requires explicit package name at (eval 54) line 15.  ' in text "
- 1  
- 2                      package main;
- 3                      use subs 'CORE::GLOBAL::exit';
- 4                      sub CORE::GLOBAL::exit { die "ExitTrap: $_[0] (Embed::check_5ftest)"; }
- 5                      package Embed::check_5ftest; sub hndlr { 
- 6  shift(@_);
- 7  @ARGV=@_;
- 8  local $^W=1;
- 9  #!/usr/bin/perl -w
- 10  
- 11  # This plugin always does what it is told.
- 12  
- 13  use strict ;
- 14  
- 15     $status = shift @ARGV ;
- 16  # my $status = shift @ARGV ;
- 17     $status ||= 'fail' ;
- 18  
- 19  my $invert = 1 ;
- 20  
- 21  $status = lc($status) ;
- 22  
- 23  $status = ( ( $invert and $status eq 'ok'   ) ? 'fail' :
- 24          ( $invert and $status eq 'fail' ) ? 'ok'   :
- 25                                               $status ) ;
- 26  
- 27  $status eq 'ok' and do {
- 28      print "Ok. Got a \"$status\". Expecting \"OK\".\n" ;
- 29      exit 0 ;
- 30  } ;
- 31  
- 32  $status eq 'fail' and do {
- 33      print "Failed. Got a \"$status\". Expecting \"FAIL\".\n" ;
- 34      exit 2 ;
- 35  } ;
- 36  
- 37  # print "Mmmm. Looks like I got an "$status\" when expecting an \"ok\" or \"fail\".\n" ;
- 38  print "Mmmm. Looks like I got an \"$status\" when expecting an \"ok\" or \"fail\".\n" ;
- 39  exit 3 ;
- 40   }
- 41                      "
-
-Note that the plugin text (lines 9 to 39 inclusive) has been transformed by the persistence frame work to
-E<10>1 override the exit sub in package main
-
-E<10>2 create a new package from the plugin file name, here Embed::check_5ftest
-
-E<10>3 wrap the plugin in a subroutine named hndlr within the new package
-
-E<10>4 handle the argument list the same way as for a method call, restoring @ARGV from the remaining
-arguments
-
-E<10>5 Setting the warning level to trap all warnings (note that the -w option to Perl is no
-longer significant because the shebang line is not fed to exec()).
-
-=item * DEBUG
-
-This setting is intended only for hacking this code. In addition to the garrulous messages
-
-=over 8
-
-=item 1 enter, leave messages
-
-=item 2 dump of %Cache data structure
-
-=back
-
-=item * RETICENT
-
-This is the default verbosity level and recommended for production use. One line only of compile or run
-time errors is reported in the Nagios log. There are no other output streams.
-
-=back
-
-=head1 SUBROUTINES
-
-Unless otherwise stated, all subroutines take two (2) arguments :-
-
-=over 4
-
-=item 1 plugin_filename - string (called from C) or scalar(called from Perl): the path to the plugin.
-
-=item 2 DO_CLEAN - boolean: set if plugin is not to be cached. Defaults to 0.
-
-Setting this flag means that the plugin is compiled each time it is executed. Nagios B<never> sets this flag when the 
-Nagios is compiled with the configure setting --with-perlcache.
-
-=back 
-
-=over 4
-
-=item Embed::Persistent::eval_file( plugin_filename, DO_CLEAN )
-
-E<10>
-Returns nothing.
-
-
-eval_file() transforms the plugin to a subroutine in a package, compiles the string containing the
-transformed plugin, caches the plugin file modification time (to avoid recompiling it), and caches
-any errors returned by the compilation.
-
-If the plugin has been modified or has not been compiled before,  the plugin is transformed to a subroutine in a new package by 
-
-creating a package name from the plugin file name (C<Embed::Persistent::valid_package_name>)
-
-turning off subroutine redefinition warnings (C<use subs 'CORE::GLOBAL::exit'>)
-
-overriding CORE::GLOBAL::exit from within package main (C<sub CORE::GLOBAL::exit { die "ExitTrap: \$_[0] ($package)"; }>)
-This allows the plugin to call exit without taking down the persistence framework.
-
-prepending the plugin text with code to let the plugin function as a subroutine. This code sets up
-the plugin argument vector (@ARGV) from the subroutine arguments and turns on warnings.
-(C<$sub = qq(\nshift(\@_);\n\@ARGV=\@_;\nlocal \$^W=1;\n$sub)>).
-
-writing the plugin as the subroutine named 'hndlr' in the new package (C<package $package; sub hndlr { $sub }>)
-
-
-The plugin compilation, performed by C<eval $eval>, caches C<$@> if the transformed plugin has syntax errors.
-
-
-=item Embed::Persistent::run_package( plugin_filename, DO_CLEAN, '', plugin_argument_string )
-
-E<10>
-Returns (plugin_return_code, plugin_output)
-
-run_package()
-
-=back
-
-=head1 BUGS
-
-This framework does nothing to prevent the memory leaks mentioned in B<perlembed>, relying on operator intervention.
-
-Probably the best way of doing so is by periodically scheduling 
-
-=over 4
-
-=item 1 A check of the memory used by the Nagios process  (by running for example the standard Nagios plugin check_vsz)
-
-=item 2 Restarting Nagios with the (supplied with Nagios) startup script (restart command).
-
-
-=back
-
-If you do periodocally restart Nagios, make sure that 
-
-=over 4
-
-=item 1 plugins all set the PATH environment variable if they need other system binaries (otherwise, if the
-init script is excec'd by cron, the PATH will be reset and the plugins will fail - but only when reatsrted by cron).
-
-=item 2 that the group owning the Nagios command pipe is the same as the Nagios group (otherwise, the restarted
-Nagios will not be able to read from the command pipe).
-
-=back
-
-Nagios installations using the persistence framework must monitor the memory use of the Nagios process and stop/start it when
-the usage is exorbidant (eg, for a site with 400 services on 200 hosts and custom Perl plugins used for about 10% of the
-service checks, the Nagios process uses ~80 MB after 20-30 days runningi with Perl 5.005 [Memory usage is
-B<much> greater with recent Perls]. It is usually stopped and started at this point).
-
-Note that a HUP signal is B<not> sufficient to deallocate the Perl memory; the Nagios process must be stopped and started.
-
-
-=head1 AUTHOR
-
-Originally by Stephen Davies.
-
-Now maintained by Stanley Hopcroft <hopcrofts at cpan.org> who retains responsibility for the 'bad bits'.
-
-=head1 COPYRIGHT
-
-Copyright (c) 2004 Stanley Hopcroft. All rights reserved.
-This program is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=cut
-

Modified: nagioscore/trunk/include/config.h.in
===================================================================
--- nagioscore/trunk/include/config.h.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/include/config.h.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -30,12 +30,6 @@
 /* Event broker integration */
 #undef USE_EVENT_BROKER
 
-/* Embed a PERL interpreter into Nagios with optional cache for compiled code (contributed by Stephen Davies) */
-#undef EMBEDDEDPERL
-#undef THREADEDPERL
-/* 0 = cache, 1 = do not cache */
-#define DO_CLEAN		"1"
-
 /* commands used by CGIs */
 #undef TRACEROUTE_COMMAND
 #undef PING_COMMAND

Modified: nagioscore/trunk/include/locations.h.in
===================================================================
--- nagioscore/trunk/include/locations.h.in	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/include/locations.h.in	2012-08-02 00:43:50 UTC (rev 2031)
@@ -39,5 +39,3 @@
 #define DEFAULT_OBJECT_CACHE_FILE		"@localstatedir@/objects.cache"
 #define DEFAULT_PRECACHED_OBJECT_FILE		"@localstatedir@/objects.precache"
 #define DEFAULT_EVENT_BROKER_FILE		"@localstatedir@/broker.socket"
-#define DEFAULT_P1_FILE				"@bindir@/p1.pl"	/**** EMBEDDED PERL ****/
-#define DEFAULT_AUTH_FILE			""			/**** EMBEDDED PERL - IS THIS USED? ****/

Deleted: nagioscore/trunk/p1.pl
===================================================================
--- nagioscore/trunk/p1.pl	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/p1.pl	2012-08-02 00:43:50 UTC (rev 2031)
@@ -1,775 +0,0 @@
- package Embed::Persistent;
-
-# p1.pl for Nagios
-
-use strict ;
-
-use Text::ParseWords qw(parse_line) ;
-
-use constant	LEAVE_MSG		=> 1 ;
-use constant	CACHE_DUMP		=> 2 ;
-use constant	PLUGIN_DUMP		=> 4 ;
-
-use constant	DEBUG_LEVEL		=> 0 ;
-# use constant	DEBUG_LEVEL		=> CACHE_DUMP ;
-# use constant	DEBUG_LEVEL		=> LEAVE_MSG ;
-# use constant	DEBUG_LEVEL		=> LEAVE_MSG | CACHE_DUMP ;
-# use constant	DEBUG_LEVEL		=> LEAVE_MSG | CACHE_DUMP | PLUGIN_DUMP ;
-
-use constant	DEBUG_LOG_PATH		=> '/usr/local/nagios/var/' ;
-# use constant	DEBUG_LOG_PATH		=> './' ;
-use constant	LEAVE_MSG_STREAM	=> DEBUG_LOG_PATH . 'epn_leave-msgs.log' ;
-use constant	CACHE_DUMP_STREAM	=> DEBUG_LOG_PATH . 'epn_cache-dump.log' ;
-use constant	PLUGIN_DUMP_STREAM	=> DEBUG_LOG_PATH . 'epn_plugin-dump.log' ;
-
-use constant	NUMBER_OF_PERL_PLUGINS	=> 60 ;
-
-use constant	Cache_Dump_Interval	=> 20 ;
-								# Cache will be dumped every Cache_Dump_Interval plugin compilations
-
-(DEBUG_LEVEL & LEAVE_MSG)	&& do 	{
-							open LH, '>> ' . LEAVE_MSG_STREAM
-								or die "Can't open " . LEAVE_MSG_STREAM . ": $!" ;
-
-								# Unbuffer LH since this will be written by child processes.
-
-							select( (select(LH), $| = 1)[0] ) ;
-					} ;
-(DEBUG_LEVEL & CACHE_DUMP)	&& do	{
-							 (open CH, '>> ' . CACHE_DUMP_STREAM
-								or die "Can't open " . CACHE_DUMP_STREAM . ": $!") ;
-							select( (select(CH), $| = 1)[0] ) ;
-					} ;
-(DEBUG_LEVEL & PLUGIN_DUMP)	&& (open PH, '>> ' . PLUGIN_DUMP_STREAM
-								or die "Can't open " . PLUGIN_DUMP_STREAM . ": $!") ;
-
-require Data::Dumper
-	if DEBUG_LEVEL & CACHE_DUMP ;
-
-my (%Cache, $Current_Run) ;
-keys %Cache	= NUMBER_OF_PERL_PLUGINS ;
-								# Offsets in %Cache{$filename}
-use constant	MTIME			=> 0 ;
-use constant	PLUGIN_ARGS		=> 1 ;
-use constant	PLUGIN_ERROR		=> 2 ;
-use constant	PLUGIN_HNDLR		=> 3 ;
-
-package main;
-
-use subs 'CORE::GLOBAL::exit';
-
-sub CORE::GLOBAL::exit { die "ExitTrap: $_[0] (Redefine exit to trap plugin exit with eval BLOCK)" }
-
-
-package OutputTrap;
-
-								# Methods for use by tied STDOUT in embedded PERL module.
-								# Simply ties STDOUT to a scalar and caches values written to it.
-								# NB No more than 4KB characters per line are kept.
- 
-sub TIEHANDLE {
-	my ($class) = @_;
-	my $me = '';
-	bless \$me, $class;
-}
-
-sub PRINT {
-	my $self = shift;
-	# $$self = substr(join('', at _), 0, 256) ;
-	$$self .= substr(join('', at _), 0, 4096) ;
-}
-
-sub PRINTF {
-	my $self = shift;
-	my $fmt = shift;
-	# $$self = substr(sprintf($fmt, at _), 0, 256) ;
-	$$self .= substr(sprintf($fmt, at _), 0, 4096) ;
-}
-
-sub READLINE {
-	my $self = shift;
-
-# CHANGED 12/26/07 EG Following two statements didn't allow for multi-line output or output > 256 chars
-								# Omit all lines after the first, per the nagios plugin guidelines
-#        $$self = (split /\n/, $$self)[0];
-								# Perl code other than plugins may print nothing; in this case return "(No output!)\n".
-#	return $$self ? substr($$self, 0, 256) : "(No output!)\n" ;
-
-	return $$self;
-}
-
-sub CLOSE {
-	my $self = shift;
-	undef $self ;
-}
-
-sub DESTROY {
-	my $self = shift;
-	undef $self;
-}
-
-package Embed::Persistent;
-
-sub valid_package_name {
-	local $_ = shift ;
-	s|([^A-Za-z0-9\/])|sprintf("_%2x",unpack("C",$1))|eg;
-								# second pass only for words starting with a digit
-	s|/(\d)|sprintf("/_%2x",unpack("C",$1))|eg;
-	
-								# Dress it up as a real package name
-	s|/|::|g;
-	return /^::/ ? "Embed$_" : "Embed::$_" ;
- }
-
-# Perl 5.005_03 only traps warnings for errors classed by perldiag
-# as Fatal (eg 'Global symbol """"%s"""" requires explicit package name').
-# Therefore treat all warnings as fatal.
-
-sub throw_exception {
-	die shift ;
-}
-
-sub eval_file {
-	my ($filename, $delete, undef, $plugin_args) = @_ ;
-
-	my $mtime 	= -M $filename ;
-	my $ts 		= localtime(time())
-				if DEBUG_LEVEL ;
-
-
-	if (
-		exists($Cache{$filename})	&&
-		$Cache{$filename}[MTIME]	&&
-	   	$Cache{$filename}[MTIME] <= $mtime
-	   )  {
-								# We have compiled this plugin before and
-								# it has not changed on disk; nothing to do except
-								# 1 parse the plugin arguments and cache them (to save 
-								#   repeated parsing of the same args) - the same
-								#   plugin could be called with different args.
-								# 2 return the error from a former compilation
-								#   if there was one.
-
-			$Cache{$filename}[PLUGIN_ARGS]{$plugin_args} ||= [ parse_line('\s+', 0, $plugin_args) ]
-				if $plugin_args ;
-
-			if ( $Cache{$filename}[PLUGIN_ERROR] ) {
-				print LH qq($ts eval_file: $filename failed compilation formerly and file has not changed; skipping compilation.\n)
-					if DEBUG_LEVEL & LEAVE_MSG ;
-				die qq(**ePN failed to compile $filename: "$Cache{$filename}[PLUGIN_ERROR]") ;
-			} else {
-				print LH qq($ts eval_file: $filename already successfully compiled and file has not changed; skipping compilation.\n)
-					if DEBUG_LEVEL & LEAVE_MSG ;
-				return $Cache{$filename}[PLUGIN_HNDLR] ;
-			}
-	}
-
-	my $package	= valid_package_name($filename) ;
-
-	$Cache{$filename}[PLUGIN_ARGS]{$plugin_args} ||= [ parse_line('\s+', 0, $plugin_args) ]
-		if $plugin_args ;
-
-	local *FH;
-								# die will be trapped by caller (checking ERRSV)
-	open FH, $filename
-		or die qq(**ePN failed to open "$filename": "$!") ;
-
-	my $sub ;
-	sysread FH, $sub, -s FH ;
-	close FH;
-								# Cater for scripts that have embedded EOF symbols (__END__)
-								# XXXX 
-								# Doesn't make sense to me.
-
-	# $sub		=~ s/__END__/\;}\n__END__/;
-								# Wrap the code into a subroutine inside our unique package
-								# (using $_ here [to save a lexical] is not a good idea since 
-								# the definition of the package is visible to any other Perl
-								# code that uses [non localised] $_).
-	my $hndlr	= <<EOSUB ;
-package $package;
-
-sub hndlr {
-	\@ARGV = \@_ ;
-	local \$^W = 1 ;
- 	\$ENV{NAGIOS_PLUGIN} = '$filename' ;
-
-								# <<< START of PLUGIN (first line of plugin is line 8 in the text) >>>
-$sub
-								# <<< END of PLUGIN >>>
-}
-EOSUB
-
-	$Cache{$filename}[MTIME]		= $mtime 
-							unless $delete ;
-								# Suppress warning display.
-	local $SIG{__WARN__}			= \&throw_exception ;
-
-
-                                                                # Following 3 lines added 10/18/07 by Larry Low to fix problem where
-                                                                # modified Perl plugins didn't get recached by the epn
-        no strict 'refs';
-        undef %{$package.'::'};
-        use strict 'refs';
-
-								# Compile &$package::hndlr. Since non executable code is being eval'd
-								# there is no need to protect lexicals in this scope.
-	eval $hndlr;
-
-								# $@ is set for any warning and error.
-								# This guarantees that the plugin will not be run.
-	if ($@) {
-								# Report error line number wrt to original plugin text (7 lines added by eval_file).
-								# Error text looks like
-								# 'Use of uninitialized ..' at (eval 23) line 186, <DATA> line 218
-								# The error line number is 'line 186'
-		chomp($@) ;
-		$@ =~ s/line (\d+)[\.,]/'line ' . ($1 - 7) . ','/e ;
-
-		print LH qq($ts eval_file: syntax error in $filename: "$@".\n) 
-			if DEBUG_LEVEL & LEAVE_MSG ;
-
-	 	if ( DEBUG_LEVEL & PLUGIN_DUMP ) {
-			my $i = 1 ;
-			$_ = $hndlr ;
-			s/^/sprintf('%10d  ', $i++)/meg ;
-								# Will only get here once (when a faulty plugin is compiled). 
-								# Therefore only _faulty_ plugins are dumped once each time the text changes.
-
-			print PH qq($ts eval_file: transformed plugin "$filename" to ==>\n$_\n) ;
-		}
-
-		$@ = substr($@, 0, 4096)
-			if length($@) > 4096 ;
-
-		$Cache{$filename}[PLUGIN_ERROR] = $@ ;
-								# If the compilation fails, leave nothing behind that may affect subsequent
-								# compilations. This will be trapped by caller (checking ERRSV).
-		die qq(**ePN failed to compile $filename: "$@") ;
-		
-	} else {
-		$Cache{$filename}[PLUGIN_ERROR] = '' ;
-	}
-
-	print LH qq($ts eval_file: successfully compiled "$filename $plugin_args".\n)
-		if DEBUG_LEVEL & LEAVE_MSG ;
-
-	print CH qq($ts eval_file: after $Current_Run compilations \%Cache =>\n), Data::Dumper->Dump([\%Cache], [qw(*Cache)]), "\n"
-		if ( (DEBUG_LEVEL & CACHE_DUMP) && (++$Current_Run % Cache_Dump_Interval == 0) ) ;
-
-	no strict 'refs' ;
-	return $Cache{$filename}[PLUGIN_HNDLR] = *{ $package . '::hndlr' }{CODE} ;
-
-}
-
-sub run_package {
-	my ($filename, undef, $plugin_hndlr_cr, $plugin_args) = @_;
-								# Second parm (after $filename) _may_ be used to wallop stashes.
-
-	my $res		= 3 ;
-	my $ts		= localtime(time()) 
-				if DEBUG_LEVEL ;
-     
-	local $SIG{__WARN__}	= \&throw_exception ;
-	my $stdout		= tie (*STDOUT, 'OutputTrap');
-	my @plugin_args		= $plugin_args ? @{ $Cache{$filename}[PLUGIN_ARGS]{$plugin_args} } : () ;
-
-								# If the plugin has args, they have been cached by eval_file.
-								# ( cannot cache @plugin_args here because run_package() is
-								#   called by child processes so cannot update %Cache.)
-
-	eval { $plugin_hndlr_cr->(@plugin_args) } ;
-
-	if ($@) {
-								# Error => normal plugin termination (exit) || run time error.
-		$_			= $@ ;
-		/^ExitTrap: (-?\d+)/	? $res = $1 :
-								# For normal plugin exit, $@ will  always match /^ExitTrap: (-?\d+)/
-		/^ExitTrap:  /		? $res = 0  :	do {
-								# Run time error/abnormal plugin termination.
-	
-								chomp ;
-								# Report error line number wrt to original plugin text (7 lines added by eval_file).
-								s/line (\d+)[\.,]/'line ' . ($1 - 7) . ','/e ;
-								print STDOUT qq(**ePN $filename: "$_".\n) ;
-							} ;
-	
-		($@, $_)		= ('', '') ;
-	}
-								# ! Error => Perl code is not a plugin (fell off the end; no exit)
-
-								# !! (read any output from the tied file handle.)
-	my $plugin_output	= <STDOUT> ;
-
-	undef $stdout ;
-	untie *STDOUT;
-
-	print LH qq($ts run_package: "$filename $plugin_args" returning ($res, "$plugin_output").\n) 
-		if DEBUG_LEVEL & LEAVE_MSG ;
-
-	return ($res, $plugin_output) ;
-}
-
-1;
-
-=head1 NAME
-
-p1.pl - Perl program to provide Perl code persistence for the Nagios project (http://www.Nagios.Org).
-
-This program provides an API for calling Nagios Perl plugins from Nagios when it is built with embedded Perl support. The
-intent is to tradeoff memory usage (see BUGS) against repeated context switches to recompile Perl plugins.
-
-=head1 SYNOPSIS
-
-
-B<From C>
-
-  /* 1 Initialise Perl - see perlembed - maintaining a persistent interpreter> */
-  /* 2 Push the arguments (char *args[]) of call_pv() onto the Perl stack */
-  /* 3 Compile the plugin - char *args[] is an array of pointers to strings required by p1.pl */
-
-  call_pv("Embed::Persistent::eval_file", G_SCALAR | G_EVAL)
-
-  /* 4 if (SvTrue(ERRSV)) */
-    goto outahere ;
-
-  /* 5 Pop the code reference to the Perl sub (corresp to the plugin) returned by Perl */
-  /* 6 Push the arguments (char *args[]) of call_pv() onto the Perl stack */
-  /* 7 Run the plugin */
-
-  call_pv("Embed::Persistent::run_package", G_ARRAY)
-
-  /* 8 example arguments for call_ functions */
-
-  args = {  "check_rcp",       /* pointer to plugin file name          */
-            "1",               /* 1 to recompile plugins each time     */
-            "",                /* temporary file name - no longer used */
-            "-H sundev -C nfs" /* pointer to plugin argument string    */
-         }
-
-B<From Perl>
-
-  my ($plugin_file, $plugin_args) = split(/\s+/, $_, 2) ;
-  my $plugin_hndlr_cr ;
-  eval {
-
-    # 'eval {}' simulates the G_EVAL flag to perl_call_argv('code', 'flags')
-    # Otherwise, die in 'eval_file' will end the caller also.
-
-    $plugin_hndlr_cr = Embed::Persistent::eval_file($plugin_file, 0, '', $plugin_args) ;
-
-  } ;
-
-  if ( $@) {
-    print "plugin compilation failed.\n" ;
-  } else {
-    my ($rc, $output) = Embed::Persistent::run_package($plugin_file, 0, $plugin_hndlr_cr, $plugin_args) ;
-    printf "embedded perl plugin return code and output was: %d & %s\n", $rc, $output) ;
-
-In the p1.pl text, 'use constant' statements set the log path and the log level.
-
-The log level flags determine the amount and type of messages logged in the log path.
-
-The default log level results in similar behaviour to former versions of p1.pl -
-log files will B<not> be opened.
-
-If you want to enable logging
-
-=over 4
-
-=item 1 Choose log options (see below)
-
-=item 2 Choose a log path
-
-=item 3 Edit p1.pl
-
-=back
-
-Set the values of (the 'use constant' statements) the log path, B<DEBUG_LOG_PATH>, and set the B<DEBUG_LEVEL> constant to
-one or more of the log options (B<LEAVE_MSG> and friends ) or'ed together.
-The default is to log nothing and to use S<<path_to_Nagios>/var/epn_stderr.log> as the log path.
-
-=head1 DESCRIPTION
-
-Nagios is a program to monitor service availability by scheduling 'plugins' - discrete programs
-that check a service (by for example simulating a users interaction with a web server using WWW::Mechanize)  and output a line of
-text (the summary of the service state) for those responsible for the service, and exit with a coded value to relay the same information to Nagios.
-
-Each plugin is run in a new child process forked by Nagios.
-
-Plugins, like CGIs, can be coded in Perl. The persistence framework embeds a Perl interpreter in Nagios to
-
-=over 4
-
-=item * reduce the time taken for the Perl compile and execute cycle.
-
-=item * eliminate the need for Nagios to fork a process (with popen) to run the Perl code.
-
-=item * eliminate reloading of frequently used modules.
-
-=back
-
-and all the good things mentioned in the B<perlembed> man page under 'Maintaining a persistent interpreter'.
-
-Plugin run-time and syntax errors, are returned to Nagios as the 'plugin output'. These messages
-appear in the Nagios log like S<**ePN 'check_test' Global symbol "$status" requires explicit package name at (eval 54) line 15.>
-
-Extra logging is given by setting DEBUG_LEVEL to include
-
-
-B<LEAVE_MSG>
-
-B<1> opens an extra output stream in the path given by the value of DEBUG_LOG_PATH
-
-B<2> logs messages describing the success or otherwise of the plugin compilation and the result of the plugin run.
-
-An example of such messages are
-
- Fri Apr 22 11:54:21 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_bass ".
- Fri Apr 22 11:54:21 2005 run_package: "/usr/local/nagios/libexec/check_bass " returning ("0", "BASS Transaction completed Ok.
- ").
- Fri Apr 22 11:55:02 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_ad -D production.prod -S".
- Fri Apr 22 11:55:02 2005 run_package: "/usr/local/nagios/libexec/check_ad -D foo.dom -S" returning ("0", "Ok. Expected 2 domain controllers [foo1 foo2] for "foo.dom.prod" domain from "1.1.2.3" DNS, found 8 [foo1 foo2 ..]
- ").
- Fri Apr 22 11:55:19 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_ldap adonis".
- Fri Apr 22 11:55:19 2005 run_package: "/usr/local/nagios/libexec/check_ldap adonis" returning ("0", "Ok. Schema query response DN: dc=ipaustralia,dc=gov,dc=au aci: (target="ldap:///dc=ipaustralia,dc=gov,dc=au")(targetattr!="userPassword")(targetfi
- ").
- Fri Apr 22 11:55:29 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_scheduler -H aphrodite -p 7003".
- Fri Apr 22 11:55:30 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_pams -H aphrodite -p 7003 -R".
- Fri Apr 22 11:55:29 2005 run_package: "/usr/local/nagios/libexec/check_scheduler -H aphrodite -p 7003" returning ("0", "Ok. COMSQ last ran 31 seconds ago. System: 0.02s Number of jobs waiting 0 "Detail" system sch_V2_6 14/01/2005 12:22:53 aimali Jobs: COMSQ/PollerManager Fri Apr 22 11:55:00, adhoc pause Fri Apr 22 09:00:00, PAMS/SchedExamDocCheck Thu Apr 21 23:00:00, CFX Cl"
- ).
- Fri Apr 22 11:55:30 2005 run_package: "/usr/local/nagios/libexec/check_pams -H aphrodite -p 7003 -R" returning ("0", "OK PAMS Worst: Test Time 2.61 Failure Ratio 0 [0:5] Statii: BASE OK Oracle (direct) OK COMS Processor OK CCS Name Search (direct) OK Correspondence Manager OK PAMS Tier OK CASEWORK OK Objective (direct) OK Customer Manager OK 
- ").
- Fri Apr 22 11:55:45 2005 eval_file: successfully compiled "/usr/local/nagios/libexec/check_coms ".
- Fri Apr 22 11:55:45 2005 run_package: "/usr/local/nagios/libexec/check_coms " returning ("0", "COMS Ok. 11 successes 20 minutes ago. 55 minute deltas: (0 0 0 11 0 1 3 4 0 6) or <a href='http://tsitc/cgi-bin/coms_graph_deltas?INT=-2h'>graph</a>
- )
-
-  .. after all the plugins are compiled, the 'successfully compiled mesages' are replaced by  'skipping compilation'
-
- Fri Apr 22 12:05:10 2005 eval_file: /usr/local/nagios/libexec/check_adds already successfully compiled and file has not changed; skipping compilation.
- Fri Apr 22 12:05:11 2005 eval_file: /usr/local/nagios/libexec/check_aub already successfully compiled and file has not changed; skipping compilation
- .
- Fri Apr 22 12:05:10 2005 run_package: "/usr/local/nagios/libexec/check_adds " returning ("0", "ADDS Transaction completed Ok.
- ").
- Fri Apr 22 12:05:13 2005 eval_file: /usr/local/nagios/libexec/check_eForm already successfully compiled and file has not changed; skipping compilation.
- Fri Apr 22 12:05:13 2005 run_package: "/usr/local/nagios/libexec/check_eForm " returning ("0", "eForm Transaction completed Ok.
- ").
- Fri Apr 22 12:05:15 2005 eval_file: /usr/local/nagios/libexec/check_cfx_log already successfully compiled and file has not changed; skipping compilation.
- Fri Apr 22 12:05:15 2005 run_package: "/usr/local/nagios/libexec/check_cfx_log -H faxgw1" returning ("0", "Ok. Last write of "//faxgw1/Faxloader$/cfxFaxLoaderClient.log"  0.0 minutes ago. File info (create, access, modify, write times): "Wed Mar 26 17:19:42 2003 Fri Apr 22 12:05:13 2005 Fri Apr 22 12:05:13 2005 Fri Apr 22 12:05:13 2005".
- ").
- Fri Apr 22 12:05:16 2005 eval_file: /usr/local/nagios/libexec/check_cfx_log already successfully compiled and file has not changed; skipping compilation.
- Fri Apr 22 12:05:16 2005 run_package: "/usr/local/nagios/libexec/check_cfx_log -H faxgw2" returning ("0", "Ok. Last write of "//faxgw2/Faxloader$/cfxFaxLoaderClient.log"  0.3 minutes ago. File info (create, access, modify, write times): "Wed Mar 26 17:27:24 2003 Fri Apr 22 12:04:55 2005 Fri Apr 22 12:04:55 2005 Fri Apr 22 12:04:55 2005".
- ").
- Fri Apr 22 12:05:17 2005 eval_file: /usr/local/nagios/libexec/check_apps_asearch already successfully compiled and file has not changed; skipping compilation.
- Fri Apr 22 12:05:18 2005 eval_file: /usr/local/nagios/libexec/check_aurioness already successfully compiled and file has not changed; skipping compi lation.
- Fri Apr 22 12:05:11 2005 run_package: "/usr/local/nagios/libexec/check_aub " returning ("0", "AU-B Transaction completed Ok.
- ").
-
-If you are lucky enough to have plugins with errors in them,
-
- Fri Apr 22 12:16:01 2005 run_package: "//usr/local/nagios/libexec/eventhandlers/restart_coldfusion OK SOFT" returning ("3", "**ePN "//usr/local/nagios/libexec/eventhandlers/restart_coldfusion": "Can't use string ("") as a subroutine ref while "strict refs" in use at /usr/local/nagios/bin/p1.pl line 291, <DATA> line 218".
-
-
-B<PLUGIN_DUMP>
-
-B<1> opens an extra output stream in the path given by the value of DEBUG_LOG_PATH.
-
-B<2> logs a listing of the text of any B<faulty> plugin - as transformed by the persistence framework. Note that plugins that compile
-are B<never> dumped. This option is only useful for investigating WTF a plugin that runs from the CLI does not run under Nagios with embedded Perl.
-
- Sat Apr 23 19:25:32 2005 eval_file: transformed plugin "check_dummy_plugin" to ==>
-         1  package Embed::check_5fdummy_5fplugin;
-         2  
-         3  sub hndlr {
-         4      @ARGV = @_ ;
-         5      local $^W = 1 ;
-         6  
-         7                                                              # <<< START of PLUGIN (first line of plugin is line 8 in the text) >>>
-         8  #!/usr/bin/perl -w
-         9  
-        10  use strict 
-        11  # use strict ;
-        12  
-        13  my @texts = split(/\n/, <<EOTEXTS) ;
-        14  The Lord is near to the brokenhearted, and saves those who are crushed in spirit. Psalms 34:18 ,
-        15  Let the words of my mouth, and the meditation of my heart, be acceptable in thy sight, O LORD, my strength, and my redeemer. Psalms 19:14,
-        16  The LORD is my shepherd; I shall not want. He restoreth my soul: He leadeth me in the paths of righteousness for His name's sake. Psalms 23:1-2,
-        17  But as many as received him, to them gave he power to become the sons of God, even to them that believe on his name John 1:12,
-        18  And he said to them all, 'If any man will come after me, let him deny himself, and take up his cross daily, and follow me.' Luke 9:23,
-        19  EOTEXTS
-        20      #EOTEXTS
-        21  
-        22  print $texts[ int(rand($#texts) + 0.5) ], "\n" ;
-        23  my $rc = int(rand(1) + 0.5) > 0 ? 2 : 0 ;
-        24  exit $rc ;
-        25  
-        26  
-        27                                                              # <<< END of PLUGIN >>>
-        28  }
-
-
-This listing is logged each time the plugin source file modification time stamp is changed (when the file is
-compiled for the first time and then either by correcting a syntax error or touching the file).
-
-Note that the plugin text (lines 8 to 27 inclusive) has been transformed by the persistence framework as described below.
-
-B<CACHE_DUMP>
-
-B<1> opens an extra output stream in the path given by the value of DEBUG_LOG_PATH.
-
-B<2> A dump of the %Cache data structure (showing the plugin file modification time, a hash keyed by the plugin argument string of arrays of parsed
-arguments (if non null), the last compilation error,  and a code ref to the Perl subroutine corresponding the plugin (this is undef if the plugin failed to compile).
-
- Sat Apr 23 19:24:59 2005 eval_file: after 5 compilations %Cache =>
- %Cache = (
-           '/usr/local/nagios/libexec/check_adds' => [
-                                                       '100.230810185185',
-                                                       undef,
-                                                       '',
-                                                       sub { "DUMMY" }
-                                                     ],
-           'check_adds' => [
-                             '3.96288194444444',
-                             undef,
-                             '',
-                             sub { "DUMMY" }
-                           ],
-           'check_atmoss' => [
-                               '3.96288194444444',
-                               undef,
-                               '',
-                               sub { "DUMMY" }
-                             ],
-          '/usr/local/nagios/libexec/check_pams' => [
-                                                       '1.90859953703704',
-                                                       {
-                                                         '-R -I -H asterix -p 7003' => [
-                                                                                         '-R',
-                                                                                         '-I',
-                                                                                         '-H',
-                                                                                         'asterix',
-                                                                                         '-p',
-                                                                                         '7003'
-                                                                                       ]
-                                                       },
-						       sub { "DUMMY" }
-                                                     ],
-           'check_dummy_plugin' => [
-                                     '3.96288194444444',
-                                     undef,
-                                     '',
-                                     sub { "DUMMY" }
-                                   ]
-         );
-  ..
-
-
-
-
-This dump is produced periodically: each B<$Cache_Dump_Interval> plugin compilations the %Cache data structure is dumped. 
-
-=head1 SUBROUTINES
-
-Unless otherwise stated, all subroutines take two (4) arguments :-
-
-=over 4
-
-=item 1 plugin_filename - char * (called from C) or scalar (called from Perl): the path to the plugin.
-
-=item 2 DO_CLEAN - boolean: set if plugin is not to be cached. Defaults to 0.
-
-Setting this flag means that the plugin is compiled each time it is executed. Nagios B<never> sets this flag when the 
-Nagios is compiled with the configure setting --with-perlcache.
-
-=item 3 (SV *) code ref to the Perl subroutine corresponding to the plugin
-
-This argument is only used by run_package(); it is returned by eval_file().
-
-=item 4 plugin arguments - char ** (called from C) or scalar (called from Perl); the plugin options and arguments
-
-
-=back 
-
-=over 4
-
-=item Embed::Persistent::eval_file( plugin_filename, DO_CLEAN, "", plugin_arguments )
-
-E<10>
-Returns B<either> a Perl code reference (an SV containing a hard reference to a subroutine) to the subroutine that
-has been produced and compiled by eval_file, B<or> raises an exception (by calling die) and setting the value of B<ERRSV> or
-B<$@> (if called from Perl).
-
-
-eval_file() transforms the plugin to a subroutine in a package, by compiling the string containing the
-transformed plugin, and caches the plugin file modification time (to avoid recompiling it), 
-the parsed plugin arguments. and either the  error trapped when the plugin is compiled or a code reference to the 
-compiled subroutine representing the plugin.
-
-eval_file() caches these values in the cache named B<%Cache>. The plugin file name is the key to an array containing
-the values illustrated above.
-
-If the plugin file has not been modified, eval_file returns the cached plugin error B<or> the code ref to the plugin subroutine.
-
-Otherwise, the plugin is compiled into a subroutine in a new package by
-
-=over 4
-
-=item 1 creating a package name from the plugin file name (C<Embed::Persistent::valid_package_name>)
-
-=item 2 turning off subroutine redefinition warnings (C<use subs 'CORE::GLOBAL::exit'>)
-
-=item 3 overriding CORE::GLOBAL::exit from within package main (C<sub CORE::GLOBAL::exit { die "ExitTrap: \$_[0] (yada)"; }>)
-
-This allows the plugin to both call exit without taking down the persistence framework, and to return the exit code to the
-Nagios.
-
-=item 4 prepending the plugin text with code to let the plugin function as a subroutine.
-
-The plugin command line arguments are expected to be in @ARGV, so @ARGV is set to the subroutine arguments (@_).
-
-The new subroutine also sets the warning level to trap all warnings that may have been caused by 
-by the transformation (the -w option to Perl in the text is no longer significant (because the shebang line is not fed to exec()).
-
-=item 5 writing the plugin as the subroutine named B<hndlr> in the new package.
-
-=item 6 returning either a code reference to the subroutine named hndlr in the package named in item 1, OR the 
-compilation error trapped by eval 'string'. It is the callers responsibility to check either ERRSV (from C) or $@ (from Perl)
-and skip run_package() if these values are true.
-
-=back
-
-=item Embed::Persistent::run_package( plugin_filename, DO_CLEAN, (SV *) plugin_hndlr_cr, plugin_argument_string )
-
-E<10>
-Returns (plugin_return_code, plugin_output)
-
-run_plugin() actually runs the plugins with the arguments contained in the (space separated string) 4th argument.
-
-=back
-
-=head1 DIFFERENCES FROM PERSISTENT.PL
-
-The example B<persistent.pl> takes no account of
-
-=over 4
-
-=item * Capturing output from the Perl program being run
-
-This framework ties STDOUT to a scalar that stores the result of PRINT or PRINTF.
-
-=item * Running Perl programs in child processes
-
-This is the largest single difference between this framework and the example program persistent.pl. The example uses one
-subroutine (eval_file()) to compile and run the program. This is unsuitable for a process like Nagios that
-fork a new process to run a plugin. (It is unsuitable because were the child process 
-to call eval_file() and then the update its copy of %Cache, other child processes would not get the updated %Cache,
-and would therefore recompile the plugin).
-
-Instead, eval_file() is split into two: eval_file() and run_package().
-
-Eval_file is called by the Nagios parent process to compile the plugin 
-and update %Cache. Child processes forked in base/checks.c have the same copy of %Cache and call run_plugin() to check the
-last compilation error (from %Cache) and run the plugin if the plugin was error free.
-
-=item * Dealing with Perl programs that call exit
-
-This framework redefines exit() to die emitting a string containing the plugin return code (the first argument of exit).
-Since the plugin is run by eval(), B<$@> contains this string from which the return code is extracted.
-
-=item * Providing command line arguments to the Perl program
-
-This framework sets @ARGV in the B<Hndlr> subroutine to the remaining subroutine arguments.
-
-All of these clever ideas came from, AFAIK, Stephen Davies.
-
-=back
-
-=head1 BUGS
-
-=item * MEMORY LEAK
-
-
-
-This framework does nothing to prevent the memory leaks mentioned in B<perlembed>, relying on operator intervention.
-
-Probably the best way of doing so is by periodically scheduling 
-
-=over 4
-
-=item 1 A check of the memory used by the Nagios process  (by running for example the standard Nagios plugin check_procs)
-
-=item 2 Restarting Nagios with the (supplied with Nagios) startup script (restart command).
-
-
-=back
-
-If you do periodically restart Nagios, make sure that 
-
-=over 4
-
-=item 1 plugins all set the PATH environment variable if they need other system binaries (otherwise, if the
-init script is excec'd by cron, the PATH will be reset and the plugins will fail - but only when reatsrted by cron).
-
-=item 2 that the group owning the Nagios command pipe is the same as the Nagios group (otherwise, the restarted
-Nagios will not be able to read from the command pipe).
-
-=back
-
-Nagios installations using the persistence framework B<must> monitor the memory use of the Nagios process and stop/start it when
-the usage is exorbidant (eg, for a site with 400 services on 200 hosts and custom Perl plugins used for about 10% of the
-service checks, the Nagios process uses ~80 MB after 20-30 days runningi with Perl 5.005 [Memory usage is
-B<much> greater with recent Perls]. It is usually stopped and started at this point).
-
-Note that a HUP signal is B<not> sufficient to deallocate the Perl memory; the Nagios process must be stopped and started. In fact, since HUP
-causes Nagios to re-run the Perl interpreter initialisation code, memory use increases significantly. B<Don't use HUP>; use the 'restart' argument
-of the Nagios supplied startup script.
-
-There are all sorts of suprising gotchas about the debug logging including
-
-=over 4
-
-=item * No dump of good plugins.
-
-Only plugins that fail to compile (after transformation) are dumped.
-
-=item * Cache dump is periodic
-
-The Cache is only dumped after the user specified number of plugin B<compilations>. If plugins are not compiled, you get
-no dump of the cache.
-
-=item * Debug level set at compile time
-
-Nagios must be restarted to change the debug level (use the examples if you have a troublesome plugin;l you may need a debug copy 
-of Nagios)
-
-=item * Not all Cached fields visible
-
-Always compile one more plugin to ensure that all the fields in the cache are set.
-
-
-=back
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * perlembed (section on maintaining a persistent interpreter)
-
-=item * examples in the examples/ directory including both C and Perl drivers that run Nagios plugins using p1.pl.
-
-=back
-
-
-=head1 AUTHOR
-
-Originally by Stephen Davies.
-
-Now maintained by Stanley Hopcroft <hopcrofts at cpan.org> who retains responsibility for the 'bad bits'.
-
-=head1 COPYRIGHT
-
-Copyright (c) 2004 Stanley Hopcroft. All rights reserved.
-This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
-
-=cut
-

Modified: nagioscore/trunk/t-tap/test_nagios_config.c
===================================================================
--- nagioscore/trunk/t-tap/test_nagios_config.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/t-tap/test_nagios_config.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -54,8 +54,6 @@
 char            *check_result_path = NULL;
 char            *lock_file = NULL;
 char            *log_archive_path = NULL;
-char            *p1_file = NULL;  /**** EMBEDDED PERL ****/
-char            *auth_file = NULL; /**** EMBEDDED PERL INTERPRETER AUTH FILE ****/
 char            *nagios_user = NULL;
 char            *nagios_group = NULL;
 
@@ -222,10 +220,6 @@
 int             free_child_process_memory = -1;
 int             child_processes_fork_twice = -1;
 
-int             enable_embedded_perl = DEFAULT_ENABLE_EMBEDDED_PERL;
-int             use_embedded_perl_implicitly = DEFAULT_USE_EMBEDDED_PERL_IMPLICITLY;
-int             embedded_perl_initialized = FALSE;
-
 int             date_format = DATE_FORMAT_US;
 char            *use_timezone = NULL;
 

Modified: nagioscore/trunk/t-tap/test_timeperiods.c
===================================================================
--- nagioscore/trunk/t-tap/test_timeperiods.c	2012-08-02 00:43:05 UTC (rev 2030)
+++ nagioscore/trunk/t-tap/test_timeperiods.c	2012-08-02 00:43:50 UTC (rev 2031)
@@ -54,8 +54,6 @@
 char            *check_result_path = NULL;
 char            *lock_file = NULL;
 char            *log_archive_path = NULL;
-char            *p1_file = NULL;  /**** EMBEDDED PERL ****/
-char            *auth_file = NULL; /**** EMBEDDED PERL INTERPRETER AUTH FILE ****/
 char            *nagios_user = NULL;
 char            *nagios_group = NULL;
 
@@ -222,10 +220,6 @@
 int             free_child_process_memory = -1;
 int             child_processes_fork_twice = -1;
 
-int             enable_embedded_perl = DEFAULT_ENABLE_EMBEDDED_PERL;
-int             use_embedded_perl_implicitly = DEFAULT_USE_EMBEDDED_PERL_IMPLICITLY;
-int             embedded_perl_initialized = FALSE;
-
 int             date_format = DATE_FORMAT_US;
 char            *use_timezone = NULL;
 

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the Nagios-commits mailing list