[Nagiosplug-checkins] CVS: nagiosplug/plugins check_by_ssh.c,1.4,1.5 check_dig.c,1.2,1.3 check_ping.c,1.8,1.9 check_time.c,1.1.1.1,1.2

Karl DeBisschop kdebisschop at users.sourceforge.net
Fri Nov 8 20:23:02 CET 2002


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

Modified Files:
	check_by_ssh.c check_dig.c check_ping.c check_time.c 
Log Message:
remove call_getopt

Index: check_by_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_by_ssh.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** check_by_ssh.c	7 Nov 2002 07:07:17 -0000	1.4
--- check_by_ssh.c	9 Nov 2002 04:22:22 -0000	1.5
***************
*** 38,42 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  void print_help (char *command_name);
--- 38,41 ----

Index: check_dig.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_dig.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_dig.c	19 Jun 2002 05:11:52 -0000	1.2
--- check_dig.c	9 Nov 2002 04:22:22 -0000	1.3
***************
*** 1,13 ****
  /******************************************************************************
! *
! * check_dig.c
! *
! * Program: dig plugin for Nagios
! * License: GPL
! * Copyright (c) 2000
! *
! * $Id$
! *
! *****************************************************************************/
  
  #include "config.h"
--- 1,23 ----
  /******************************************************************************
!  *
!  * Program: SNMP plugin for Nagios
!  * License: GPL
!  *
!  * License Information:
!  *
!  * This program is free software; you can redistribute it and/or modify
!  * it under the terms of the GNU General Public License as published by
!  * the Free Software Foundation; either version 2 of the License, or
!  * (at your option) any later version.
!  *
!  * This program is distributed in the hope that it will be useful,
!  * but WITHOUT ANY WARRANTY; without even the implied warranty of
!  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!  * GNU General Public License for more details.
!  *
!  * You should have received a copy of the GNU General Public License
!  * along with this program; if not, write to the Free Software
!  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
!  *****************************************************************************/
  
  #include "config.h"
***************
*** 17,20 ****
--- 27,35 ----
  
  #define PROGNAME "check_dig"
+ #define REVISION "$Revision$"
+ #define COPYRIGHT "2000-2002"
+ #define AUTHOR "Karl DeBisschop"
+ #define EMAIL "karl at debisschop.net"
+ #define SUMMARY "Test the DNS service on the specified host using dig\n"
  
  int process_arguments (int, char **);
***************
*** 141,180 ****
  	int c;
  
- 	if (argc < 2)
- 		return ERROR;
- 
- 
- 	c = 0;
- 	while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (dns_server == NULL) {
- 			if (is_host (argv[c])) {
- 				dns_server = argv[c];
- 			}
- 			else {
- 				usage ("Invalid host name");
- 			}
- 		}
- 	}
- 
- 	if (dns_server == NULL)
- 		dns_server = strscpy (NULL, "127.0.0.1");
- 
- 	return validate_arguments ();
- }
- 
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
--- 156,159 ----
***************
*** 189,212 ****
  #endif
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c = getopt_long (argc, argv, "+hVvt:l:H:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "+?hVvt:l:H:");
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
! 		case 't':
! 		case 'l':
! 		case 'H':
! 			i++;
! 		}
! 
! 		switch (c) {
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
--- 168,187 ----
  #endif
  
+ 	if (argc < 2)
+ 		return ERROR;
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
! 		c = getopt_long (argc, argv, "hVvt:l:H:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "hVvt:l:H:");
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
! 		case '?':									/* help */
! 			usage3 ("Unknown argument", optopt);
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
***************
*** 237,245 ****
  			print_help ();
  			exit (STATE_OK);
- 		case '?':									/* help */
- 			usage ("Invalid argument\n");
  		}
  	}
! 	return i;
  }
  
--- 212,234 ----
  			print_help ();
  			exit (STATE_OK);
  		}
  	}
! 
! 	c = optind;
! 	if (dns_server == NULL) {
! 		if (c < argc) {
! 			if (is_host (argv[c])) {
! 				dns_server = argv[c];
! 			}
! 			else {
! 				usage ("Invalid host name");
! 			}
! 		}
! 		else {
! 			dns_server = strscpy (NULL, "127.0.0.1");
! 		}
! 	}
! 
! 	return validate_arguments ();
  }
  
***************
*** 263,268 ****
  	print_revision (PROGNAME, "$Revision$");
  	printf
! 		("Copyright (c) 2000 Karl DeBisschop\n\n"
! 		 "This plugin use dig to test the DNS service on the specified host.\n\n");
  	print_usage ();
  	printf
--- 252,257 ----
  	print_revision (PROGNAME, "$Revision$");
  	printf
! 		("Copyright (c) %s %s <%s>\n\n%s\n",
! 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
  	print_usage ();
  	printf

Index: check_ping.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ping.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_ping.c	9 Nov 2002 03:39:35 -0000	1.8
--- check_ping.c	9 Nov 2002 04:22:22 -0000	1.9
***************
*** 57,61 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int get_threshold (char *, float *, int *);
  int validate_arguments (void);
--- 57,60 ----

Index: check_time.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_time.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_time.c	28 Feb 2002 06:42:59 -0000	1.1.1.1
--- check_time.c	9 Nov 2002 04:22:22 -0000	1.2
***************
*** 41,44 ****
--- 41,49 ----
  
  #define PROGNAME "check_time"
+ #define REVISION "$Revision$"
+ #define COPYRIGHT "1999-2002"
+ #define AUTHOR "Ethan Galstad"
+ #define EMAIL "nagios at nagios.org"
+ #define SUMMARY "Check time on the specified host.\n"
  
  #define TIME_PORT	37
***************
*** 60,64 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  void print_usage (void);
  void print_help (void);
--- 65,68 ----
***************
*** 94,98 ****
  	}
  
! 	/* watch for the FTP connection string */
  	result = recv (sd, &raw_server_time, sizeof (raw_server_time), 0);
  
--- 98,102 ----
  	}
  
! 	/* watch for the connection string */
  	result = recv (sd, &raw_server_time, sizeof (raw_server_time), 0);
  
***************
*** 155,204 ****
  	int c;
  
- 	if (argc < 2)
- 		usage ("\n");
- 
- 	for (c = 1; c < argc; c++) {
- 		if (strcmp ("-to", argv[c]) == 0)
- 			strcpy (argv[c], "-t");
- 		else if (strcmp ("-wd", argv[c]) == 0)
- 			strcpy (argv[c], "-w");
- 		else if (strcmp ("-cd", argv[c]) == 0)
- 			strcpy (argv[c], "-c");
- 		else if (strcmp ("-wt", argv[c]) == 0)
- 			strcpy (argv[c], "-W");
- 		else if (strcmp ("-ct", argv[c]) == 0)
- 			strcpy (argv[c], "-C");
- 	}
- 
- 	c = 0;
- 	while ((c += call_getopt (argc - c, &argv[c])) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (server_address == NULL) {
- 			if (argc > c) {
- 				if (is_host (argv[c]) == FALSE)
- 					usage ("Invalid host name/address\n");
- 				server_address = argv[c];
- 			}
- 			else {
- 				usage ("Host name was not supplied\n");
- 			}
- 		}
- 	}
- 
- 	return OK;
- }
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
--- 159,162 ----
***************
*** 217,255 ****
  #endif
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+hVH:w:c:W:C:p:t:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "+hVH:w:c:W:C:p:t:");
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'H':
- 		case 'w':
- 		case 'c':
- 		case 'W':
- 		case 'C':
- 		case 'p':
- 		case 't':
- 			i++;
- 		}
- 
- 		switch (c) {
  		case '?':									/* print short usage statement if args not parsable */
! 			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
! 			print_usage ();
! 			exit (STATE_UNKNOWN);
  		case 'h':									/* help */
  			print_help ();
  			exit (STATE_OK);
  		case 'V':									/* version */
! 			print_revision (my_basename (argv[0]), "$Revision$");
  			exit (STATE_OK);
  		case 'H':									/* hostname */
--- 175,214 ----
  #endif
  
+ 	if (argc < 2)
+ 		usage ("\n");
+ 
+ 	for (c = 1; c < argc; c++) {
+ 		if (strcmp ("-to", argv[c]) == 0)
+ 			strcpy (argv[c], "-t");
+ 		else if (strcmp ("-wd", argv[c]) == 0)
+ 			strcpy (argv[c], "-w");
+ 		else if (strcmp ("-cd", argv[c]) == 0)
+ 			strcpy (argv[c], "-c");
+ 		else if (strcmp ("-wt", argv[c]) == 0)
+ 			strcpy (argv[c], "-W");
+ 		else if (strcmp ("-ct", argv[c]) == 0)
+ 			strcpy (argv[c], "-C");
+ 	}
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "hVH:w:c:W:C:p:t:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "hVH:w:c:W:C:p:t:");
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
  		case '?':									/* print short usage statement if args not parsable */
! 			usage3 ("Unknown argument", optopt);
  		case 'h':									/* help */
  			print_help ();
  			exit (STATE_OK);
  		case 'V':									/* version */
! 			print_revision (PROGNAME, REVISION);
  			exit (STATE_OK);
  		case 'H':									/* hostname */
***************
*** 319,323 ****
  		}
  	}
! 	return i;
  }
  
--- 278,295 ----
  		}
  	}
! 
! 	c = optind;
! 	if (server_address == NULL) {
! 		if (argc > c) {
! 			if (is_host (argv[c]) == FALSE)
! 				usage ("Invalid host name/address\n");
! 			server_address = argv[c];
! 		}
! 		else {
! 			usage ("Host name was not supplied\n");
! 		}
! 	}
! 
! 	return OK;
  }
  
***************
*** 330,335 ****
  {
  	printf
! 		("Usage: check_time -H <host_address> [-p port] [-w variance] [-c variance]\n"
! 		 "                 [-W connect_time] [-C connect_time] [-t timeout]\n");
  }
  
--- 302,311 ----
  {
  	printf
! 		("Usage:\n"
! 		 " %s -H <host_address> [-p port] [-w variance] [-c variance]\n"
! 		 "           [-W connect_time] [-C connect_time] [-t timeout]\n"
! 		 " %s (-h | --help) for detailed help\n"
! 		 " %s (-V | --version) for version information\n",
! 		 PROGNAME, PROGNAME, PROGNAME);
  }
  
***************
*** 341,348 ****
  print_help (void)
  {
! 	print_revision (PROGNAME, "$Revision$");
  	printf
! 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
! 		 "This plugin connects to a time port on the specified host.\n\n");
  	print_usage ();
  	printf
--- 317,324 ----
  print_help (void)
  {
! 	print_revision (PROGNAME, REVISION);
  	printf
! 		("Copyright (c) %s %s <%s>\n\n%s\n",
! 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
  	print_usage ();
  	printf





More information about the Commits mailing list