summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHarper Mann <harpermann@users.sourceforge.net>2005-12-07 19:32:37 +0000
committerHarper 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";
27#include "utils.h" 27#include "utils.h"
28#include "popen.h" 28#include "popen.h"
29 29
30#define PERF_CHARACTER "|"
31#define NEWLINE_CHARACTER '\n'
32
30void print_help (void); 33void print_help (void);
31void print_usage (void); 34void print_usage (void);
32 35
@@ -37,6 +40,8 @@ main (int argc, char **argv)
37 char *url = NULL; 40 char *url = NULL;
38 char *cmd; 41 char *cmd;
39 char *buf; 42 char *buf;
43 char *nstr;
44 char tstr[MAX_INPUT_BUFFER];
40 45
41 int c; 46 int c;
42 int option = 0; 47 int option = 0;
@@ -53,7 +58,7 @@ main (int argc, char **argv)
53 58
54 while (1) { 59 while (1) {
55 c = getopt_long (argc, argv, "+hVu:", longopts, &option); 60 c = getopt_long (argc, argv, "+hVu:", longopts, &option);
56 61
57 if (c == -1 || c == EOF) 62 if (c == -1 || c == EOF)
58 break; 63 break;
59 64
@@ -94,11 +99,13 @@ main (int argc, char **argv)
94 printf (_("Could not open stderr for %s\n"), cmd); 99 printf (_("Could not open stderr for %s\n"), cmd);
95 } 100 }
96 101
102 bzero(tstr, sizeof(tstr));
97 buf = malloc(MAX_INPUT_BUFFER); 103 buf = malloc(MAX_INPUT_BUFFER);
98 printf ("<A href=\"%s\">", argv[1]); 104 printf ("<A href=\"%s\">", argv[1]);
99 while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) { 105 while (fgets (buf, MAX_INPUT_BUFFER - 1, child_process)) {
100 found++; 106 found++;
101 printf ("%s", buf); 107 /* Collect the string in temp str so we can tokenize */
108 strcat(tstr, buf);
102 } 109 }
103 110
104 if (!found) 111 if (!found)
@@ -106,6 +113,19 @@ main (int argc, char **argv)
106 _("%s UNKNOWN - No data received from host\nCMD: %s</A>\n"), 113 _("%s UNKNOWN - No data received from host\nCMD: %s</A>\n"),
107 argv[0], cmd); 114 argv[0], cmd);
108 115
116
117 /* chop the newline character */
118 if ((nstr = strchr(tstr, NEWLINE_CHARACTER)) != NULL)
119 *nstr = '\0';
120
121 /* tokenize the string for Perfdata if there is some */
122 nstr = strtok(tstr, PERF_CHARACTER);
123 printf ("%s", nstr);
124 printf ("</A>");
125 nstr = strtok(NULL, PERF_CHARACTER);
126 if (nstr != NULL)
127 printf (" | %s", nstr);
128
109 /* close the pipe */ 129 /* close the pipe */
110 result = spclose (child_process); 130 result = spclose (child_process);
111 131
@@ -116,7 +136,6 @@ main (int argc, char **argv)
116 /* close stderr */ 136 /* close stderr */
117 (void) fclose (child_stderr); 137 (void) fclose (child_stderr);
118 138
119 printf ("</A>\n");
120 return result; 139 return result;
121} 140}
122 141