diff options
Diffstat (limited to 'plugins/urlize.c')
-rw-r--r-- | plugins/urlize.c | 89 |
1 files changed, 47 insertions, 42 deletions
diff --git a/plugins/urlize.c b/plugins/urlize.c index b9217072..12fb3ec9 100644 --- a/plugins/urlize.c +++ b/plugins/urlize.c | |||
@@ -38,14 +38,52 @@ | |||
38 | *****************************************************************************/ | 38 | *****************************************************************************/ |
39 | 39 | ||
40 | const char *progname = "urlize"; | 40 | const char *progname = "urlize"; |
41 | const char *revision = "$Revision$"; | ||
42 | const char *copyright = "2000-2003"; | ||
43 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
41 | 44 | ||
42 | #include "common.h" | 45 | #include "common.h" |
43 | #include "utils.h" | 46 | #include "utils.h" |
44 | #include "popen.h" | 47 | #include "popen.h" |
45 | 48 | ||
46 | void print_usage (const char *); | 49 | void |
47 | void print_help (const char *); | 50 | print_usage (void) |
51 | { | ||
52 | printf (_("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n"), progname); | ||
53 | } | ||
54 | |||
55 | void | ||
56 | print_help (void) | ||
57 | { | ||
58 | print_revision (progname, revision); | ||
48 | 59 | ||
60 | printf (_("Copyright (c) 2000 Karl DeBisschop <kdebisschop@users.sourceforge.net>\n")); | ||
61 | printf (_(COPYRIGHT), copyright, email); | ||
62 | |||
63 | printf (_("\n\ | ||
64 | This plugin wraps the text output of another command (plugin) in HTML\n\ | ||
65 | <A> tags, thus displaying the plugin output in as a clickable link in\n\ | ||
66 | the Nagios status screen. The return status is the same as the invoked\n\ | ||
67 | plugin.\n\n")); | ||
68 | |||
69 | print_usage (); | ||
70 | |||
71 | printf (_("\n\ | ||
72 | Pay close attention to quoting to ensure that the shell passes the expected\n\ | ||
73 | data to the plugin. For example, in:\n\ | ||
74 | \n\ | ||
75 | urlize http://example.com/ check_http -H example.com -r 'two words'\n\ | ||
76 | \n\ | ||
77 | the shell will remove the single quotes and urlize will see:\n\ | ||
78 | \n\ | ||
79 | urlize http://example.com/ check_http -H example.com -r two words\n\ | ||
80 | \n\ | ||
81 | You probably want:\n\ | ||
82 | \n\ | ||
83 | urlize http://example.com/ \"check_http -H example.com -r 'two words'\"\n")); | ||
84 | exit (STATE_OK); | ||
85 | } | ||
86 | |||
49 | int | 87 | int |
50 | main (int argc, char **argv) | 88 | main (int argc, char **argv) |
51 | { | 89 | { |
@@ -54,22 +92,22 @@ main (int argc, char **argv) | |||
54 | char input_buffer[MAX_INPUT_BUFFER]; | 92 | char input_buffer[MAX_INPUT_BUFFER]; |
55 | 93 | ||
56 | if (argc < 2) { | 94 | if (argc < 2) { |
57 | print_usage (progname); | 95 | print_usage (); |
58 | exit (STATE_UNKNOWN); | 96 | exit (STATE_UNKNOWN); |
59 | } | 97 | } |
60 | 98 | ||
61 | if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) { | 99 | if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) { |
62 | print_help (argv[0]); | 100 | print_help (); |
63 | exit (STATE_OK); | 101 | exit (STATE_OK); |
64 | } | 102 | } |
65 | 103 | ||
66 | if (!strcmp (argv[1], "-V") || !strcmp (argv[1], "--version")) { | 104 | if (!strcmp (argv[1], "-V") || !strcmp (argv[1], "--version")) { |
67 | print_revision (progname, "$Revision$"); | 105 | print_revision (progname, revision); |
68 | exit (STATE_OK); | 106 | exit (STATE_OK); |
69 | } | 107 | } |
70 | 108 | ||
71 | if (argc < 2) { | 109 | if (argc < 2) { |
72 | print_usage (progname); | 110 | print_usage (); |
73 | exit (STATE_UNKNOWN); | 111 | exit (STATE_UNKNOWN); |
74 | } | 112 | } |
75 | 113 | ||
@@ -80,13 +118,13 @@ main (int argc, char **argv) | |||
80 | 118 | ||
81 | child_process = spopen (cmd); | 119 | child_process = spopen (cmd); |
82 | if (child_process == NULL) { | 120 | if (child_process == NULL) { |
83 | printf ("Could not open pipe: %s\n", cmd); | 121 | printf (_("Could not open pipe: %s\n"), cmd); |
84 | exit (STATE_UNKNOWN); | 122 | exit (STATE_UNKNOWN); |
85 | } | 123 | } |
86 | 124 | ||
87 | child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); | 125 | child_stderr = fdopen (child_stderr_array[fileno (child_process)], "r"); |
88 | if (child_stderr == NULL) { | 126 | if (child_stderr == NULL) { |
89 | printf ("Could not open stderr for %s\n", cmd); | 127 | printf (_("Could not open stderr for %s\n"), cmd); |
90 | } | 128 | } |
91 | 129 | ||
92 | printf ("<A href=\"%s\">", argv[1]); | 130 | printf ("<A href=\"%s\">", argv[1]); |
@@ -102,7 +140,7 @@ main (int argc, char **argv) | |||
102 | } | 140 | } |
103 | 141 | ||
104 | if (!found) { | 142 | if (!found) { |
105 | printf ("%s problem - No data recieved from host\nCMD: %s</A>\n", argv[0], | 143 | printf (_("%s problem - No data recieved from host\nCMD: %s</A>\n"), argv[0], |
106 | cmd); | 144 | cmd); |
107 | exit (STATE_UNKNOWN); | 145 | exit (STATE_UNKNOWN); |
108 | } | 146 | } |
@@ -120,36 +158,3 @@ main (int argc, char **argv) | |||
120 | printf ("</A>\n"); | 158 | printf ("</A>\n"); |
121 | return result; | 159 | return result; |
122 | } | 160 | } |
123 | |||
124 | void | ||
125 | print_usage (const char *cmd) | ||
126 | { | ||
127 | printf ("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n", cmd); | ||
128 | } | ||
129 | |||
130 | void | ||
131 | print_help (const char *cmd) | ||
132 | { | ||
133 | print_revision (progname, "$Revision$"); | ||
134 | printf ("\ | ||
135 | Copyright (c) 2000 Karl DeBisschop (kdebiss@alum.mit.edu)\n\n\ | ||
136 | \nThis plugin wraps the text output of another command (plugin) in HTML\n\ | ||
137 | <A> tags, thus displaying the plugin output in as a clickable link in\n\ | ||
138 | the Nagios status screen. The return status is the same as the invoked\n\ | ||
139 | plugin.\n\n"); | ||
140 | print_usage (cmd); | ||
141 | printf ("\n\ | ||
142 | Pay close attention to quoting to ensure that the shell passes the expected\n\ | ||
143 | data to the plugin. For example, in:\n\ | ||
144 | \n\ | ||
145 | urlize http://example.com/ check_http -H example.com -r 'two words'\n\ | ||
146 | \n\ | ||
147 | the shell will remove the single quotes and urlize will see:\n\ | ||
148 | \n\ | ||
149 | urlize http://example.com/ check_http -H example.com -r two words\n\ | ||
150 | \n\ | ||
151 | You probably want:\n\ | ||
152 | \n\ | ||
153 | urlize http://example.com/ \"check_http -H example.com -r 'two words'\"\n"); | ||
154 | exit (STATE_OK); | ||
155 | } | ||