summaryrefslogtreecommitdiffstats
path: root/plugins/check_dns.c
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2005-11-14 00:51:44 (GMT)
committerBenoit Mortier <opensides@users.sourceforge.net>2005-11-14 00:51:44 (GMT)
commitc68d99cee2d1b3de6a7e800440433a39a7436313 (patch)
treebecb58a009fd3b7016d16a44139f13d6f7b511d7 /plugins/check_dns.c
parent7741c005fa10be018264f17e685d5bde34bc92a3 (diff)
downloadmonitoring-plugins-c68d99cee2d1b3de6a7e800440433a39a7436313.tar.gz
start of the cleaning of the localization
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1282 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_dns.c')
-rw-r--r--plugins/check_dns.c667
1 files changed, 348 insertions, 319 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index d6e8ca2..faa1e15 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -23,7 +23,7 @@
23 23
24const char *progname = "check_dns"; 24const char *progname = "check_dns";
25const char *revision = "$Revision$"; 25const char *revision = "$Revision$";
26const char *copyright = "2000-2004"; 26const char *copyright = "2000-2005";
27const char *email = "nagiosplug-devel@lists.sourceforge.net"; 27const char *email = "nagiosplug-devel@lists.sourceforge.net";
28 28
29#include "common.h" 29#include "common.h"
@@ -49,156 +49,156 @@ int expect_authority = FALSE;
49int 49int
50main (int argc, char **argv) 50main (int argc, char **argv)
51{ 51{
52 char *command_line = NULL; 52 char *command_line = NULL;
53 char input_buffer[MAX_INPUT_BUFFER]; 53 char input_buffer[MAX_INPUT_BUFFER];
54 char *address = NULL; 54 char *address = NULL;
55 char *msg = NULL; 55 char *msg = NULL;
56 char *temp_buffer = NULL; 56 char *temp_buffer = NULL;
57 int non_authoritative = FALSE; 57 int non_authoritative = FALSE;
58 int result = STATE_UNKNOWN; 58 int result = STATE_UNKNOWN;
59 double elapsed_time; 59 double elapsed_time;
60 long microsec; 60 long microsec;
61 struct timeval tv; 61 struct timeval tv;
62 int multi_address; 62 int multi_address;
63 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */ 63 int parse_address = FALSE; /* This flag scans for Address: but only after Name: */
64 output chld_out, chld_err; 64 output chld_out, chld_err;
65 size_t i; 65 size_t i;
66 66
67 setlocale (LC_ALL, ""); 67 setlocale (LC_ALL, "");
68 bindtextdomain (PACKAGE, LOCALEDIR); 68 bindtextdomain (PACKAGE, LOCALEDIR);
69 textdomain (PACKAGE); 69 textdomain (PACKAGE);
70 70
71 /* Set signal handling and alarm */ 71 /* Set signal handling and alarm */
72 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) { 72 if (signal (SIGALRM, popen_timeout_alarm_handler) == SIG_ERR) {
73 usage_va(_("Cannot catch SIGALRM")); 73 usage_va(_("Cannot catch SIGALRM"));
74 } 74 }
75 75
76 if (process_arguments (argc, argv) == ERROR) { 76 if (process_arguments (argc, argv) == ERROR) {
77 usage_va(_("Could not parse arguments")); 77 usage_va(_("Could not parse arguments"));
78 } 78 }
79 79
80 /* get the command to run */ 80 /* get the command to run */
81 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server); 81 asprintf (&command_line, "%s %s %s", NSLOOKUP_COMMAND, query_address, dns_server);
82 82
83 alarm (timeout_interval); 83 alarm (timeout_interval);
84 gettimeofday (&tv, NULL); 84 gettimeofday (&tv, NULL);
85 85
86 if (verbose) 86 if (verbose)
87 printf ("%s\n", command_line); 87 printf ("%s\n", command_line);
88 88
89 /* run the command */ 89 /* run the command */
90 if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) { 90 if((np_runcmd(command_line, &chld_out, &chld_err, 0)) != 0) {
91 msg = (char *)_("nslookup returned error status"); 91 msg = (char *)_("nslookup returned an error status");
92 result = STATE_WARNING; 92 result = STATE_WARNING;
93 } 93 }
94 94
95 /* scan stdout */ 95 /* scan stdout */
96 for(i = 0; i < chld_out.lines; i++) { 96 for(i = 0; i < chld_out.lines; i++) {
97 if (verbose) 97 if (verbose)
98 puts(chld_out.line[i]); 98 puts(chld_out.line[i]);
99 99
100 if (strstr (chld_out.line[i], ".in-addr.arpa")) { 100 if (strstr (chld_out.line[i], ".in-addr.arpa")) {
101 if ((temp_buffer = strstr (chld_out.line[i], "name = "))) 101 if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
102 address = strdup (temp_buffer + 7); 102 address = strdup (temp_buffer + 7);
103 else { 103 else {
104 msg = (char *)_("Warning plugin error"); 104 msg = (char *)_("Warning plugin error");
105 result = STATE_WARNING; 105 result = STATE_WARNING;
106 } 106 }
107 } 107 }
108 108
109 /* the server is responding, we just got the host name... */ 109 /* the server is responding, we just got the host name... */
110 if (strstr (chld_out.line[i], "Name:")) 110 if (strstr (chld_out.line[i], "Name:"))
111 parse_address = TRUE; 111 parse_address = TRUE;
112 else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") || 112 else if (parse_address == TRUE && (strstr (chld_out.line[i], "Address:") ||
113 strstr (chld_out.line[i], "Addresses:"))) { 113 strstr (chld_out.line[i], "Addresses:"))) {
114 temp_buffer = index (chld_out.line[i], ':'); 114 temp_buffer = index (chld_out.line[i], ':');
115 temp_buffer++; 115 temp_buffer++;
116 116
117 /* Strip leading spaces */ 117 /* Strip leading spaces */
118 for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++) 118 for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
119 /* NOOP */; 119 /* NOOP */;
120 120
121 strip(temp_buffer); 121 strip(temp_buffer);
122 if (temp_buffer==NULL || strlen(temp_buffer)==0) { 122 if (temp_buffer==NULL || strlen(temp_buffer)==0) {
123 die (STATE_CRITICAL, 123 die (STATE_CRITICAL,
124 _("DNS CRITICAL - '%s' returned empty host name string\n"), 124 _("DNS CRITICAL - '%s' returned empty host name string\n"),
125 NSLOOKUP_COMMAND); 125 NSLOOKUP_COMMAND);
126 } 126 }
127 127
128 if (address == NULL) 128 if (address == NULL)
129 address = strdup (temp_buffer); 129 address = strdup (temp_buffer);
130 else 130 else
131 asprintf(&address, "%s,%s", address, temp_buffer); 131 asprintf(&address, "%s,%s", address, temp_buffer);
132 } 132 }
133 133
134 else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) { 134 else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {
135 non_authoritative = TRUE; 135 non_authoritative = TRUE;
136 } 136 }
137 137
138 result = error_scan (chld_out.line[i]); 138 result = error_scan (chld_out.line[i]);
139 if (result != STATE_OK) { 139 if (result != STATE_OK) {
140 msg = strchr (chld_out.line[i], ':'); 140 msg = strchr (chld_out.line[i], ':');
141 if(msg) msg++; 141 if(msg) msg++;
142 break; 142 break;
143 } 143 }
144 } 144 }
145 145
146 /* scan stderr */ 146 /* scan stderr */
147 for(i = 0; i < chld_err.lines; i++) { 147 for(i = 0; i < chld_err.lines; i++) {
148 if (verbose) 148 if (verbose)
149 puts(chld_err.line[i]); 149 puts(chld_err.line[i]);
150 150
151 if (error_scan (chld_err.line[i]) != STATE_OK) { 151 if (error_scan (chld_err.line[i]) != STATE_OK) {
152 result = max_state (result, error_scan (chld_err.line[i])); 152 result = max_state (result, error_scan (chld_err.line[i]));
153 msg = strchr(input_buffer, ':'); 153 msg = strchr(input_buffer, ':');
154 if(msg) msg++; 154 if(msg) msg++;
155 } 155 }
156 } 156 }
157 157
158 /* If we got here, we should have an address string, 158 /* If we got here, we should have an address string,
159 * and we can segfault if we do not */ 159 * and we can segfault if we do not */
160 if (address==NULL || strlen(address)==0) 160 if (address==NULL || strlen(address)==0)
161 die (STATE_CRITICAL, 161 die (STATE_CRITICAL,
162 _("DNS CRITICAL - '%s' msg parsing exited with no address\n"), 162 _("DNS CRITICAL - '%s' msg parsing exited with no address\n"),
163 NSLOOKUP_COMMAND); 163 NSLOOKUP_COMMAND);
164 164
165 /* compare to expected address */ 165 /* compare to expected address */
166 if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) { 166 if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
167 result = STATE_CRITICAL; 167 result = STATE_CRITICAL;
168 asprintf(&msg, _("expected %s but got %s"), expected_address, address); 168 asprintf(&msg, _("expected %s but got %s"), expected_address, address);
169 } 169 }
170 170
171 /* check if authoritative */ 171 /* check if authoritative */
172 if (result == STATE_OK && expect_authority && non_authoritative) { 172 if (result == STATE_OK && expect_authority && non_authoritative) {
173 result = STATE_CRITICAL; 173 result = STATE_CRITICAL;
174 asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address); 174 asprintf(&msg, _("server %s is not authoritative for %s"), dns_server, query_address);
175 } 175 }
176 176
177 microsec = deltime (tv); 177 microsec = deltime (tv);
178 elapsed_time = (double)microsec / 1.0e6; 178 elapsed_time = (double)microsec / 1.0e6;
179 179
180 if (result == STATE_OK) { 180 if (result == STATE_OK) {
181 if (strchr (address, ',') == NULL) 181 if (strchr (address, ',') == NULL)
182 multi_address = FALSE; 182 multi_address = FALSE;
183 else 183 else
184 multi_address = TRUE; 184 multi_address = TRUE;
185 185
186 printf ("DNS %s: ", _("OK")); 186 printf ("DNS %s: ", _("OK"));
187 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time); 187 printf (ngettext("%.3f second response time", "%.3f seconds response time", elapsed_time), elapsed_time);
188 printf (_(". %s returns %s"), query_address, address); 188 printf (_(". %s returns %s"), query_address, address);
189 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0)); 189 printf ("|%s\n", fperfdata ("time", elapsed_time, "s", FALSE, 0, FALSE, 0, TRUE, 0, FALSE, 0));
190 } 190 }
191 else if (result == STATE_WARNING) 191 else if (result == STATE_WARNING)
192 printf (_("DNS WARNING - %s\n"), 192 printf (_("DNS WARNING - %s\n"),
193 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); 193 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
194 else if (result == STATE_CRITICAL) 194 else if (result == STATE_CRITICAL)
195 printf (_("DNS CRITICAL - %s\n"), 195 printf (_("DNS CRITICAL - %s\n"),
196 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); 196 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
197 else 197 else
198 printf (_("DNS UNKNOW - %s\n"), 198 printf (_("DNS UNKNOW - %s\n"),
199 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg); 199 !strcmp (msg, "") ? _(" Probably a non-existent host/domain") : msg);
200 200
201 return result; 201 return result;
202} 202}
203 203
204 204
@@ -207,56 +207,56 @@ int
207error_scan (char *input_buffer) 207error_scan (char *input_buffer)
208{ 208{
209 209
210 /* the DNS lookup timed out */ 210 /* the DNS lookup timed out */
211 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) || 211 if (strstr (input_buffer, _("Note: nslookup is deprecated and may be removed from future releases.")) ||
212 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) || 212 strstr (input_buffer, _("Consider using the `dig' or `host' programs instead. Run nslookup with")) ||
213 strstr (input_buffer, _("the `-sil[ent]' option to prevent this message from appearing."))) 213 strstr (input_buffer, _("the `-sil[ent]' option to prevent this message from appearing.")))
214 return STATE_OK; 214 return STATE_OK;
215 215
216 /* DNS server is not running... */ 216 /* DNS server is not running... */
217 else if (strstr (input_buffer, "No response from server")) 217 else if (strstr (input_buffer, "No response from server"))
218 die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server); 218 die (STATE_CRITICAL, _("No response from DNS %s\n"), dns_server);
219 219
220 /* Host name is valid, but server doesn't have records... */ 220 /* Host name is valid, but server doesn't have records... */
221 else if (strstr (input_buffer, "No records")) 221 else if (strstr (input_buffer, "No records"))
222 die (STATE_CRITICAL, _("DNS %s has no records\n"), dns_server); 222 die (STATE_CRITICAL, _("DNS %s has no records\n"), dns_server);
223 223
224 /* Connection was refused */ 224 /* Connection was refused */
225 else if (strstr (input_buffer, "Connection refused") || 225 else if (strstr (input_buffer, "Connection refused") ||
226 strstr (input_buffer, "Couldn't find server") || 226 strstr (input_buffer, "Couldn't find server") ||
227 strstr (input_buffer, "Refused") || 227 strstr (input_buffer, "Refused") ||
228 (strstr (input_buffer, "** server can't find") && 228 (strstr (input_buffer, "** server can't find") &&
229 strstr (input_buffer, ": REFUSED"))) 229 strstr (input_buffer, ": REFUSED")))
230 die (STATE_CRITICAL, _("Connection to DNS %s was refused\n"), dns_server); 230 die (STATE_CRITICAL, _("Connection to DNS %s was refused\n"), dns_server);
231 231
232 /* Query refused (usually by an ACL in the namserver) */ 232 /* Query refused (usually by an ACL in the namserver) */
233 else if (strstr (input_buffer, "Query refused")) 233 else if (strstr (input_buffer, "Query refused"))
234 die (STATE_CRITICAL, _("Query was refused by DNS server at %s\n"), dns_server); 234 die (STATE_CRITICAL, _("Query was refused by DNS server at %s\n"), dns_server);
235 235
236 /* No information (e.g. nameserver IP has two PTR records) */ 236 /* No information (e.g. nameserver IP has two PTR records) */
237 else if (strstr (input_buffer, "No information")) 237 else if (strstr (input_buffer, "No information"))
238 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server); 238 die (STATE_CRITICAL, _("No information returned by DNS server at %s\n"), dns_server);
239 239
240 /* Host or domain name does not exist */ 240 /* Host or domain name does not exist */
241 else if (strstr (input_buffer, "Non-existent") || 241 else if (strstr (input_buffer, "Non-existent") ||
242 strstr (input_buffer, "** server can't find") || 242 strstr (input_buffer, "** server can't find") ||
243 strstr (input_buffer,"NXDOMAIN")) 243 strstr (input_buffer,"NXDOMAIN"))
244 die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address); 244 die (STATE_CRITICAL, _("Domain %s was not found by the server\n"), query_address);
245 245
246 /* Network is unreachable */ 246 /* Network is unreachable */
247 else if (strstr (input_buffer, "Network is unreachable")) 247 else if (strstr (input_buffer, "Network is unreachable"))
248 die (STATE_CRITICAL, _("Network is unreachable\n")); 248 die (STATE_CRITICAL, _("Network is unreachable\n"));
249 249
250 /* Internal server failure */ 250 /* Internal server failure */
251 else if (strstr (input_buffer, "Server failure")) 251 else if (strstr (input_buffer, "Server failure"))
252 die (STATE_CRITICAL, _("DNS failure for %s\n"), dns_server); 252 die (STATE_CRITICAL, _("DNS failure for %s\n"), dns_server);
253 253
254 /* Request error or the DNS lookup timed out */ 254 /* Request error or the DNS lookup timed out */
255 else if (strstr (input_buffer, "Format error") || 255 else if (strstr (input_buffer, "Format error") ||
256 strstr (input_buffer, "Timed out")) 256 strstr (input_buffer, "Timed out"))
257 return STATE_WARNING; 257 return STATE_WARNING;
258 258
259 return STATE_OK; 259 return STATE_OK;
260 260
261} 261}
262 262
@@ -265,148 +265,177 @@ error_scan (char *input_buffer)
265int 265int
266process_arguments (int argc, char **argv) 266process_arguments (int argc, char **argv)
267{ 267{
268 int c; 268 int c;
269 269
270 int opt_index = 0; 270 int opt_index = 0;
271 static struct option long_opts[] = { 271 static struct option long_opts[] = {
272 {"help", no_argument, 0, 'h'}, 272 {"help", no_argument, 0, 'h'},
273 {"version", no_argument, 0, 'V'}, 273 {"version", no_argument, 0, 'V'},
274 {"verbose", no_argument, 0, 'v'}, 274 {"verbose", no_argument, 0, 'v'},
275 {"timeout", required_argument, 0, 't'}, 275 {"timeout", required_argument, 0, 't'},
276 {"hostname", required_argument, 0, 'H'}, 276 {"hostname", required_argument, 0, 'H'},
277 {"server", required_argument, 0, 's'}, 277 {"server", required_argument, 0, 's'},
278 {"reverse-server", required_argument, 0, 'r'}, 278 {"reverse-server", required_argument, 0, 'r'},
279 {"expected-address", required_argument, 0, 'a'}, 279 {"expected-address", required_argument, 0, 'a'},
280 {"expect-authority", no_argument, 0, 'A'}, 280 {"expect-authority", no_argument, 0, 'A'},
281 {0, 0, 0, 0} 281 {0, 0, 0, 0}
282 }; 282 };
283 283
284 if (argc < 2) 284 if (argc < 2)
285 return ERROR; 285 return ERROR;
286 286
287 for (c = 1; c < argc; c++) 287 for (c = 1; c < argc; c++)
288 if (strcmp ("-to", argv[c]) == 0) 288 if (strcmp ("-to", argv[c]) == 0)
289 strcpy (argv[c], "-t"); 289 strcpy (argv[c], "-t");
290 290
291 while (1) { 291 while (1) {
292 c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index); 292 c = getopt_long (argc, argv, "hVvAt:H:s:r:a:", long_opts, &opt_index);
293 293
294 if (c == -1 || c == EOF) 294 if (c == -1 || c == EOF)
295 break; 295 break;
296 296
297 switch (c) { 297 switch (c) {
298 case 'h': /* help */ 298 case 'h': /* help */
299 print_help (); 299 print_help ();
300 exit (STATE_OK); 300 exit (STATE_OK);
301 case 'V': /* version */ 301 case 'V': /* version */
302 print_revision (progname, revision); 302 print_revision (progname, revision);
303 exit (STATE_OK); 303 exit (STATE_OK);
304 case 'v': /* version */ 304 case 'v': /* version */
305 verbose = TRUE; 305 verbose = TRUE;
306 break; 306 break;
307 case 't': /* timeout period */ 307 case 't': /* timeout period */
308 timeout_interval = atoi (optarg); 308 timeout_interval = atoi (optarg);
309 break; 309 break;
310 case 'H': /* hostname */ 310 case 'H': /* hostname */
311 if (strlen (optarg) >= ADDRESS_LENGTH) 311 if (strlen (optarg) >= ADDRESS_LENGTH)
312 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 312 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
313 strcpy (query_address, optarg); 313 strcpy (query_address, optarg);
314 break; 314 break;
315 case 's': /* server name */ 315 case 's': /* server name */
316 /* TODO: this host_or_die check is probably unnecessary. 316 /* TODO: this host_or_die check is probably unnecessary.
317 * Better to confirm nslookup response matches */ 317 * Better to confirm nslookup response matches */
318 host_or_die(optarg); 318 host_or_die(optarg);
319 if (strlen (optarg) >= ADDRESS_LENGTH) 319 if (strlen (optarg) >= ADDRESS_LENGTH)
320 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 320 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
321 strcpy (dns_server, optarg); 321 strcpy (dns_server, optarg);
322 break; 322 break;
323 case 'r': /* reverse server name */ 323 case 'r': /* reverse server name */
324 /* TODO: Is this host_or_die necessary? */ 324 /* TODO: Is this host_or_die necessary? */
325 host_or_die(optarg); 325 host_or_die(optarg);
326 if (strlen (optarg) >= ADDRESS_LENGTH) 326 if (strlen (optarg) >= ADDRESS_LENGTH)
327 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 327 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
328 strcpy (ptr_server, optarg); 328 strcpy (ptr_server, optarg);
329 break; 329 break;
330 case 'a': /* expected address */ 330 case 'a': /* expected address */
331 if (strlen (optarg) >= ADDRESS_LENGTH) 331 if (strlen (optarg) >= ADDRESS_LENGTH)
332 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 332 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
333 strcpy (expected_address, optarg); 333 strcpy (expected_address, optarg);
334 match_expected_address = TRUE; 334 match_expected_address = TRUE;
335 break; 335 break;
336 case 'A': /* expect authority */ 336 case 'A': /* expect authority */
337 expect_authority = TRUE; 337 expect_authority = TRUE;
338 break; 338 break;
339 default: /* args not parsable */ 339 default: /* args not parsable */
340 usage_va(_("Unknown argument - %s"), optarg); 340 usage_va(_("Unknown argument - %s"), optarg);
341 } 341 }
342 } 342 }
343 343
344 c = optind; 344 c = optind;
345 if (strlen(query_address)==0 && c<argc) { 345 if (strlen(query_address)==0 && c<argc) {
346 if (strlen(argv[c])>=ADDRESS_LENGTH) 346 if (strlen(argv[c])>=ADDRESS_LENGTH)
347 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 347 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
348 strcpy (query_address, argv[c++]); 348 strcpy (query_address, argv[c++]);
349 } 349 }
350 350
351 if (strlen(dns_server)==0 && c<argc) { 351 if (strlen(dns_server)==0 && c<argc) {
352 /* TODO: See -s option */ 352 /* TODO: See -s option */
353 host_or_die(argv[c]); 353 host_or_die(argv[c]);
354 if (strlen(argv[c]) >= ADDRESS_LENGTH) 354 if (strlen(argv[c]) >= ADDRESS_LENGTH)
355 die (STATE_UNKNOWN, _("Input buffer overflow\n")); 355 die (STATE_UNKNOWN, _("Input buffer overflow\n"));
356 strcpy (dns_server, argv[c++]); 356 strcpy (dns_server, argv[c++]);
357 } 357 }
358 358
359 return validate_arguments (); 359 return validate_arguments ();
360} 360}
361 361
362 362
363int 363int
364validate_arguments () 364validate_arguments ()
365{ 365{
366 if (query_address[0] == 0) 366 if (query_address[0] == 0)
367 return ERROR; 367 return ERROR;
368 368
369 return OK; 369 return OK;
370} 370}
371 371
372 372
373void 373void
374print_help (void) 374print_help (void)
375{ 375{
376 print_revision (progname, revision); 376 print_revision (progname, revision);
377 377
378 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n"); 378 printf ("Copyright (c) 1999 Ethan Galstad <nagios@nagios.org>\n");
379 printf (COPYRIGHT, copyright, email); 379 printf (COPYRIGHT, copyright, email);
380 380
381 printf (_("\ 381 printf (_("This plugin uses the nslookup program to obtain the IP address for the given host/domain query."));
382This plugin uses the nslookup program to obtain the IP address\n\ 382
383for the given host/domain query. A optional DNS server to use may\n\ 383 printf ("\n");
384be specified. If no DNS server is specified, the default server(s)\n\ 384
385specified in /etc/resolv.conf will be used.\n\n")); 385 printf (_("An optional DNS server to use may be specified."));
386
387 printf ("\n");
386 388
387 print_usage (); 389 printf (_("If no DNS server is specified, the default server(s)specified in /etc/resolv.conf will be used."));
388 390
389 printf (_(UT_HELP_VRSN)); 391 printf ("\n\n");
390 392
391 printf (_("\ 393 print_usage ();
392-H, --hostname=HOST\n\
393 The name or address you want to query\n\
394-s, --server=HOST\n\
395 Optional DNS server you want to use for the lookup\n\
396-a, --expected-address=IP-ADDRESS\n\
397 Optional IP address you expect the DNS server to return\n\
398-A, --expect-authority\n\
399 Optionally expect the DNS server to be authoritative for the lookup\n"));
400 394
401 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT); 395 printf (_(UT_HELP_VRSN));
402 396
403 printf (_(UT_SUPPORT)); 397 printf (" -H, --hostname=HOST");
398
399 printf ("\n");
400
401 printf (_("the name or address you want to query"));
402
403 printf ("\n");
404
405 printf (" -s, --server=HOST");
406
407 printf ("\n");
408
409 printf (_("optional DNS server you want to use for the lookup"));
410
411 printf ("\n");
412
413 printf (" -a, --expected-address=IP-ADDRESS");
414
415 printf ("\n");
416
417 printf (_("optional IP address you expect the DNS server to return"));
418
419 printf ("\n");
420
421 printf (" -A, --expect-authority");
422
423 printf ("\n");
424
425 printf (_("optionally expect the DNS server to be authoritative for the lookup"));
426
427 printf ("\n");
428
429 printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
430
431 printf (_(UT_SUPPORT));
404} 432}
405 433
406 434
407void 435void
408print_usage (void) 436print_usage (void)
409{ 437{
410 printf ("\ 438 printf (_("Usage:"));
411Usage: %s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n", progname); 439
440 printf ("%s -H host [-s server] [-a expected-address] [-A] [-t timeout]\n", progname);
412} 441}