summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2003-03-12 00:45:01 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2003-03-12 00:45:01 (GMT)
commit6f621a1118b854070fc34896230b09be66279cb1 (patch)
tree056609ad2665164ca54c41f83ddd2e7123d179d6 /plugins
parent2eca952f2666244c4dd2c60735e6721134d0de14 (diff)
downloadmonitoring-plugins-6f621a1118b854070fc34896230b09be66279cb1.tar.gz
Removed is_host checks to speed up code. Fixed timings so no spaces
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@401 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dns.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index fd798a6..2503293 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -154,6 +154,7 @@ main (int argc, char **argv)
154 result = error_scan (input_buffer); 154 result = error_scan (input_buffer);
155 if (result != STATE_OK) { 155 if (result != STATE_OK) {
156 output = strscpy (output, 1 + index (input_buffer, ':')); 156 output = strscpy (output, 1 + index (input_buffer, ':'));
157 strip (output);
157 break; 158 break;
158 } 159 }
159 160
@@ -164,6 +165,7 @@ main (int argc, char **argv)
164 if (error_scan (input_buffer) != STATE_OK) { 165 if (error_scan (input_buffer) != STATE_OK) {
165 result = max_state (result, error_scan (input_buffer)); 166 result = max_state (result, error_scan (input_buffer));
166 output = strscpy (output, 1 + index (input_buffer, ':')); 167 output = strscpy (output, 1 + index (input_buffer, ':'));
168 strip (output);
167 } 169 }
168 } 170 }
169 171
@@ -191,7 +193,7 @@ main (int argc, char **argv)
191 else 193 else
192 multi_address = TRUE; 194 multi_address = TRUE;
193 195
194 printf ("DNS ok - %-7.3f seconds response time, address%s %s|time=%-7.3f\n", 196 printf ("DNS ok - %-5.3f seconds response time, address%s %s|time=%-5.3f\n",
195 elapsed_time, (multi_address==TRUE ? "es are" : " is"), address, elapsed_time); 197 elapsed_time, (multi_address==TRUE ? "es are" : " is"), address, elapsed_time);
196 } 198 }
197 else if (result == STATE_WARNING) 199 else if (result == STATE_WARNING)
@@ -315,16 +317,13 @@ process_arguments (int argc, char **argv)
315 timeout_interval = atoi (optarg); 317 timeout_interval = atoi (optarg);
316 break; 318 break;
317 case 'H': /* hostname */ 319 case 'H': /* hostname */
318 if (is_host (optarg) == FALSE) {
319 printf ("Invalid host name/address\n\n");
320 print_usage ();
321 exit (STATE_UNKNOWN);
322 }
323 if (strlen (optarg) >= ADDRESS_LENGTH) 320 if (strlen (optarg) >= ADDRESS_LENGTH)
324 terminate (STATE_UNKNOWN, "Input buffer overflow\n"); 321 terminate (STATE_UNKNOWN, "Input buffer overflow\n");
325 strcpy (query_address, optarg); 322 strcpy (query_address, optarg);
326 break; 323 break;
327 case 's': /* server name */ 324 case 's': /* server name */
325 /* TODO: this is_host check is probably unnecessary. Better to confirm nslookup
326 response matches */
328 if (is_host (optarg) == FALSE) { 327 if (is_host (optarg) == FALSE) {
329 printf ("Invalid server name/address\n\n"); 328 printf ("Invalid server name/address\n\n");
330 print_usage (); 329 print_usage ();
@@ -335,6 +334,7 @@ process_arguments (int argc, char **argv)
335 strcpy (dns_server, optarg); 334 strcpy (dns_server, optarg);
336 break; 335 break;
337 case 'r': /* reverse server name */ 336 case 'r': /* reverse server name */
337 /* TODO: Is this is_host necessary? */
338 if (is_host (optarg) == FALSE) { 338 if (is_host (optarg) == FALSE) {
339 printf ("Invalid host name/address\n\n"); 339 printf ("Invalid host name/address\n\n");
340 print_usage (); 340 print_usage ();
@@ -345,11 +345,6 @@ process_arguments (int argc, char **argv)
345 strcpy (ptr_server, optarg); 345 strcpy (ptr_server, optarg);
346 break; 346 break;
347 case 'a': /* expected address */ 347 case 'a': /* expected address */
348 if (is_addr (optarg) == FALSE) {
349 printf ("Invalid expected address\n\n");
350 print_usage ();
351 exit (STATE_UNKNOWN);
352 }
353 if (strlen (optarg) >= ADDRESS_LENGTH) 348 if (strlen (optarg) >= ADDRESS_LENGTH)
354 terminate (STATE_UNKNOWN, "Input buffer overflow\n"); 349 terminate (STATE_UNKNOWN, "Input buffer overflow\n");
355 strcpy (expected_address, optarg); 350 strcpy (expected_address, optarg);
@@ -360,16 +355,13 @@ process_arguments (int argc, char **argv)
360 355
361 c = optind; 356 c = optind;
362 if (strlen(query_address)==0 && c<argc) { 357 if (strlen(query_address)==0 && c<argc) {
363 if (is_host(argv[c])==FALSE) {
364 printf ("Invalid name/address: %s\n\n", argv[c]);
365 return ERROR;
366 }
367 if (strlen(argv[c])>=ADDRESS_LENGTH) 358 if (strlen(argv[c])>=ADDRESS_LENGTH)
368 terminate (STATE_UNKNOWN, "Input buffer overflow\n"); 359 terminate (STATE_UNKNOWN, "Input buffer overflow\n");
369 strcpy (query_address, argv[c++]); 360 strcpy (query_address, argv[c++]);
370 } 361 }
371 362
372 if (strlen(dns_server)==0 && c<argc) { 363 if (strlen(dns_server)==0 && c<argc) {
364 /* TODO: See -s option */
373 if (is_host(argv[c]) == FALSE) { 365 if (is_host(argv[c]) == FALSE) {
374 printf ("Invalid name/address: %s\n\n", argv[c]); 366 printf ("Invalid name/address: %s\n\n", argv[c]);
375 return ERROR; 367 return ERROR;