diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 (GMT) |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-08-04 07:42:24 (GMT) |
commit | 55def28f6619ab0f9807a0195aa01da5d6ff1dc0 (patch) | |
tree | f0762811e1ff964e874d88bd4448b64213bcbd45 /plugins/check_udp.c | |
parent | 04b3d4554b829531ee4859859e7dd25fe660bba8 (diff) | |
download | monitoring-plugins-55def28f6619ab0f9807a0195aa01da5d6ff1dc0.tar.gz |
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@643 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_udp.c')
-rw-r--r-- | plugins/check_udp.c | 182 |
1 files changed, 80 insertions, 102 deletions
diff --git a/plugins/check_udp.c b/plugins/check_udp.c index da9a142..3e903df 100644 --- a/plugins/check_udp.c +++ b/plugins/check_udp.c | |||
@@ -1,57 +1,84 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | |
3 | * CHECK_UDP.C | 3 | This program is free software; you can redistribute it and/or modify |
4 | * | 4 | it under the terms of the GNU General Public License as published by |
5 | * Program: UDP port plugin for Nagios | 5 | the Free Software Foundation; either version 2 of the License, or |
6 | * License: GPL | 6 | (at your option) any later version. |
7 | * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) | 7 | |
8 | * | 8 | This program is distributed in the hope that it will be useful, |
9 | * Last Modified: $Date$ | 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * | 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 | * Command line: CHECK_UDP <host_address> [-p port] [-s send] [-e expect] \ | 11 | GNU General Public License for more details. |
12 | * [-wt warn_time] [-ct crit_time] [-to to_sec] | 12 | |
13 | * | 13 | You should have received a copy of the GNU General Public License |
14 | * Description: | 14 | along with this program; if not, write to the Free Software |
15 | * | 15 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
16 | * This plugin will attempt to connect to the specified port | 16 | |
17 | * on the host. Successul connects return STATE_OK, refusals | ||
18 | * and timeouts return STATE_CRITICAL, other errors return | ||
19 | * STATE_UNKNOWN. | ||
20 | * | ||
21 | * License Information: | ||
22 | * | ||
23 | * This program is free software; you can redistribute it and/or modify | ||
24 | * it under the terms of the GNU General Public License as published by | ||
25 | * the Free Software Foundation; either version 2 of the License, or | ||
26 | * (at your option) any later version. | ||
27 | * | ||
28 | * This program is distributed in the hope that it will be useful, | ||
29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
31 | * GNU General Public License for more details. | ||
32 | * | ||
33 | * You should have received a copy of the GNU General Public License | ||
34 | * along with this program; if not, write to the Free Software | ||
35 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
36 | * | ||
37 | *****************************************************************************/ | 17 | *****************************************************************************/ |
38 | 18 | ||
39 | #include "config.h" | 19 | const char *progname = "check_udp"; |
20 | const char *revision = "$Revision$"; | ||
21 | const char *copyright = "1999-2002"; | ||
22 | const char *email = "nagiosplug-devel@lists.sourceforge.net"; | ||
23 | |||
40 | #include "common.h" | 24 | #include "common.h" |
41 | #include "netutils.h" | 25 | #include "netutils.h" |
42 | #include "utils.h" | 26 | #include "utils.h" |
43 | 27 | ||
44 | const char *progname = "check_udp"; | 28 | /* Original Command line: |
29 | check_udp <host_address> [-p port] [-s send] [-e expect] \ | ||
30 | [-wt warn_time] [-ct crit_time] [-to to_sec] */ | ||
31 | void | ||
32 | print_usage (void) | ||
33 | { | ||
34 | printf (_("\ | ||
35 | Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\ | ||
36 | [-e expect] [-s send] [-t to_sec] [-v]\n"), progname); | ||
37 | } | ||
38 | |||
39 | void | ||
40 | print_help (void) | ||
41 | { | ||
42 | print_revision (progname, revision); | ||
43 | |||
44 | printf (_("Copyright (c) 1999 Ethan Galstad\n")); | ||
45 | printf (_(COPYRIGHT), copyright, email); | ||
46 | |||
47 | printf (_("\ | ||
48 | This plugin tests an UDP connection with the specified host.\n\n")); | ||
49 | |||
50 | print_usage (); | ||
51 | |||
52 | printf (_(UT_HELP_VRSN)); | ||
53 | |||
54 | printf (_(UT_HOST_PORT), 'p', "none"); | ||
55 | |||
56 | printf (_("\ | ||
57 | -e, --expect=STRING <optional>\n\ | ||
58 | String to expect in first line of server response\n\ | ||
59 | -s, --send=STRING <optional>\n\ | ||
60 | String to send to the server when initiating the connection\n")); | ||
61 | |||
62 | printf (_(UT_WARN_CRIT)); | ||
63 | |||
64 | printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); | ||
65 | |||
66 | printf (_(UT_VERBOSE)); | ||
67 | |||
68 | printf (_("\ | ||
69 | This plugin will attempt to connect to the specified port on the host.\n\ | ||
70 | Successful connects return STATE_OK, refusals and timeouts return\n\ | ||
71 | STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n")); | ||
72 | |||
73 | printf(_(UT_SUPPORT)); | ||
74 | } | ||
75 | |||
76 | int process_arguments (int, char **); | ||
45 | 77 | ||
46 | int warning_time = 0; | 78 | int warning_time = 0; |
47 | int check_warning_time = FALSE; | 79 | int check_warning_time = FALSE; |
48 | int critical_time = 0; | 80 | int critical_time = 0; |
49 | int check_critical_time = FALSE; | 81 | int check_critical_time = FALSE; |
50 | |||
51 | int process_arguments (int, char **); | ||
52 | void print_usage (void); | ||
53 | void print_help (void); | ||
54 | |||
55 | int verbose = FALSE; | 82 | int verbose = FALSE; |
56 | int server_port = 0; | 83 | int server_port = 0; |
57 | char *server_address = NULL; | 84 | char *server_address = NULL; |
@@ -104,8 +131,8 @@ main (int argc, char **argv) | |||
104 | && (end_time - start_time) > warning_time) result = | 131 | && (end_time - start_time) > warning_time) result = |
105 | STATE_WARNING; | 132 | STATE_WARNING; |
106 | 133 | ||
107 | printf ("Connection %s on port %d - %d second response time\n", | 134 | printf (_("Connection %s on port %d - %d second response time\n"), |
108 | (result == STATE_OK) ? "accepted" : "problem", server_port, | 135 | (result == STATE_OK) ? _("accepted") : _("problem"), server_port, |
109 | (int) (end_time - start_time)); | 136 | (int) (end_time - start_time)); |
110 | } | 137 | } |
111 | 138 | ||
@@ -159,43 +186,43 @@ process_arguments (int argc, char **argv) | |||
159 | 186 | ||
160 | switch (c) { | 187 | switch (c) { |
161 | case '?': /* print short usage statement if args not parsable */ | 188 | case '?': /* print short usage statement if args not parsable */ |
162 | printf ("%s: Unknown argument: %s\n\n", progname, optarg); | 189 | printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); |
163 | print_usage (); | 190 | print_usage (); |
164 | exit (STATE_UNKNOWN); | 191 | exit (STATE_UNKNOWN); |
165 | case 'h': /* help */ | 192 | case 'h': /* help */ |
166 | print_help (); | 193 | print_help (); |
167 | exit (STATE_OK); | 194 | exit (STATE_OK); |
168 | case 'V': /* version */ | 195 | case 'V': /* version */ |
169 | print_revision (progname, "$Revision$"); | 196 | print_revision (progname, revision); |
170 | exit (STATE_OK); | 197 | exit (STATE_OK); |
171 | case 'v': /* verbose mode */ | 198 | case 'v': /* verbose mode */ |
172 | verbose = TRUE; | 199 | verbose = TRUE; |
173 | break; | 200 | break; |
174 | case 'H': /* hostname */ | 201 | case 'H': /* hostname */ |
175 | if (is_host (optarg) == FALSE) | 202 | if (is_host (optarg) == FALSE) |
176 | usage ("Invalid host name/address\n"); | 203 | usage (_("Invalid host name/address\n")); |
177 | server_address = optarg; | 204 | server_address = optarg; |
178 | break; | 205 | break; |
179 | case 'c': /* critical */ | 206 | case 'c': /* critical */ |
180 | if (!is_intnonneg (optarg)) | 207 | if (!is_intnonneg (optarg)) |
181 | usage ("Critical threshold must be a nonnegative integer\n"); | 208 | usage (_("Critical threshold must be a nonnegative integer\n")); |
182 | critical_time = atoi (optarg); | 209 | critical_time = atoi (optarg); |
183 | check_critical_time = TRUE; | 210 | check_critical_time = TRUE; |
184 | break; | 211 | break; |
185 | case 'w': /* warning */ | 212 | case 'w': /* warning */ |
186 | if (!is_intnonneg (optarg)) | 213 | if (!is_intnonneg (optarg)) |
187 | usage ("Warning threshold must be a nonnegative integer\n"); | 214 | usage (_("Warning threshold must be a nonnegative integer\n")); |
188 | warning_time = atoi (optarg); | 215 | warning_time = atoi (optarg); |
189 | check_warning_time = TRUE; | 216 | check_warning_time = TRUE; |
190 | break; | 217 | break; |
191 | case 't': /* timeout */ | 218 | case 't': /* timeout */ |
192 | if (!is_intnonneg (optarg)) | 219 | if (!is_intnonneg (optarg)) |
193 | usage ("Timeout interval must be a nonnegative integer\n"); | 220 | usage (_("Timeout interval must be a nonnegative integer\n")); |
194 | socket_timeout = atoi (optarg); | 221 | socket_timeout = atoi (optarg); |
195 | break; | 222 | break; |
196 | case 'p': /* port */ | 223 | case 'p': /* port */ |
197 | if (!is_intnonneg (optarg)) | 224 | if (!is_intnonneg (optarg)) |
198 | usage ("Serevr port must be a nonnegative integer\n"); | 225 | usage (_("Server port must be a nonnegative integer\n")); |
199 | server_port = atoi (optarg); | 226 | server_port = atoi (optarg); |
200 | break; | 227 | break; |
201 | case 'e': /* expect */ | 228 | case 'e': /* expect */ |
@@ -210,61 +237,12 @@ process_arguments (int argc, char **argv) | |||
210 | c = optind; | 237 | c = optind; |
211 | if (server_address == NULL && c < argc && argv[c]) { | 238 | if (server_address == NULL && c < argc && argv[c]) { |
212 | if (is_host (argv[c]) == FALSE) | 239 | if (is_host (argv[c]) == FALSE) |
213 | usage ("Invalid host name/address\n"); | 240 | usage (_("Invalid host name/address\n")); |
214 | server_address = argv[c++]; | 241 | server_address = argv[c++]; |
215 | } | 242 | } |
216 | 243 | ||
217 | if (server_address == NULL) | 244 | if (server_address == NULL) |
218 | usage ("Host name was not supplied\n"); | 245 | usage (_("Host name was not supplied\n")); |
219 | 246 | ||
220 | return c; | 247 | return c; |
221 | } | 248 | } |
222 | |||
223 | |||
224 | |||
225 | |||
226 | |||
227 | void | ||
228 | print_usage (void) | ||
229 | { | ||
230 | printf | ||
231 | ("Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n" | ||
232 | " [-e expect] [-s send] [-t to_sec] [-v]\n", progname); | ||
233 | } | ||
234 | |||
235 | |||
236 | |||
237 | |||
238 | |||
239 | void | ||
240 | print_help (void) | ||
241 | { | ||
242 | print_revision (progname, "$Revision$"); | ||
243 | printf | ||
244 | ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n" | ||
245 | "This plugin tests an UDP connection with the specified host.\n\n"); | ||
246 | print_usage (); | ||
247 | printf | ||
248 | ("Options:\n" | ||
249 | " -H, --hostname=ADDRESS\n" | ||
250 | " Host name argument for servers using host headers (use numeric\n" | ||
251 | " address if possible to bypass DNS lookup).\n" | ||
252 | " -p, --port=INTEGER\n" | ||
253 | " Port number\n" | ||
254 | " -e, --expect=STRING <optional>\n" | ||
255 | " String to expect in first line of server response\n" | ||
256 | " -s, --send=STRING <optional>\n" | ||
257 | " String to send to the server when initiating the connection\n" | ||
258 | " -w, --warning=INTEGER <optional>\n" | ||
259 | " Response time to result in warning status (seconds)\n" | ||
260 | " -c, --critical=INTEGER <optional>\n" | ||
261 | " Response time to result in critical status (seconds)\n" | ||
262 | " -t, --timeout=INTEGER <optional>\n" | ||
263 | " Seconds before connection times out (default: %d)\n" | ||
264 | " -v, --verbose <optional>\n" | ||
265 | " Show details for command-line debugging (do not use with nagios server)\n" | ||
266 | " -h, --help\n" | ||
267 | " Print detailed help screen and exit\n" | ||
268 | " -V, --version\n" | ||
269 | " Print version information and exit\n", DEFAULT_SOCKET_TIMEOUT); | ||
270 | } | ||