[Nagiosplug-checkins] CVS: nagiosplug/plugins check_dns.c,1.2,1.3

Subhendu Ghosh sghosh at users.sourceforge.net
Mon Oct 7 12:06:05 CEST 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv12500

Modified Files:
	check_dns.c 
Log Message:
patch for expected IP address

Index: check_dns.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dns.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_dns.c	19 Jun 2002 05:11:52 -0000	1.2
--- check_dns.c	7 Oct 2002 19:05:24 -0000	1.3
***************
*** 11,16 ****
   * Notes:
   *  - Safe popen added by Karl DeBisschop 9-11-99
   *
!  * Command line: CHECK_DNS <query_address> [dns_server]
   *
   * Description:
--- 11,17 ----
   * Notes:
   *  - Safe popen added by Karl DeBisschop 9-11-99
+  *  - expected-address parameter added by Alex Chaffee - 7 Oct 2002
   *
!  * Command line: (see print_usage)
   *
   * Description:
***************
*** 60,63 ****
--- 61,66 ----
  char ptr_server[ADDRESS_LENGTH] = "";
  int verbose = FALSE;
+ char expected_address[ADDRESS_LENGTH] = "";
+ int match_expected_address = FALSE;
  
  int
***************
*** 166,169 ****
--- 169,178 ----
  	}
  
+ 	/* compare to expected address */
+ 	if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
+ 	        result = STATE_CRITICAL;
+ 	        output = ssprintf(output, "expected %s but got %s", expected_address, address);
+ 		}
+ 	
  	(void) time (&end_time);
  
***************
*** 298,301 ****
--- 307,311 ----
  		{"server", required_argument, 0, 's'},
  		{"reverse-server", required_argument, 0, 'r'},
+ 		{"expected-address", required_argument, 0, 'a'},
  		{0, 0, 0, 0}
  	};
***************
*** 305,311 ****
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c = getopt_long (argc, argv, "+?hVvt:H:s:r:", long_opts, &opt_index);
  #else
! 		c = getopt (argc, argv, "+?hVvt:H:s:r:");
  #endif
  
--- 315,321 ----
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c = getopt_long (argc, argv, "+?hVvt:H:s:r:a:", long_opts, &opt_index);
  #else
! 		c = getopt (argc, argv, "+?hVvt:H:s:r:a:");
  #endif
  
***************
*** 319,322 ****
--- 329,333 ----
  		case 's':
  		case 'r':
+ 		case 'a':
  			i++;
  		}
***************
*** 369,372 ****
--- 380,394 ----
  			strcpy (ptr_server, optarg);
  			break;
+ 		case 'a': /* expected address */
+ 			if (is_dotted_quad (optarg) == FALSE) {
+ 				printf ("Invalid expected address\n\n");
+ 				print_usage (my_basename (argv[0]));
+ 				exit (STATE_UNKNOWN);
+ 			}
+ 			if (strlen (optarg) >= ADDRESS_LENGTH)
+ 				terminate (STATE_UNKNOWN, "Input buffer overflow\n");
+ 			strcpy (expected_address, optarg);
+ 			match_expected_address = TRUE;
+ 			break;
  		}
  	}
***************
*** 386,390 ****
  print_usage (char *cmd)
  {
! 	printf ("Usage: %s -H host [-s server] [-t timeout]\n" "       %s --help\n"
  					"       %s --version\n", cmd, cmd, cmd);
  }
--- 408,412 ----
  print_usage (char *cmd)
  {
! 	printf ("Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n" "       %s --help\n"
  					"       %s --version\n", cmd, cmd, cmd);
  }
***************
*** 402,405 ****
--- 424,429 ----
  		 "-s, --server=HOST\n"
  		 "   Optional DNS server you want to use for the lookup\n"
+ 		 "-a, --expected-address=IP-ADDRESS\n"
+ 		 "   Optional IP address you expect the DNS server to return\n"
  		 "-t, --timeout=INTEGER\n"
  		 "   Seconds before connection times out (default: %d)\n"





More information about the Commits mailing list