summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7c69cca)
raw | patch | inline | side by side (parent: 7c69cca)
author | Harper Mann <harpermann@users.sourceforge.net> | |
Wed, 7 Dec 2005 19:32:37 +0000 (19:32 +0000) | ||
committer | Harper Mann <harpermann@users.sourceforge.net> | |
Wed, 7 Dec 2005 19:32:37 +0000 (19:32 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1296 f882894a-f735-0410-b71e-b25c423dba1c
plugins/urlize.c | patch | blob | history |
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 96bbdc00543f8ca2bc9039ac0fffd3f2a6fdbda5..13ab14ee0b1c9d67286dc45e7841d6c852f9cd9c 100644 (file)
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
#include "utils.h"
#include "popen.h"
+#define PERF_CHARACTER "|"
+#define NEWLINE_CHARACTER '\n'
+
void print_help (void);
void print_usage (void);
char *url = NULL;
char *cmd;
char *buf;
+ char *nstr;
+ char tstr[MAX_INPUT_BUFFER];
int c;
int option = 0;
while (1) {
c = getopt_long (argc, argv, "+hVu:", longopts, &option);
-
+
if (c == -1 || c == EOF)
break;
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)
_("%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);
/* close stderr */
(void) fclose (child_stderr);
- printf ("</A>\n");
return result;
}