summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 08:13:20 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-08-04 08:13:20 +0000
commitc878b033f7f732ba37a398d13c3bbff7e08b6a7d (patch)
treec7df24346b1124e3379a4faf7def8852f0494959 /plugins
parent55def28f6619ab0f9807a0195aa01da5d6ff1dc0 (diff)
downloadmonitoring-plugins-c878b033f7f732ba37a398d13c3bbff7e08b6a7d.tar.gz
markup for translation
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@644 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_time.c211
-rw-r--r--plugins/check_udp.c1
2 files changed, 94 insertions, 118 deletions
diff --git a/plugins/check_time.c b/plugins/check_time.c
index 70bb6906..b3210bc3 100644
--- a/plugins/check_time.c
+++ b/plugins/check_time.c
@@ -1,53 +1,80 @@
1/****************************************************************************** 1/******************************************************************************
2* 2
3* CHECK_TIME.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: Network time server 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* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 8 This program is distributed in the hope that it will be useful,
9* 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10* $Id$ 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* 11 GNU General Public License for more details.
12* Description: 12
13* 13 You should have received a copy of the GNU General Public License
14* This plugin will attempt to connect to the specified port 14 along with this program; if not, write to the Free Software
15* on the host. Successul connects return STATE_OK, refusals 15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16* and timeouts return STATE_CRITICAL, other errors return 16
17* STATE_UNKNOWN. 17******************************************************************************/
18* 18
19* License Information:
20*
21* This program is free software; you can redistribute it and/or modify
22* it under the terms of the GNU General Public License as published by
23* the Free Software Foundation; either version 2 of the License, or
24* (at your option) any later version.
25*
26* This program is distributed in the hope that it will be useful,
27* but WITHOUT ANY WARRANTY; without even the implied warranty of
28* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29* GNU General Public License for more details.
30*
31* You should have received a copy of the GNU General Public License
32* along with this program; if not, write to the Free Software
33* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
34*
35*****************************************************************************/
36
37#include "config.h"
38#include "common.h" 19#include "common.h"
39#include "netutils.h" 20#include "netutils.h"
40#include "utils.h" 21#include "utils.h"
41 22
42const char *progname = "check_time"; 23const char *progname = "check_time";
43#define REVISION "$Revision$" 24const char *revision = "$Revision$";
44#define COPYRIGHT "1999-2002" 25const char *copyright = "1999-2003";
45#define AUTHOR "Ethan Galstad" 26const char *email = "nagiosplug-devel@lists.sourceforge.net";
46#define EMAIL "nagios@nagios.org" 27
47#define SUMMARY "Check time on the specified host.\n" 28enum {
29 TIME_PORT = 37
30};
31
32void
33print_usage (void)
34{
35 printf (_("\
36Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
37 [-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
38 printf (_(UT_HLP_VRS), progname, progname);
39}
40
41void
42print_help (void)
43{
44 char *myport;
45 asprintf (&myport, "%d", TIME_PORT);
46
47 print_revision (progname, revision);
48
49 printf (_("Copyright (c) 1999 Ethan Galstad\n"));
50 printf (_(COPYRIGHT), copyright, email);
51
52 printf (_("\
53This plugin will check the time on the specified host.\n\n"));
48 54
49#define TIME_PORT 37 55 print_usage ();
50#define UNIX_EPOCH 2208988800UL 56
57 printf (_(UT_HELP_VRSN));
58
59 printf (_(UT_HOST_PORT), 'p', myport);
60
61 printf (_("\
62 -w, --warning-variance=INTEGER\n\
63 Time difference (sec.) necessary to result in a warning status\n\
64 -c, --critical-variance=INTEGER\n\
65 Time difference (sec.) necessary to result in a critical status\n\
66 -W, --warning-connect=INTEGER\n\
67 Response time (sec.) necessary to result in warning status\n\
68 -C, --critical-connect=INTEGER\n\
69 Response time (sec.) necessary to result in critical status\n"));
70
71 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
72
73 support ();
74}
75
76
77#define UNIX_EPOCH 2208988800UL
51 78
52unsigned long server_time, raw_server_time; 79unsigned long server_time, raw_server_time;
53time_t diff_time; 80time_t diff_time;
@@ -75,7 +102,7 @@ main (int argc, char **argv)
75 int result; 102 int result;
76 103
77 if (process_arguments (argc, argv) != OK) 104 if (process_arguments (argc, argv) != OK)
78 usage ("Invalid command arguments supplied\n"); 105 usage (_("Invalid command arguments supplied\n"));
79 106
80 /* initialize alarm signal handling */ 107 /* initialize alarm signal handling */
81 signal (SIGALRM, socket_timeout_alarm_handler); 108 signal (SIGALRM, socket_timeout_alarm_handler);
@@ -93,7 +120,7 @@ main (int argc, char **argv)
93 else 120 else
94 result = STATE_UNKNOWN; 121 result = STATE_UNKNOWN;
95 terminate (result, 122 terminate (result,
96 "TIME UNKNOWN - could not connect to server %s, port %d\n", 123 _("TIME UNKNOWN - could not connect to server %s, port %d\n"),
97 server_address, server_port); 124 server_address, server_port);
98 } 125 }
99 126
@@ -116,7 +143,7 @@ main (int argc, char **argv)
116 else 143 else
117 result = STATE_UNKNOWN; 144 result = STATE_UNKNOWN;
118 terminate (result, 145 terminate (result,
119 "TIME UNKNOWN - no data on recv() from server %s, port %d\n", 146 _("TIME UNKNOWN - no data on recv() from server %s, port %d\n"),
120 server_address, server_port); 147 server_address, server_port);
121 } 148 }
122 149
@@ -128,21 +155,21 @@ main (int argc, char **argv)
128 && (end_time - start_time) > warning_time) result = STATE_WARNING; 155 && (end_time - start_time) > warning_time) result = STATE_WARNING;
129 156
130 if (result != STATE_OK) 157 if (result != STATE_OK)
131 terminate (result, "TIME %s - %d second response time\n", 158 terminate (result, _("TIME %s - %d second response time\n"),
132 state_text (result), (int) (end_time - start_time)); 159 state_text (result), (int) (end_time - start_time));
133 160
134 server_time = ntohl (raw_server_time) - UNIX_EPOCH; 161 server_time = ntohl (raw_server_time) - UNIX_EPOCH;
135 if (server_time > end_time) 162 if (server_time > (unsigned long)end_time)
136 diff_time = server_time - end_time; 163 diff_time = server_time - (unsigned long)end_time;
137 else 164 else
138 diff_time = end_time - server_time; 165 diff_time = (unsigned long)end_time - server_time;
139 166
140 if (check_critical_diff == TRUE && diff_time > critical_diff) 167 if (check_critical_diff == TRUE && diff_time > (time_t)critical_diff)
141 result = STATE_CRITICAL; 168 result = STATE_CRITICAL;
142 else if (check_warning_diff == TRUE && diff_time > warning_diff) 169 else if (check_warning_diff == TRUE && diff_time > (time_t)warning_diff)
143 result = STATE_WARNING; 170 result = STATE_WARNING;
144 171
145 printf ("TIME %s - %lu second time difference\n", state_text (result), 172 printf (_("TIME %s - %lu second time difference\n"), state_text (result),
146 diff_time); 173 diff_time);
147 return result; 174 return result;
148} 175}
@@ -197,16 +224,16 @@ process_arguments (int argc, char **argv)
197 224
198 switch (c) { 225 switch (c) {
199 case '?': /* print short usage statement if args not parsable */ 226 case '?': /* print short usage statement if args not parsable */
200 usage3 ("Unknown argument", optopt); 227 usage3 (_("Unknown argument"), optopt);
201 case 'h': /* help */ 228 case 'h': /* help */
202 print_help (); 229 print_help ();
203 exit (STATE_OK); 230 exit (STATE_OK);
204 case 'V': /* version */ 231 case 'V': /* version */
205 print_revision (progname, REVISION); 232 print_revision (progname, revision);
206 exit (STATE_OK); 233 exit (STATE_OK);
207 case 'H': /* hostname */ 234 case 'H': /* hostname */
208 if (is_host (optarg) == FALSE) 235 if (is_host (optarg) == FALSE)
209 usage ("Invalid host name/address\n"); 236 usage (_("Invalid host name/address\n"));
210 server_address = optarg; 237 server_address = optarg;
211 break; 238 break;
212 case 'w': /* warning-variance */ 239 case 'w': /* warning-variance */
@@ -220,11 +247,11 @@ process_arguments (int argc, char **argv)
220 check_warning_time = TRUE; 247 check_warning_time = TRUE;
221 } 248 }
222 else { 249 else {
223 usage ("Warning thresholds must be a nonnegative integer\n"); 250 usage (_("Warning thresholds must be a nonnegative integer\n"));
224 } 251 }
225 } 252 }
226 else { 253 else {
227 usage ("Warning threshold must be a nonnegative integer\n"); 254 usage (_("Warning threshold must be a nonnegative integer\n"));
228 } 255 }
229 break; 256 break;
230 case 'c': /* critical-variance */ 257 case 'c': /* critical-variance */
@@ -239,33 +266,33 @@ process_arguments (int argc, char **argv)
239 check_critical_time = TRUE; 266 check_critical_time = TRUE;
240 } 267 }
241 else { 268 else {
242 usage ("Critical thresholds must be a nonnegative integer\n"); 269 usage (_("Critical thresholds must be a nonnegative integer\n"));
243 } 270 }
244 } 271 }
245 else { 272 else {
246 usage ("Critical threshold must be a nonnegative integer\n"); 273 usage (_("Critical threshold must be a nonnegative integer\n"));
247 } 274 }
248 break; 275 break;
249 case 'W': /* warning-connect */ 276 case 'W': /* warning-connect */
250 if (!is_intnonneg (optarg)) 277 if (!is_intnonneg (optarg))
251 usage ("Warning threshold must be a nonnegative integer\n"); 278 usage (_("Warning threshold must be a nonnegative integer\n"));
252 warning_time = atoi (optarg); 279 warning_time = atoi (optarg);
253 check_warning_time = TRUE; 280 check_warning_time = TRUE;
254 break; 281 break;
255 case 'C': /* critical-connect */ 282 case 'C': /* critical-connect */
256 if (!is_intnonneg (optarg)) 283 if (!is_intnonneg (optarg))
257 usage ("Critical threshold must be a nonnegative integer\n"); 284 usage (_("Critical threshold must be a nonnegative integer\n"));
258 critical_time = atoi (optarg); 285 critical_time = atoi (optarg);
259 check_critical_time = TRUE; 286 check_critical_time = TRUE;
260 break; 287 break;
261 case 'p': /* port */ 288 case 'p': /* port */
262 if (!is_intnonneg (optarg)) 289 if (!is_intnonneg (optarg))
263 usage ("Serevr port must be a nonnegative integer\n"); 290 usage (_("Server port must be a nonnegative integer\n"));
264 server_port = atoi (optarg); 291 server_port = atoi (optarg);
265 break; 292 break;
266 case 't': /* timeout */ 293 case 't': /* timeout */
267 if (!is_intnonneg (optarg)) 294 if (!is_intnonneg (optarg))
268 usage ("Timeout interval must be a nonnegative integer\n"); 295 usage (_("Timeout interval must be a nonnegative integer\n"));
269 socket_timeout = atoi (optarg); 296 socket_timeout = atoi (optarg);
270 break; 297 break;
271 } 298 }
@@ -275,65 +302,13 @@ process_arguments (int argc, char **argv)
275 if (server_address == NULL) { 302 if (server_address == NULL) {
276 if (argc > c) { 303 if (argc > c) {
277 if (is_host (argv[c]) == FALSE) 304 if (is_host (argv[c]) == FALSE)
278 usage ("Invalid host name/address\n"); 305 usage (_("Invalid host name/address\n"));
279 server_address = argv[c]; 306 server_address = argv[c];
280 } 307 }
281 else { 308 else {
282 usage ("Host name was not supplied\n"); 309 usage (_("Host name was not supplied\n"));
283 } 310 }
284 } 311 }
285 312
286 return OK; 313 return OK;
287} 314}
288
289
290
291
292
293void
294print_usage (void)
295{
296 printf
297 ("Usage:\n"
298 " %s -H <host_address> [-p port] [-w variance] [-c variance]\n"
299 " [-W connect_time] [-C connect_time] [-t timeout]\n"
300 " %s (-h | --help) for detailed help\n"
301 " %s (-V | --version) for version information\n",
302 progname, progname, progname);
303}
304
305
306
307
308
309void
310print_help (void)
311{
312 print_revision (progname, REVISION);
313 printf
314 ("Copyright (c) %s %s <%s>\n\n%s\n",
315 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
316 print_usage ();
317 printf
318 ("Options:\n"
319 " -H, --hostname=ADDRESS\n"
320 " Host name argument for servers using host headers (use numeric\n"
321 " address if possible to bypass DNS lookup).\n"
322 " -w, --warning-variance=INTEGER\n"
323 " Time difference (sec.) necessary to result in a warning status\n"
324 " -c, --critical-variance=INTEGER\n"
325 " Time difference (sec.) necessary to result in a critical status\n"
326 " -W, --warning-connect=INTEGER\n"
327 " Response time (sec.) necessary to result in warning status\n"
328 " -C, --critical-connect=INTEGER\n"
329 " Response time (sec.) necessary to result in critical status\n"
330 " -t, --timeout=INTEGER\n"
331 " Seconds before connection times out (default: %d)\n"
332 " -p, --port=INTEGER\n"
333 " Port number (default: %d)\n"
334 " -h, --help\n"
335 " Print detailed help screen\n"
336 " -V, --version\n"
337 " Print version information\n\n", DEFAULT_SOCKET_TIMEOUT, TIME_PORT);
338 support ();
339}
diff --git a/plugins/check_udp.c b/plugins/check_udp.c
index 3e903dfc..11b942a4 100644
--- a/plugins/check_udp.c
+++ b/plugins/check_udp.c
@@ -34,6 +34,7 @@ print_usage (void)
34 printf (_("\ 34 printf (_("\
35Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\ 35Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
36 [-e expect] [-s send] [-t to_sec] [-v]\n"), progname); 36 [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
37 printf (_(UT_HLP_VRS), progname, progname);
37} 38}
38 39
39void 40void