aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-12-07 19:32:37 +0000
committerGravatar Harper Mann <harpermann@users.sourceforge.net> 2005-12-07 19:32:37 +0000
commit162faf883a864a94c0f75ca0e21360cbd001e0f3 (patch)
treed5750d240fe831e6c315f7877cb684bc207afdf4 /plugins
parent7c69ccaee2baba7d1e8347b8b9e1f45a18551a6c (diff)
downloadmonitoring-plugins-162faf883a864a94c0f75ca0e21360cbd001e0f3.tar.gz
Nagiosplug bug 1266977. Added code to insert the closing </A> after the plugin output but before the performance output.
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1296 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/urlize.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 96bbdc00..13ab14ee 100644
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
@@ -27,6 +27,9 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
#include "utils.h"
#include "popen.h"
+#define PERF_CHARACTER "|"
+#define NEWLINE_CHARACTER '\n'
+
void print_help (void);
void print_usage (void);
@@ -37,6 +40,8 @@ main (int argc, char **argv)
char *url = NULL;
char *cmd;
char *buf;
+ char *nstr;
+ char tstr[MAX_INPUT_BUFFER];
int c;
int option = 0;
@@ -53,7 +58,7 @@ main (int argc, char **argv)
while (1) {
c = getopt_long (argc, argv, "+hVu:", longopts, &option);
-
+
if (c == -1 || c == EOF)
break;
@@ -94,11 +99,13 @@ main (int argc, char **argv)
printf (_("Could not open stderr for %s\n"), cmd);
}
+ bzero(tstr, sizeof(tstr));
buf = malloc(MAX_INPUT_BUFFER);
printf ("<A href=\"%s\">", argv[1]);
while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
found++;
- printf ("%s", buf);
+ /* Collect the string in temp str so we can tokenize */
+ strcat(tstr, buf);
}
if (!found)
@@ -106,6 +113,19 @@ main (int argc, char **argv)
_("%s UNKNOWN - No data received from host\nCMD: %s</A>\n"),
argv[0], cmd);
+
+ /* chop the newline character */
+ if ((nstr = strchr(tstr, NEWLINE_CHARACTER)) != NULL)
+ *nstr = '\0';
+
+ /* tokenize the string for Perfdata if there is some */
+ nstr = strtok(tstr, PERF_CHARACTER);
+ printf ("%s", nstr);
+ printf ("</A>");
+ nstr = strtok(NULL, PERF_CHARACTER);
+ if (nstr != NULL)
+ printf (" | %s", nstr);
+
/* close the pipe */
result = spclose (child_process);
@@ -116,7 +136,6 @@ main (int argc, char **argv)
/* close stderr */
(void) fclose (child_stderr);
- printf ("</A>\n");
return result;
}