diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 03:51:02 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-08 03:51:02 (GMT) |
commit | 92cd137176830bcdfbd477f151ba22d456b2e31c (patch) | |
tree | f242bbef29aefa991752da130e182562558934f5 /plugins/check_smtp.c | |
parent | ee37af8e56af48faab21a07c0cde1fa1d31c7849 (diff) | |
download | monitoring-plugins-92cd137176830bcdfbd477f151ba22d456b2e31c.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@661 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_smtp.c')
-rw-r--r-- | plugins/check_smtp.c | 188 |
1 files changed, 92 insertions, 96 deletions
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c index 7562c4c..f7c826b 100644 --- a/plugins/check_smtp.c +++ b/plugins/check_smtp.c | |||
@@ -1,70 +1,29 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * This program is free software; you can redistribute it and/or modify | 3 | This program is free software; you can redistribute it and/or modify |
4 | * it under the terms of the GNU General Public License as published by | 4 | it under the terms of the GNU General Public License as published by |
5 | * the Free Software Foundation; either version 2 of the License, or | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * (at your option) any later version. | 6 | (at your option) any later version. |
7 | * | 7 | |
8 | * This program is distributed in the hope that it will be useful, | 8 | This program is distributed in the hope that it will be useful, |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * GNU General Public License for more details. | 11 | GNU General Public License for more details. |
12 | * | 12 | |
13 | * You should have received a copy of the GNU General Public License | 13 | You should have received a copy of the GNU General Public License |
14 | * along with this program; if not, write to the Free Software | 14 | along with this program; if not, write to the Free Software |
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * | 16 | |
17 | *****************************************************************************/ | 17 | ******************************************************************************/ |
18 | 18 | ||
19 | const char *progname = "check_smtp"; | 19 | const char *progname = "check_smtp"; |
20 | const char *revision = "$Revision$"; | 20 | const char *revision = "$Revision$"; |
21 | const char *copyright = "1999-2003"; | 21 | const char *copyright = "2000-2003"; |
22 | const char *authors = "Nagios Plugin Development Team"; | ||
23 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | 22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; |
24 | 23 | ||
25 | const char *summary = "\ | 24 | #include "common.h" |
26 | This plugin will attempt to open an SMTP connection with the host.\n"; | 25 | #include "netutils.h" |
27 | 26 | #include "utils.h" | |
28 | const char *description = "\ | ||
29 | Successul connects return STATE_OK, refusals and timeouts return\n\ | ||
30 | STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\ | ||
31 | connects, but incorrect reponse messages from the host result in\n\ | ||
32 | STATE_WARNING return values.\n"; | ||
33 | |||
34 | const char *option_summary = "\ | ||
35 | -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ | ||
36 | [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]"; | ||
37 | |||
38 | const char *options = "\ | ||
39 | -H, --hostname=STRING or IPADDRESS\n\ | ||
40 | Check server on the indicated host\n\ | ||
41 | -4, --use-ipv4\n\ | ||
42 | Use IPv4 protocol\n\ | ||
43 | -6, --use-ipv6\n\ | ||
44 | Use IPv6 protocol\n\ | ||
45 | -p, --port=INTEGER\n\ | ||
46 | Make connection on the indicated port (default: %d)\n\ | ||
47 | -e, --expect=STRING\n\ | ||
48 | String to expect in first line of server response (default: '%s')\n\ | ||
49 | -n, nocommand\n\ | ||
50 | Suppress SMTP command\n\ | ||
51 | -C, --command=STRING\n\ | ||
52 | SMTP command (default: '%s')\n\ | ||
53 | -f, --from=STRING\n\ | ||
54 | FROM-address to include in MAIL command, required by Exchange 2000\n\ | ||
55 | (default: '%s')\n\ | ||
56 | -w, --warning=INTEGER\n\ | ||
57 | Seconds necessary to result in a warning status\n\ | ||
58 | -c, --critical=INTEGER\n\ | ||
59 | Seconds necessary to result in a critical status\n\ | ||
60 | -t, --timeout=INTEGER\n\ | ||
61 | Seconds before connection attempt times out (default: %d)\n\ | ||
62 | -v, --verbose\n\ | ||
63 | Print extra information (command-line use only)\n\ | ||
64 | -h, --help\n\ | ||
65 | Print detailed help screen\n\ | ||
66 | -V, --version\n\ | ||
67 | Print version information\n\n"; | ||
68 | 27 | ||
69 | enum { | 28 | enum { |
70 | SMTP_PORT = 25 | 29 | SMTP_PORT = 25 |
@@ -73,11 +32,6 @@ const char *SMTP_EXPECT = "220"; | |||
73 | const char *SMTP_HELO = "HELO "; | 32 | const char *SMTP_HELO = "HELO "; |
74 | const char *SMTP_QUIT = "QUIT\r\n"; | 33 | const char *SMTP_QUIT = "QUIT\r\n"; |
75 | 34 | ||
76 | #include "config.h" | ||
77 | #include "common.h" | ||
78 | #include "netutils.h" | ||
79 | #include "utils.h" | ||
80 | |||
81 | int process_arguments (int, char **); | 35 | int process_arguments (int, char **); |
82 | int validate_arguments (void); | 36 | int validate_arguments (void); |
83 | void print_help (void); | 37 | void print_help (void); |
@@ -95,6 +49,11 @@ int critical_time = 0; | |||
95 | int check_critical_time = FALSE; | 49 | int check_critical_time = FALSE; |
96 | int verbose = 0; | 50 | int verbose = 0; |
97 | 51 | ||
52 | |||
53 | |||
54 | |||
55 | |||
56 | |||
98 | int | 57 | int |
99 | main (int argc, char **argv) | 58 | main (int argc, char **argv) |
100 | { | 59 | { |
@@ -107,7 +66,7 @@ main (int argc, char **argv) | |||
107 | struct timeval tv; | 66 | struct timeval tv; |
108 | 67 | ||
109 | if (process_arguments (argc, argv) != OK) | 68 | if (process_arguments (argc, argv) != OK) |
110 | usage ("Invalid command arguments supplied\n"); | 69 | usage (_("Invalid command arguments supplied\n")); |
111 | 70 | ||
112 | /* initialize the HELO command with the localhostname */ | 71 | /* initialize the HELO command with the localhostname */ |
113 | #ifndef HOST_MAX_BYTES | 72 | #ifndef HOST_MAX_BYTES |
@@ -141,7 +100,7 @@ main (int argc, char **argv) | |||
141 | /* watch for the SMTP connection string and */ | 100 | /* watch for the SMTP connection string and */ |
142 | /* return a WARNING status if we couldn't read any data */ | 101 | /* return a WARNING status if we couldn't read any data */ |
143 | if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) { | 102 | if (recv (sd, buffer, MAX_INPUT_BUFFER - 1, 0) == -1) { |
144 | printf ("recv() failed\n"); | 103 | printf (_("recv() failed\n")); |
145 | result = STATE_WARNING; | 104 | result = STATE_WARNING; |
146 | } | 105 | } |
147 | else { | 106 | else { |
@@ -150,9 +109,9 @@ main (int argc, char **argv) | |||
150 | /* make sure we find the response we are looking for */ | 109 | /* make sure we find the response we are looking for */ |
151 | if (!strstr (buffer, server_expect)) { | 110 | if (!strstr (buffer, server_expect)) { |
152 | if (server_port == SMTP_PORT) | 111 | if (server_port == SMTP_PORT) |
153 | printf ("Invalid SMTP response received from host\n"); | 112 | printf (_("Invalid SMTP response received from host\n")); |
154 | else | 113 | else |
155 | printf ("Invalid SMTP response received from host on port %d\n", | 114 | printf (_("Invalid SMTP response received from host on port %d\n"), |
156 | server_port); | 115 | server_port); |
157 | result = STATE_WARNING; | 116 | result = STATE_WARNING; |
158 | } | 117 | } |
@@ -182,7 +141,7 @@ main (int argc, char **argv) | |||
182 | recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); | 141 | recv(sd, buffer, MAX_INPUT_BUFFER-1, 0); |
183 | 142 | ||
184 | if (verbose) | 143 | if (verbose) |
185 | printf("DUMMYCMD: %s\n%s\n",from_str,buffer); | 144 | printf(_("DUMMYCMD: %s\n%s\n"),from_str,buffer); |
186 | 145 | ||
187 | } /* smtp_use_dummycmd */ | 146 | } /* smtp_use_dummycmd */ |
188 | 147 | ||
@@ -204,10 +163,10 @@ main (int argc, char **argv) | |||
204 | result = STATE_WARNING; | 163 | result = STATE_WARNING; |
205 | 164 | ||
206 | if (verbose) | 165 | if (verbose) |
207 | printf ("SMTP %s - %.3f sec. response time, %s|time=%.3f\n", | 166 | printf (_("SMTP %s - %.3f sec. response time, %s|time=%.3f\n"), |
208 | state_text (result), elapsed_time, buffer, elapsed_time); | 167 | state_text (result), elapsed_time, buffer, elapsed_time); |
209 | else | 168 | else |
210 | printf ("SMTP %s - %.3f second response time|time=%.3f\n", | 169 | printf (_("SMTP %s - %.3f second response time|time=%.3f\n"), |
211 | state_text (result), elapsed_time, elapsed_time); | 170 | state_text (result), elapsed_time, elapsed_time); |
212 | 171 | ||
213 | return result; | 172 | return result; |
@@ -217,7 +176,7 @@ main (int argc, char **argv) | |||
217 | 176 | ||
218 | 177 | ||
219 | 178 | ||
220 | 179 | ||
221 | /* process command-line arguments */ | 180 | /* process command-line arguments */ |
222 | int | 181 | int |
223 | process_arguments (int argc, char **argv) | 182 | process_arguments (int argc, char **argv) |
@@ -268,16 +227,14 @@ process_arguments (int argc, char **argv) | |||
268 | server_address = optarg; | 227 | server_address = optarg; |
269 | } | 228 | } |
270 | else { | 229 | else { |
271 | usage ("Invalid host name\n"); | 230 | usage (_("Invalid host name\n")); |
272 | } | 231 | } |
273 | break; | 232 | break; |
274 | case 'p': /* port */ | 233 | case 'p': /* port */ |
275 | if (is_intpos (optarg)) { | 234 | if (is_intpos (optarg)) |
276 | server_port = atoi (optarg); | 235 | server_port = atoi (optarg); |
277 | } | 236 | else |
278 | else { | 237 | usage (_("Server port must be a positive integer\n")); |
279 | usage ("Server port must be a positive integer\n"); | ||
280 | } | ||
281 | break; | 238 | break; |
282 | case 'f': /* from argument */ | 239 | case 'f': /* from argument */ |
283 | from_arg = optarg; | 240 | from_arg = optarg; |
@@ -298,7 +255,7 @@ process_arguments (int argc, char **argv) | |||
298 | check_critical_time = TRUE; | 255 | check_critical_time = TRUE; |
299 | } | 256 | } |
300 | else { | 257 | else { |
301 | usage ("Critical time must be a nonnegative integer\n"); | 258 | usage (_("Critical time must be a nonnegative integer\n")); |
302 | } | 259 | } |
303 | break; | 260 | break; |
304 | case 'w': /* warning time threshold */ | 261 | case 'w': /* warning time threshold */ |
@@ -307,7 +264,7 @@ process_arguments (int argc, char **argv) | |||
307 | check_warning_time = TRUE; | 264 | check_warning_time = TRUE; |
308 | } | 265 | } |
309 | else { | 266 | else { |
310 | usage ("Warning time must be a nonnegative integer\n"); | 267 | usage (_("Warning time must be a nonnegative integer\n")); |
311 | } | 268 | } |
312 | break; | 269 | break; |
313 | case 'v': /* verbose */ | 270 | case 'v': /* verbose */ |
@@ -318,7 +275,7 @@ process_arguments (int argc, char **argv) | |||
318 | socket_timeout = atoi (optarg); | 275 | socket_timeout = atoi (optarg); |
319 | } | 276 | } |
320 | else { | 277 | else { |
321 | usage ("Time interval must be a nonnegative integer\n"); | 278 | usage (_("Time interval must be a nonnegative integer\n")); |
322 | } | 279 | } |
323 | break; | 280 | break; |
324 | case '4': | 281 | case '4': |
@@ -328,7 +285,7 @@ process_arguments (int argc, char **argv) | |||
328 | #ifdef USE_IPV6 | 285 | #ifdef USE_IPV6 |
329 | address_family = AF_INET6; | 286 | address_family = AF_INET6; |
330 | #else | 287 | #else |
331 | usage ("IPv6 support not available\n"); | 288 | usage (_("IPv6 support not available\n")); |
332 | #endif | 289 | #endif |
333 | break; | 290 | break; |
334 | case 'V': /* version */ | 291 | case 'V': /* version */ |
@@ -338,7 +295,7 @@ process_arguments (int argc, char **argv) | |||
338 | print_help (); | 295 | print_help (); |
339 | exit (STATE_OK); | 296 | exit (STATE_OK); |
340 | case '?': /* help */ | 297 | case '?': /* help */ |
341 | usage ("Invalid argument\n"); | 298 | usage (_("Invalid argument\n")); |
342 | } | 299 | } |
343 | } | 300 | } |
344 | 301 | ||
@@ -348,7 +305,7 @@ process_arguments (int argc, char **argv) | |||
348 | if (is_host (argv[c])) | 305 | if (is_host (argv[c])) |
349 | server_address = argv[c]; | 306 | server_address = argv[c]; |
350 | else | 307 | else |
351 | usage ("Invalid host name"); | 308 | usage (_("Invalid host name")); |
352 | } | 309 | } |
353 | else { | 310 | else { |
354 | asprintf (&server_address, "127.0.0.1"); | 311 | asprintf (&server_address, "127.0.0.1"); |
@@ -375,17 +332,53 @@ validate_arguments (void) | |||
375 | 332 | ||
376 | 333 | ||
377 | 334 | ||
335 | |||
378 | void | 336 | void |
379 | print_help (void) | 337 | print_help (void) |
380 | { | 338 | { |
339 | char *myport; | ||
340 | asprintf (&myport, "%d", SMTP_PORT); | ||
341 | |||
381 | print_revision (progname, revision); | 342 | print_revision (progname, revision); |
382 | printf ("Copyright (c) %s %s\n\t<%s>\n\n%s\n", | 343 | |
383 | copyright, authors, email, summary); | 344 | printf (_("Copyright (c) 1999-2001 Ethan Galstad <nagios@nagios.org>\n")); |
345 | printf (_(COPYRIGHT), copyright, email); | ||
346 | |||
347 | printf(_("\ | ||
348 | This plugin will attempt to open an SMTP connection with the host.\n\n")); | ||
349 | |||
384 | print_usage (); | 350 | print_usage (); |
385 | printf ("\nOptions:\n"); | 351 | |
386 | printf (options, SMTP_PORT, SMTP_EXPECT, mail_command, from_arg, | 352 | printf (_(UT_HELP_VRSN)); |
387 | DEFAULT_SOCKET_TIMEOUT); | 353 | |
388 | support (); | 354 | printf (_(UT_HOST_PORT), 'p', myport); |
355 | |||
356 | printf (_(UT_IPv46)); | ||
357 | |||
358 | printf (_("\ | ||
359 | -e, --expect=STRING\n\ | ||
360 | String to expect in first line of server response (default: '%s')\n\ | ||
361 | -n, nocommand\n\ | ||
362 | Suppress SMTP command\n\ | ||
363 | -C, --command=STRING\n\ | ||
364 | SMTP command (default: '%s')\n\ | ||
365 | -f, --from=STRING\n\ | ||
366 | FROM-address to include in MAIL command, required by Exchange 2000\n\ | ||
367 | (default: '%s')\n"), SMTP_EXPECT, mail_command, from_arg); | ||
368 | |||
369 | printf (_(UT_WARN_CRIT)); | ||
370 | |||
371 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
372 | |||
373 | printf (_(UT_VERBOSE)); | ||
374 | |||
375 | printf(_("\n\ | ||
376 | Successul connects return STATE_OK, refusals and timeouts return\n\ | ||
377 | STATE_CRITICAL, other errors return STATE_UNKNOWN. Successful\n\ | ||
378 | connects, but incorrect reponse messages from the host result in\n\ | ||
379 | STATE_WARNING return values.\n")); | ||
380 | |||
381 | printf (_(UT_SUPPORT)); | ||
389 | } | 382 | } |
390 | 383 | ||
391 | 384 | ||
@@ -395,8 +388,11 @@ print_help (void) | |||
395 | void | 388 | void |
396 | print_usage (void) | 389 | print_usage (void) |
397 | { | 390 | { |
398 | printf ("Usage: %s %s\n" | 391 | printf ("\ |
399 | " %s --help\n" | 392 | Usage: %s -H host [-p port] [-e expect] [-C command] [-f from addr]\n\ |
400 | " %s --version\n", | 393 | [-w warn] [-c crit] [-t timeout] [-n] [-v] [-4|-6]\n", progname); |
401 | progname, option_summary, progname, progname); | 394 | printf (_(UT_HLP_VRS), progname, progname); |
402 | } | 395 | } |
396 | |||
397 | |||
398 | |||