[Xymon] Critical Systems 'Hosts docs'-URL does not show correct URL

henrik at hswn.dk henrik at hswn.dk
Mon Aug 15 14:47:13 CEST 2011


On Wed, 27 Jul 2011 16:50:47 +0200, Peter Welter <peter.welter at gmail.com>
wrote:
 
> After years of Xymon usage, I start to use the Critical Systems view. I
> have setup a BBGENOPTS to use a docurl. I expect this URL to show up on
the
> Critical Systems view.

BBGENOPTS (or XYMONGENOPTS in 4.3.x) is not used for the Critical Systems
view, since this setting only provides some default options for the
"xymongen" utility. And the Critical Systems view is generated by another
tool (criticalview.cgi).

It's something that I forgot to handle in the Critical systems view.

I've attached a patch that will be included in Xymon 4.3.5. It deprecates
the "docurl" option for xymongen, and replaces it with a new HOSTDOCURL
setting in xymonserver.cfg with the same function. This setting is also
used by the Critical Systems view (and other tools). So it should work as
you would expect.


Regards,
Henrik
-------------- next part --------------
Index: common/xymonserver.cfg.5
===================================================================
--- common/xymonserver.cfg.5	(revision 6731)
+++ common/xymonserver.cfg.5	(working copy)
@@ -316,7 +316,18 @@
 .I columndoc.sh(1)
 script to document a column.
 
+.IP HOSTDOCURL
+Format string used to build a link to the documentation for a host.
+If not set, then Xymon falls back to scanning the XYMONNOTES directory
+for files matching the hostname, or the hostname together with a common
+filename extension (.php, .html, .doc and so on). If set, this string
+becomes a formatting string for the documentation URL. E.g. for the host
+"myhost", a setting of HOSTDOCURL="/docs/%s.php" will generate a link to
+"/docs/myhost.php".
+Default: Not set, so host documentation will be retrieved from the
+XYMONNOTES directory.
 
+
 .SH SETTINGS FOR SENDING MESSAGES TO XYMON
 .IP XYMSRV
 The IP-address used to contact the
Index: xymongen/xymongen.1
===================================================================
--- xymongen/xymongen.1	(revision 6731)
+++ xymongen/xymongen.1	(working copy)
@@ -40,17 +40,14 @@
 Prints the version number of xymongen
 .sp
 .IP "--docurl=URL"
-Make hostnames be hyperlinks to documentation, accessed via a common
-web page (typically a CGI script or a PHP-driven dynamic page). The URL 
-parameter is a formatting string with the name of the web page - you can 
-put a "%s" in it which will be replaced by the hostname being accessed. 
-E.g. if you use the bb-notes extension from www.deadcat.net, you would
-enable this with "--docurl=/xymon/admin/notes.php?host=%s". For the host 
-www.storner.dk this will result in a link to 
-"/xymon/admin/notes.php?host=www.storner.dk". 
+This option is deprecated, use the HOSTDOCURL setting in
+.I xymonserver.cfg(5)
+instead.
 .sp
 .IP "--doccgi=URL"
-This option is deprecated; please use --docurl instead.
+This option is deprecated, use the HOSTDOCURL setting in
+.I xymonserver.cfg(5)
+instead.
 .sp
 .IP "--doc-window"
 Causes links to documentation for hosts and services to open in a
Index: lib/environ.c
===================================================================
--- lib/environ.c	(revision 6731)
+++ lib/environ.c	(working copy)
@@ -113,6 +113,7 @@
 	{ "RRDHEIGHT", "120" },
 	{ "RRDWIDTH", "576" },
 	{ "COLUMNDOCURL", "$CGIBINURL/columndoc.sh?%s" },
+	{ "HOSTDOCURL", "" },
 	{ "XYMONLOGO", "Xymon" },
 	{ "XYMONPAGELOCAL", "<B><I>Pages Hosted Locally</I></B>" },
 	{ "XYMONPAGEREMOTE", "<B><I>Remote Status Display</I></B>" },
Index: lib/links.c
===================================================================
--- lib/links.c	(revision 6731)
+++ lib/links.c	(working copy)
@@ -35,6 +35,7 @@
 static char *notesskin = NULL;
 static char *helpskin = NULL;
 static char *columndocurl = NULL;
+static char *hostdocurl = NULL;
 
 char *link_docext(char *fn)
 {
@@ -118,6 +119,7 @@
 	if (notesskin) { xfree(notesskin); notesskin = NULL; }
 	if (helpskin) { xfree(helpskin); helpskin = NULL; }
 	if (columndocurl) { xfree(columndocurl); columndocurl = NULL; }
+	if (hostdocurl) { xfree(hostdocurl); hostdocurl = NULL; }
 
 	if (xgetenv("XYMONNOTESSKIN")) notesskin = strdup(xgetenv("XYMONNOTESSKIN"));
 	else { 
@@ -132,11 +134,15 @@
 	}
 
 	if (xgetenv("COLUMNDOCURL")) columndocurl = strdup(xgetenv("COLUMNDOCURL"));
+	if (xgetenv("HOSTDOCURL")) hostdocurl = strdup(xgetenv("HOSTDOCURL"));
 
-	strcpy(dirname, xgetenv("XYMONNOTESDIR"));
-	load_links(dirname, notesskin);
+	if (!hostdocurl || (strlen(hostdocurl) == 0)) {
+		strcpy(dirname, xgetenv("XYMONNOTESDIR"));
+		load_links(dirname, notesskin);
+	}
 
 	/* Change xxx/xxx/xxx/notes into xxx/xxx/xxx/help */
+	strcpy(dirname, xgetenv("XYMONNOTESDIR"));
 	p = strrchr(dirname, '/'); *p = '\0'; strcat(dirname, "/help");
 	load_links(dirname, helpskin);
 
@@ -189,24 +195,19 @@
 	if (linkurl == NULL) linkurl = (char *)malloc(PATH_MAX);
 	if (!linksloaded) load_all_links();
 
-	link = find_link(hostname);
-
-	if (link) {
-		sprintf(linkurl, "%s/%s", link->urlprefix, link->filename);
+	if (hostdocurl && *hostdocurl) {
+		snprintf(linkurl, PATH_MAX-1, hostdocurl, hostname);
 		return linkurl;
 	}
+	else {
+		link = find_link(hostname);
 
+		if (link) {
+			sprintf(linkurl, "%s/%s", link->urlprefix, link->filename);
+			return linkurl;
+		}
+	}
+
 	return NULL;
 }
 
-char *hostlink_filename(char *hostname)
-{
-	link_t *link;
-
-	if (!linksloaded) load_all_links();
-
-	link = find_link(hostname);
-
-	return (link ? link->filename : NULL);
-}
-
Index: lib/links.h
===================================================================
--- lib/links.h	(revision 6731)
+++ lib/links.h	(working copy)
@@ -15,6 +15,5 @@
 extern void load_all_links(void);
 extern char *columnlink(char *colname);
 extern char *hostlink(char *hostname);
-extern char *hostlink_filename(char *hostname);
 
 #endif
Index: xymond/etcfiles/xymonserver.cfg.DIST
===================================================================
--- xymond/etcfiles/xymonserver.cfg.DIST	(revision 6731)
+++ xymond/etcfiles/xymonserver.cfg.DIST	(working copy)
@@ -157,7 +157,13 @@
 DOTHEIGHT="16"					# Height (in pixels) of the color GIF's
 DOTWIDTH="16"					# Width (in pixels) of the color GIF's
 COLUMNDOCURL="$CGIBINURL/columndoc.sh?%s"	# URL formatting string for column-links
+# HOSTDOCURL is a formatting string for generating links to host documentation.
+# If NOT set, Xymon will scan the "notes" directory for files matching the hostname 
+# and possibly a filename extension (php, html, doc, asp ...)
+#
+# HOSTDOCURL="$XYMONNOTESSKIN/%s.html"
 
+
 # HTML content
 HTMLCONTENTTYPE="text/html"                     # You can add charset options here.
 


More information about the Xymon mailing list