[Nagiosplug-checkins] CVS: nagiosplug/plugins check_users.c,1.1.1.1,1.2 check_ups.c,1.2,1.3

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat Nov 9 03:38:02 CET 2002


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

Modified Files:
	check_users.c check_ups.c 
Log Message:
remove call_getopt

Index: check_users.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_users.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_users.c	28 Feb 2002 06:42:59 -0000	1.1.1.1
--- check_users.c	9 Nov 2002 11:37:14 -0000	1.2
***************
*** 50,58 ****
  
  #define PROGNAME "check_users"
  
  #define possibly_set(a,b) ((a) == 0 ? (b) : 0)
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  void print_usage (void);
  void print_help (void);
--- 50,61 ----
  
  #define PROGNAME "check_users"
+ #define REVISION "$Revision$"
+ #define COPYRIGHT "1999-2002"
+ #define AUTHOR "Ethan Galstad"
+ #define EMAIL "nagios at nagios.org"
  
  #define possibly_set(a,b) ((a) == 0 ? (b) : 0)
  
  int process_arguments (int, char **);
  void print_usage (void);
  void print_help (void);
***************
*** 134,171 ****
  	int c;
  
- 	if (argc < 2)
- 		usage ("\n");
- 
- 	c = 0;
- 	while ((c += call_getopt (argc - c, &argv[c])) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (wusers == -1 && argc > c) {
- 			if (is_intnonneg (argv[c]) == FALSE)
- 				usage ("Warning threshold must be a nonnegative integer\n");
- 			wusers = atoi (argv[c]);
- 
- 		}
- 		else if (cusers == -1 && argc > c) {
- 			if (is_intnonneg (argv[c]) == FALSE)
- 				usage ("Warning threshold must be a nonnegative integer\n");
- 			cusers = atoi (argv[c]);
- 		}
- 	}
- 
- 	return OK;
- }
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
--- 137,140 ----
***************
*** 179,182 ****
--- 148,154 ----
  #endif
  
+ 	if (argc < 2)
+ 		usage ("\n");
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
***************
*** 186,203 ****
  #endif
  
- 		i++;
- 
  		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'c':
- 		case 'w':
- 			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);
--- 158,167 ----
  #endif
  
  		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
  		case '?':									/* print short usage statement if args not parsable */
! 			printf ("%s: Unknown argument: %s\n\n", PROGNAME, optarg);
  			print_usage ();
  			exit (STATE_UNKNOWN);
***************
*** 206,210 ****
  			exit (STATE_OK);
  		case 'V':									/* version */
! 			print_revision (my_basename (argv[0]), "$Revision$");
  			exit (STATE_OK);
  		case 'c':									/* critical */
--- 170,174 ----
  			exit (STATE_OK);
  		case 'V':									/* version */
! 			print_revision (PROGNAME, REVISION);
  			exit (STATE_OK);
  		case 'c':									/* critical */
***************
*** 220,224 ****
  		}
  	}
! 	return i;
  }
  
--- 184,202 ----
  		}
  	}
! 
! 	c = optind;
! 	if (wusers == -1 && argc > c) {
! 		if (is_intnonneg (argv[c]) == FALSE)
! 			usage ("Warning threshold must be a nonnegative integer\n");
! 		wusers = atoi (argv[c++]);
! 	}
! 
! 	if (cusers == -1 && argc > c) {
! 		if (is_intnonneg (argv[c]) == FALSE)
! 			usage ("Warning threshold must be a nonnegative integer\n");
! 		cusers = atoi (argv[c]);
! 	}
! 
! 	return OK;
  }
  
***************
*** 240,246 ****
  print_help (void)
  {
! 	print_revision (PROGNAME, "$Revision$");
  	printf
! 		("Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)\n\n"
  		 "This plugin checks the number of users currently logged in on the local\n"
  		 "system and generates an error if the number exceeds the thresholds specified.\n");
--- 218,224 ----
  print_help (void)
  {
! 	print_revision (PROGNAME, REVISION);
  	printf
! 		("Copyright (c) " COPYRIGHT " " AUTHOR "(" EMAIL ")\n\n"
  		 "This plugin checks the number of users currently logged in on the local\n"
  		 "system and generates an error if the number exceeds the thresholds specified.\n");

Index: check_ups.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ups.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** check_ups.c	8 May 2002 05:07:22 -0000	1.2
--- check_ups.c	9 Nov 2002 11:37:14 -0000	1.3
***************
*** 58,61 ****
--- 58,65 ----
  
  #define PROGNAME "check_ups"
+ #define REVISION "$Revision$"
+ #define COPYRIGHT "1999-2002"
+ #define AUTHOR "Ethan Galstad"
+ #define EMAIL "nagios at nagios.org"
  
  #define CHECK_NONE	0
***************
*** 434,481 ****
  	int c;
  
- 	if (argc < 2)
- 		return ERROR;
- 
- 	for (c = 1; c < argc; c++) {
- 		if (strcmp ("-to", argv[c]) == 0)
- 			strcpy (argv[c], "-t");
- 		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 (is_host (argv[c])) {
- 				server_address = argv[c];
- 			}
- 			else {
- 				usage ("Invalid host name");
- 			}
- 		}
- 	}
- 
- 	if (server_address == NULL)
- 		server_address = 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;
--- 438,441 ----
***************
*** 494,525 ****
  #endif
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+hVH:u:p:v:c:w:t:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "+?hVH:u:p:v:c:w:t:");
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'H':
- 		case 'u':
- 		case 'p':
- 		case 'v':
- 		case 'c':
- 		case 'w':
- 		case 't':
- 			i++;
- 		}
- 
- 		switch (c) {
  		case '?':									/* help */
! 			usage ("Invalid argument\n");
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
--- 454,484 ----
  #endif
  
+ 	if (argc < 2)
+ 		return ERROR;
+ 
+ 	for (c = 1; c < argc; c++) {
+ 		if (strcmp ("-to", argv[c]) == 0)
+ 			strcpy (argv[c], "-t");
+ 		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:u:p:v:c:w:t:", long_options,
  									 &option_index);
  #else
! 		c = getopt (argc, argv, "hVH:u:p:v:c:w:t:");
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
  		case '?':									/* help */
! 			usage3 ("Unknown option", optopt);
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
***************
*** 527,531 ****
  			}
  			else {
! 				usage ("Invalid host name\n");
  			}
  			break;
--- 486,490 ----
  			}
  			else {
! 				usage2 ("Invalid host name", optarg);
  			}
  			break;
***************
*** 538,542 ****
  			}
  			else {
! 				usage ("Server port must be a positive integer\n");
  			}
  			break;
--- 497,501 ----
  			}
  			else {
! 				usage2 ("Server port must be a positive integer", optarg);
  			}
  			break;
***************
*** 547,551 ****
  			}
  			else {
! 				usage ("Critical time must be a nonnegative integer\n");
  			}
  			break;
--- 506,510 ----
  			}
  			else {
! 				usage2 ("Critical time must be a nonnegative integer", optarg);
  			}
  			break;
***************
*** 556,560 ****
  			}
  			else {
! 				usage ("Warning time must be a nonnegative integer\n");
  			}
  			break;
--- 515,519 ----
  			}
  			else {
! 				usage2 ("Warning time must be a nonnegative integer", optarg);
  			}
  			break;
***************
*** 569,573 ****
  				check_variable = UPS_LOADPCT;
  			else
! 				usage ("Unrecognized UPS variable\n");
  			break;
  		case 't':									/* timeout */
--- 528,532 ----
  				check_variable = UPS_LOADPCT;
  			else
! 				usage2 ("Unrecognized UPS variable", optarg);
  			break;
  		case 't':									/* timeout */
***************
*** 587,591 ****
  		}
  	}
! 	return i;
  }
  
--- 546,563 ----
  		}
  	}
! 
! 
! 	if (server_address == NULL) {
! 		if (optind >= argc) {
! 			server_address = strscpy (NULL, "127.0.0.1");
! 		}
! 		else if (is_host (argv[optind])) {
! 			server_address = argv[optind++];
! 		}
! 		else {
! 			usage ("Invalid host name");
! 		}
! 	}
! 	return validate_arguments();
  }
  





More information about the Commits mailing list