Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-updates-src > by-pkgid > deecb6b6a05b8293e284be1ad9b5f073 > files > 22

xymon-4.3.17-5.1.mga5.src.rpm

From ef028fa41eca4b6ee34407aad8d29abd4d218ea2 Mon Sep 17 00:00:00 2001
From: William Murphy <warrendiogenese@gmail.com>
Date: Thu, 7 Aug 2014 22:31:01 -0700
Subject: [PATCH] Patched rundir

---
 client/xymonclient.cfg.DIST          |  1 +
 configure.server                     | 13 +++++++++++++
 lib/environ.c                        |  1 +
 web/showgraph.c                      |  6 +++---
 xymond/Makefile                      |  2 +-
 xymond/etcfiles/xymonserver.cfg.DIST |  1 +
 xymond/trimhistory.c                 |  2 +-
 xymond/xymond_history.c              |  2 +-
 xymond/xymond_rrd.c                  |  3 ++-
 9 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/client/xymonclient.cfg.DIST b/client/xymonclient.cfg.DIST
index b14a6de..b8e3f70 100644
--- a/client/xymonclient.cfg.DIST
+++ b/client/xymonclient.cfg.DIST
@@ -16,6 +16,7 @@ XYMONHOME="$XYMONCLIENTHOME"       # Directory for the Xymon client files
 XYMON="$XYMONHOME/bin/xymon"          # The Xymon client "xymon" utility
 XYMONTMP="$XYMONHOME/tmp"             # Where we may store temporary files.
 XYMONCLIENTLOGS="$XYMONHOME/logs"     # Where we store the client logfiles
+XYMONRUNDIR="$XYMONCLIENTLOGS"	   # Where we store pid and other run files
 
 # Compatibility settings
 HOBBITCLIENTHOME="$XYMONCLIENTHOME"
diff --git a/configure.server b/configure.server
index 1fc3818..4b400ba 100755
--- a/configure.server
+++ b/configure.server
@@ -361,6 +361,17 @@ then
 fi
 echo ""; echo ""
 
+echo "Where to put the Xymon runfiles [$XYMONLOGDIR] ? "
+if test -z "$XYMONRUNDIR"
+then
+	read XYMONRUNDIR
+fi
+if test -z "$XYMONRUNDIR"
+then
+	XYMONRUNDIR="$XYMONLOGDIR"
+fi
+echo ""; echo ""
+
 echo "What is the name of this host [`uname -n`] ? "
 if test -z "$XYMONHOSTNAME"
 then
@@ -416,6 +427,8 @@ echo "# Admin CGI scripts go in SECURECGIDIR" >>Makefile
 echo "SECURECGIDIR = $SECURECGIDIR"      >>Makefile
 echo "# Where to put logfiles"           >>Makefile
 echo "XYMONLOGDIR = $XYMONLOGDIR"        >>Makefile
+echo "# Where to put runfiles"           >>Makefile
+echo "XYMONRUNDIR = $XYMONRUNDIR"        >>Makefile
 echo "# Where to install manpages"       >>Makefile
 echo "MANROOT = $MANROOT"                >>Makefile
 echo "# How to run fping or xymonping"   >>Makefile
diff --git a/lib/environ.c b/lib/environ.c
index 8183db7..7eb1940 100644
--- a/lib/environ.c
+++ b/lib/environ.c
@@ -27,6 +27,7 @@ const static struct {
 	{ "XYMONDREL", VERSION },
 	{ "XYMONSERVERROOT", XYMONTOPDIR },
 	{ "XYMONSERVERLOGS", XYMONLOGDIR },
+	{ "XYMONRUNDIR", XYMONLOGDIR },
 	{ "XYMONSERVERHOSTNAME", XYMONHOSTNAME },
 	{ "XYMONSERVERIP", XYMONHOSTIP },
 	{ "XYMONSERVEROS", XYMONHOSTOS },
diff --git a/web/showgraph.c b/web/showgraph.c
index b76b319..f1f8d2d 100644
--- a/web/showgraph.c
+++ b/web/showgraph.c
@@ -135,9 +135,9 @@ void request_cacheflush(char *hostname)
 	}
 	fcntl(ctlsocket, F_SETFL, O_NONBLOCK);
 
-	dir = opendir(xgetenv("XYMONTMP"));
+	dir = opendir(xgetenv("XYMONRUNDIR"));
 	if (!dir) {
-		errprintf("Cannot acces $XYMONTMP directory: %s\n", strerror(errno));
+		errprintf("Cannot acces $XYMONRUNDIR directory: %s\n", strerror(errno));
 		return;
 	}
 
@@ -152,7 +152,7 @@ void request_cacheflush(char *hostname)
 
 			memset(&myaddr, 0, sizeof(myaddr));
 			myaddr.sun_family = AF_UNIX;
-			sprintf(myaddr.sun_path, "%s/%s", xgetenv("XYMONTMP"), d->d_name);
+			sprintf(myaddr.sun_path, "%s/%s", xgetenv("XYMONRUNDIR"), d->d_name);
 			myaddrsz = sizeof(myaddr);
 			bufp = req; bytesleft = strlen(req);
 			do {
diff --git a/xymond/Makefile b/xymond/Makefile
index 89a6d8f..50daee7 100644
--- a/xymond/Makefile
+++ b/xymond/Makefile
@@ -138,7 +138,7 @@ endif
 
 cfgfiles:
 	cat $(APACHECONF) | sed -e 's!@XYMONHOME@!$(XYMONHOME)!g' | sed -e 's!@INSTALLETCDIR@!$(INSTALLETCDIR)!g' | sed -e 's!@INSTALLWWWDIR@!$(INSTALLWWWDIR)!g' | sed -e 's!@INSTALLSTATICWWWDIR@!$(INSTALLSTATICWWWDIR)!g' | sed -e 's!@XYMONVAR@!$(XYMONVAR)!g' | sed -e 's!@CGIDIR@!$(CGIDIR)!g' | sed -e 's!@SECURECGIDIR@!$(SECURECGIDIR)!g' | sed -e 's!@XYMONHOSTURL@!$(XYMONHOSTURL)!g' | sed -e 's!@XYMONCGIURL@!$(XYMONCGIURL)!g' | sed -e 's!@SECUREXYMONCGIURL@!$(SECUREXYMONCGIURL)!g' >etcfiles/xymon-apache.conf
-	cat etcfiles/xymonserver.cfg.DIST | sed -e 's!@XYMONTOPDIR@!$(XYMONTOPDIR)!g'| sed -e 's!@XYMONLOGDIR@!$(XYMONLOGDIR)!g'| sed -e 's!@XYMONHOSTNAME@!$(XYMONHOSTNAME)!g'| sed -e 's!@XYMONHOSTIP@!$(XYMONHOSTIP)!g'| sed -e 's!@XYMONHOSTOS@!$(XYMONHOSTOS)!g' | sed -e 's!@XYMONHOSTURL@!$(XYMONHOSTURL)!g' | sed -e 's!@XYMONCGIURL@!$(XYMONCGIURL)!g' | sed -e 's!@SECUREXYMONCGIURL@!$(SECUREXYMONCGIURL)!g' | sed -e 's!@XYMONHOME@!$(XYMONHOME)!g' | sed -e 's!@XYMONVAR@!$(XYMONVAR)!g' | sed -e 's!@FPING@!$(FPING)!g' | sed -e 's!@MAILPROGRAM@!$(MAILPROGRAM)!g' | sed -e 's!@RUNTIMEDEFS@!$(RUNTIMEDEFS)!g' >etcfiles/xymonserver.cfg
+	cat etcfiles/xymonserver.cfg.DIST | sed -e 's!@XYMONTOPDIR@!$(XYMONTOPDIR)!g'| sed -e 's!@XYMONLOGDIR@!$(XYMONLOGDIR)!g'| sed -e 's!@XYMONRUNDIR@!$(XYMONRUNDIR)!g' | sed -e 's!@XYMONHOSTNAME@!$(XYMONHOSTNAME)!g'| sed -e 's!@XYMONHOSTIP@!$(XYMONHOSTIP)!g'| sed -e 's!@XYMONHOSTOS@!$(XYMONHOSTOS)!g' | sed -e 's!@XYMONHOSTURL@!$(XYMONHOSTURL)!g' | sed -e 's!@XYMONCGIURL@!$(XYMONCGIURL)!g' | sed -e 's!@SECUREXYMONCGIURL@!$(SECUREXYMONCGIURL)!g' | sed -e 's!@XYMONHOME@!$(XYMONHOME)!g' | sed -e 's!@XYMONVAR@!$(XYMONVAR)!g' | sed -e 's!@FPING@!$(FPING)!g' | sed -e 's!@MAILPROGRAM@!$(MAILPROGRAM)!g' | sed -e 's!@RUNTIMEDEFS@!$(RUNTIMEDEFS)!g' >etcfiles/xymonserver.cfg
 	../build/bb-commands.sh >>etcfiles/xymonserver.cfg
 	cat etcfiles/hosts.cfg.DIST | sed -e 's!@XYMONHOSTNAME@!$(XYMONHOSTNAME)!g' | sed -e 's!@XYMONHOSTIP@!$(XYMONHOSTIP)!g' >etcfiles/hosts.cfg
 	cat etcfiles/alerts.cfg.DIST | sed -e 's!@XYMONHOSTNAME@!$(XYMONHOSTNAME)!g' | sed -e 's!@XYMONHOSTIP@!$(XYMONHOSTIP)!g' >etcfiles/alerts.cfg
diff --git a/xymond/etcfiles/xymonserver.cfg.DIST b/xymond/etcfiles/xymonserver.cfg.DIST
index e535639..f989844 100644
--- a/xymond/etcfiles/xymonserver.cfg.DIST
+++ b/xymond/etcfiles/xymonserver.cfg.DIST
@@ -2,6 +2,7 @@
 #
 XYMONSERVERROOT="@XYMONTOPDIR@"			# Where Xymon is installed
 XYMONSERVERLOGS="@XYMONLOGDIR@"			# Directory for server logs. The xymon user must have write-access here.
+XYMONRUNDIR="@XYMONRUNDIR@"			# Directory for server pid files and runtime data. The xymon user must also have write-access here.
 XYMONCLIENTHOME="@XYMONTOPDIR@/client"		# XYMONHOME directory for the client
 
 
diff --git a/xymond/trimhistory.c b/xymond/trimhistory.c
index 3ff40fe..6db7ba8 100644
--- a/xymond/trimhistory.c
+++ b/xymond/trimhistory.c
@@ -210,7 +210,7 @@ void trim_files(time_t cutoff)
 			FILE *fd;
 			long pid = -1;
 
-			sprintf(pidfn, "%s/xymond_history.pid", xgetenv("XYMONSERVERLOGS"));
+			sprintf(pidfn, "%s/xymond_history.pid", xgetenv("XYMONRUNDIR"));
 			fd = fopen(pidfn, "r");
 			if (fd) {
 				char l[100];
diff --git a/xymond/xymond_history.c b/xymond/xymond_history.c
index 1f8e700..fc765a0 100644
--- a/xymond/xymond_history.c
+++ b/xymond/xymond_history.c
@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
 	/* Dont save the error buffer */
 	save_errbuf = 0;
 
-	sprintf(pidfn, "%s/xymond_history.pid", xgetenv("XYMONSERVERLOGS"));
+	sprintf(pidfn, "%s/xymond_history.pid", xgetenv("XYMONRUNDIR"));
 	if (xgetenv("XYMONALLHISTLOG")) save_allevents = (strcmp(xgetenv("XYMONALLHISTLOG"), "TRUE") == 0);
 	if (xgetenv("XYMONHOSTHISTLOG")) save_hostevents = (strcmp(xgetenv("XYMONHOSTHISTLOG"), "TRUE") == 0);
 	if (xgetenv("SAVESTATUSLOG")) save_histlogs = (strncmp(xgetenv("SAVESTATUSLOG"), "FALSE", 5) != 0);
diff --git a/xymond/xymond_rrd.c b/xymond/xymond_rrd.c
index 1ba93f3..b67b1b1 100644
--- a/xymond/xymond_rrd.c
+++ b/xymond/xymond_rrd.c
@@ -267,7 +267,8 @@ int main(int argc, char *argv[])
 
 	/* Setup the control socket that receives cache-flush commands */
 	memset(&ctlsockaddr, 0, sizeof(ctlsockaddr));
-	sprintf(ctlsockaddr.sun_path, "%s/rrdctl.%lu", xgetenv("XYMONTMP"), (unsigned long)getpid());
+	if (xgetenv("XYMONRUNDIR") && mkdir(xgetenv("XYMONRUNDIR"), 0755) != -1) dbgprintf("Created %s\n", xgetenv("XYMONRUNDIR")); // just in case
+	sprintf(ctlsockaddr.sun_path, "%s/rrdctl.%lu", xgetenv("XYMONRUNDIR"), (unsigned long)getpid());
 	unlink(ctlsockaddr.sun_path);     /* In case it was accidentally left behind */
 	ctlsockaddr.sun_family = AF_UNIX;
 	ctlsocket = socket(AF_UNIX, SOCK_DGRAM, 0);
-- 
1.8.4.5