[Nagiosplug-checkins] CVS: nagiosplug/plugins check_smtp.c,1.16,1.17 check_ssh.c,1.10,1.11 check_tcp.c,1.33,1.34 check_time.c,1.7,1.8 check_udp.c,1.9,1.10 check_ups.c,1.8,1.9 check_users.c,1.6,1.7

Karl DeBisschop kdebisschop at users.sourceforge.net
Sat Aug 9 06:38:03 CEST 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv3769

Modified Files:
	check_smtp.c check_ssh.c check_tcp.c check_time.c check_udp.c 
	check_ups.c check_users.c 
Log Message:
more pedantic compiler warnings

Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** check_smtp.c	8 Aug 2003 03:51:02 -0000	1.16
--- check_smtp.c	9 Aug 2003 13:36:49 -0000	1.17
***************
*** 42,47 ****
  char *server_expect = NULL;
  int smtp_use_dummycmd = 1;
! char *mail_command = "MAIL ";
! char *from_arg = " ";
  int warning_time = 0;
  int check_warning_time = FALSE;
--- 42,47 ----
  char *server_expect = NULL;
  int smtp_use_dummycmd = 1;
! char *mail_command;
! char *from_arg;
  int warning_time = 0;
  int check_warning_time = FALSE;
***************
*** 61,65 ****
  	double elapsed_time;
  	int result = STATE_UNKNOWN;
! 	char buffer[MAX_INPUT_BUFFER] = "";
  	char *from_str = NULL;
  	char *helocmd = NULL;
--- 61,65 ----
  	double elapsed_time;
  	int result = STATE_UNKNOWN;
! 	char buffer[MAX_INPUT_BUFFER];
  	char *from_str = NULL;
  	char *helocmd = NULL;
***************
*** 314,318 ****
  
  	if (server_expect == NULL)
! 		asprintf (&server_expect, SMTP_EXPECT);
  
  	return validate_arguments ();
--- 314,324 ----
  
  	if (server_expect == NULL)
! 		server_expect = strdup (SMTP_EXPECT);
! 
! 	if (mail_command == NULL)
! 		mail_command = strdup("MAIL ");
! 
! 	if (from_arg==NULL)
! 		from_arg = strdup(" ");
  
  	return validate_arguments ();

Index: check_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ssh.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** check_ssh.c	5 Aug 2003 11:53:21 -0000	1.10
--- check_ssh.c	9 Aug 2003 13:36:49 -0000	1.11
***************
*** 33,37 ****
  #define BUFF_SZ         256
  
! short port = -1;
  char *server_name = NULL;
  int verbose = FALSE;
--- 33,37 ----
  #define BUFF_SZ         256
  
! int port = -1;
  char *server_name = NULL;
  int verbose = FALSE;
***************
*** 42,46 ****
  void print_usage (void);
  
! int ssh_connect (char *haddr, short hport);
  
  int
--- 42,46 ----
  void print_usage (void);
  
! int ssh_connect (char *haddr, int hport);
  
  int
***************
*** 112,116 ****
  			if (!is_integer (optarg))
  				usage (_("Timeout Interval must be an integer!\n\n"));
! 			socket_timeout = atoi (optarg);
  			break;
  		case '4':
--- 112,117 ----
  			if (!is_integer (optarg))
  				usage (_("Timeout Interval must be an integer!\n\n"));
! 			else
! 				socket_timeout = atoi (optarg);
  			break;
  		case '4':
***************
*** 179,183 ****
  
  int
! ssh_connect (char *haddr, short hport)
  {
  	int sd;
--- 180,184 ----
  
  int
! ssh_connect (char *haddr, int hport)
  {
  	int sd;

Index: check_tcp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_tcp.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -r1.33 -r1.34
*** check_tcp.c	7 Aug 2003 11:51:12 -0000	1.33
--- check_tcp.c	9 Aug 2003 13:36:49 -0000	1.34
***************
*** 1,20 ****
  /*****************************************************************************
! *
! * 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"
  #include "common.h"
  #include "netutils.h"
--- 1,26 ----
  /*****************************************************************************
! 
!  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.
! 
  *****************************************************************************/
! 
! /* progname changes depending on symlink called */
! char *progname = "check_tcp";
! const char *revision = "$Revision$";
! const char *copyright = "1999-2003";
! const char *email = "nagiosplug-devel at lists.sourceforge.net";
! 
  #include "common.h"
  #include "netutils.h"
***************
*** 52,58 ****
  
  int process_arguments (int, char **);
- void print_usage (void);
- void print_help (void);
  int my_recv (void);
  
  char *SERVICE = NULL;
--- 58,64 ----
  
  int process_arguments (int, char **);
  int my_recv (void);
+ void print_help (void);
+ void print_usage (void);
  
  char *SERVICE = NULL;
***************
*** 68,78 ****
  char *server_quit = NULL;
  char **server_expect = NULL;
! int server_expect_count = 0;
  int maxbytes = 0;
  char **warn_codes = NULL;
! int warn_codes_count = 0;
  char **crit_codes = NULL;
! int crit_codes_count = 0;
! int delay = 0;
  double warning_time = 0;
  int check_warning_time = FALSE;
--- 74,84 ----
  char *server_quit = NULL;
  char **server_expect = NULL;
! size_t server_expect_count = 0;
  int maxbytes = 0;
  char **warn_codes = NULL;
! size_t warn_codes_count = 0;
  char **crit_codes = NULL;
! size_t crit_codes_count = 0;
! unsigned int delay = 0;
  double warning_time = 0;
  int check_warning_time = FALSE;
***************
*** 80,153 ****
  int check_critical_time = FALSE;
  double elapsed_time = 0;
  int verbose = FALSE;
  int use_ssl = FALSE;
  int sd = 0;
! char *buffer = "";
! 
! /* progname changes depending on symlink called */
! char *progname = "check_tcp";
! const char *revision = "$Revision$";
! const char *copyright = "1999-2003";
! const char *email = "nagiosplug-devel at lists.sourceforge.net";
! 
  
  
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
-   [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
-   [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
-   [-r <refuse state>] [-v] [-4|-6]\n"), progname);
- 	printf ("       %s (-h|--help)\n", progname);
- 	printf ("       %s (-V|--version)\n", progname);
- }
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
  
- 	printf (_(COPYRIGHT), copyright, email);
  
- 	printf (_("This plugin tests %s connections with the specified host.\n\n"),
- 	        SERVICE);
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', "none");
- 
- 	printf (_(UT_IPv46));
- 
- 	printf (_("\
-  -s, --send=STRING\n\
-     String to send to the server\n\
-  -e, --expect=STRING\n\
-     String to expect in server response\n\
-  -q, --quit=STRING\n\
-     String to send server to initiate a clean close of the connection\n"));
- 
- 	printf (_("\
-  -r, --refuse=ok|warn|crit\n\
-     Accept tcp refusals with states ok, warn, crit (default: crit)\n\
-  -m, --maxbytes=INTEGER\n\
-     Close connection once more than this number of bytes are received\n\
-  -d, --delay=INTEGER\n\
-     Seconds to wait between sending string and polling for response\n"));
- 
- 	printf (_(UT_WARN_CRIT));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_(UT_SUPPORT));
- }
  
- 
- 
  int
  main (int argc, char **argv)
--- 86,100 ----
  int check_critical_time = FALSE;
  double elapsed_time = 0;
+ long microsec;
  int verbose = FALSE;
  int use_ssl = FALSE;
  int sd = 0;
! char *buffer;
  
  
  
  
  
  
  int
  main (int argc, char **argv)
***************
*** 155,159 ****
  	int result;
  	int i;
! 	char *status = "";
  	struct timeval tv;
  
--- 102,106 ----
  	int result;
  	int i;
! 	char *status;
  	struct timeval tv;
  
***************
*** 297,304 ****
  #ifdef HAVE_SSL
  		if (use_ssl)
! 			SSL_write(ssl, server_send, strlen (server_send));
  		else
  #endif
! 			send (sd, server_send, strlen (server_send), 0);
  	}
  
--- 244,251 ----
  #ifdef HAVE_SSL
  		if (use_ssl)
! 			SSL_write(ssl, server_send, (int)strlen(server_send));
  		else
  #endif
! 			send (sd, server_send, strlen(server_send), 0);
  	}
  
***************
*** 312,315 ****
--- 259,263 ----
  		buffer = malloc (MAXBUF);
  		memset (buffer, '\0', MAXBUF);
+ 		status = strdup ("");
  		/* watch for the expect string */
  		while ((i = my_recv ()) > 0) {
***************
*** 334,339 ****
  			for (i = 0;; i++) {
  				if (verbose)
! 					printf ("%d %d\n", i, server_expect_count);
! 				if (i >= server_expect_count)
  					die (STATE_WARNING, _("Invalid response from host\n"));
  				if (strstr (status, server_expect[i]))
--- 282,287 ----
  			for (i = 0;; i++) {
  				if (verbose)
! 					printf ("%d %d\n", i, (int)server_expect_count);
! 				if (i >= (int)server_expect_count)
  					die (STATE_WARNING, _("Invalid response from host\n"));
  				if (strstr (status, server_expect[i]))
***************
*** 346,350 ****
  #ifdef HAVE_SSL
  		if (use_ssl) {
! 			SSL_write (ssl, server_quit, strlen (server_quit));
  			SSL_shutdown (ssl);
   			SSL_free (ssl);
--- 294,298 ----
  #ifdef HAVE_SSL
  		if (use_ssl) {
! 			SSL_write (ssl, server_quit, (int)strlen(server_quit));
  			SSL_shutdown (ssl);
   			SSL_free (ssl);
***************
*** 363,367 ****
  		close (sd);
  
! 	elapsed_time = delta_time (tv);
  
  	if (check_critical_time == TRUE && elapsed_time > critical_time)
--- 311,316 ----
  		close (sd);
  
! 	microsec = deltime (tv);
! 	elapsed_time = (double)microsec / 1.0e6;
  
  	if (check_critical_time == TRUE && elapsed_time > critical_time)
***************
*** 383,387 ****
  		printf (" [%s]", status);
  
! 	printf ("|time=%.3f\n", elapsed_time);
  
  	return result;
--- 332,336 ----
  		printf (" [%s]", status);
  
! 	printf ("|time=%ldus\n", microsec);
  
  	return result;
***************
*** 480,484 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			critical_time = strtod (optarg, NULL);
  			check_critical_time = TRUE;
  			break;
--- 429,434 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			else
! 				critical_time = strtod (optarg, NULL);
  			check_critical_time = TRUE;
  			break;
***************
*** 486,490 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			warning_time = strtod (optarg, NULL);
  			check_warning_time = TRUE;
  			break;
--- 436,441 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			else
! 				warning_time = strtod (optarg, NULL);
  			check_warning_time = TRUE;
  			break;
***************
*** 500,509 ****
  			if (!is_intpos (optarg))
  				usage (_("Timeout interval must be a positive integer\n"));
! 			socket_timeout = atoi (optarg);
  			break;
  		case 'p':                 /* port */
  			if (!is_intpos (optarg))
  				usage (_("Server port must be a positive integer\n"));
! 			server_port = atoi (optarg);
  			break;
  		case 's':
--- 451,462 ----
  			if (!is_intpos (optarg))
  				usage (_("Timeout interval must be a positive integer\n"));
! 			else
! 				socket_timeout = atoi (optarg);
  			break;
  		case 'p':                 /* port */
  			if (!is_intpos (optarg))
  				usage (_("Server port must be a positive integer\n"));
! 			else
! 				server_port = atoi (optarg);
  			break;
  		case 's':
***************
*** 521,525 ****
  			if (!is_intpos (optarg))
  				usage (_("Maxbytes must be a positive integer\n"));
! 			maxbytes = atoi (optarg);
  		case 'q':
  			server_quit = optarg;
--- 474,479 ----
  			if (!is_intpos (optarg))
  				usage (_("Maxbytes must be a positive integer\n"));
! 			else
! 				maxbytes = atoi (optarg);
  		case 'q':
  			server_quit = optarg;
***************
*** 627,629 ****
--- 581,646 ----
  
  	return i;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This plugin tests %s connections with the specified host.\n\n"),
+ 	        SERVICE);
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', "none");
+ 
+ 	printf (_(UT_IPv46));
+ 
+ 	printf (_("\
+  -s, --send=STRING\n\
+     String to send to the server\n\
+  -e, --expect=STRING\n\
+     String to expect in server response\n\
+  -q, --quit=STRING\n\
+     String to send server to initiate a clean close of the connection\n"));
+ 
+ 	printf (_("\
+  -r, --refuse=ok|warn|crit\n\
+     Accept tcp refusals with states ok, warn, crit (default: crit)\n\
+  -m, --maxbytes=INTEGER\n\
+     Close connection once more than this number of bytes are received\n\
+  -d, --delay=INTEGER\n\
+     Seconds to wait between sending string and polling for response\n"));
+ 
+ 	printf (_(UT_WARN_CRIT));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H host -p port [-w <warning time>] [-c <critical time>]\n\
+   [-s <send string>] [-e <expect string>] [-q <quit string>]\n\
+   [-m <maximum bytes>] [-d <delay>] [-t <timeout seconds>]\n\
+   [-r <refuse state>] [-v] [-4|-6]\n"), progname);
+ 	printf ("       %s (-h|--help)\n", progname);
+ 	printf ("       %s (-V|--version)\n", progname);
  }

Index: check_time.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_time.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_time.c	7 Aug 2003 11:51:12 -0000	1.7
--- check_time.c	9 Aug 2003 13:36:49 -0000	1.8
***************
*** 30,78 ****
  };
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
-     [-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	char *myport;
- 	asprintf (&myport, "%d", TIME_PORT);
- 
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- This plugin will check the time on the specified host.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', myport);
- 
- 	printf (_("\
-  -w, --warning-variance=INTEGER\n\
-     Time difference (sec.) necessary to result in a warning status\n\
-  -c, --critical-variance=INTEGER\n\
-     Time difference (sec.) necessary to result in a critical status\n\
-  -W, --warning-connect=INTEGER\n\
-     Response time (sec.) necessary to result in warning status\n\
-  -C, --critical-connect=INTEGER\n\
-     Response time (sec.) necessary to result in critical status\n"));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	support ();
- }
- 
- 
  #define	UNIX_EPOCH 2208988800UL
  
--- 30,33 ----
***************
*** 90,98 ****
  char *server_address = NULL;
  
- 
  int process_arguments (int, char **);
- void print_usage (void);
  void print_help (void);
! 
  
  int
--- 45,51 ----
  char *server_address = NULL;
  
  int process_arguments (int, char **);
  void print_help (void);
! void print_usage (void);
  
  int
***************
*** 277,281 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			warning_time = atoi (optarg);
  			check_warning_time = TRUE;
  			break;
--- 230,235 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			else
! 				warning_time = atoi (optarg);
  			check_warning_time = TRUE;
  			break;
***************
*** 283,287 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			critical_time = atoi (optarg);
  			check_critical_time = TRUE;
  			break;
--- 237,242 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			else
! 				critical_time = atoi (optarg);
  			check_critical_time = TRUE;
  			break;
***************
*** 289,298 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Server port must be a nonnegative integer\n"));
! 			server_port = atoi (optarg);
  			break;
  		case 't':									/* timeout */
  			if (!is_intnonneg (optarg))
  				usage (_("Timeout interval must be a nonnegative integer\n"));
! 			socket_timeout = atoi (optarg);
  			break;
  		}
--- 244,255 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Server port must be a nonnegative integer\n"));
! 			else
! 				server_port = atoi (optarg);
  			break;
  		case 't':									/* timeout */
  			if (!is_intnonneg (optarg))
  				usage (_("Timeout interval must be a nonnegative integer\n"));
! 			else
! 				socket_timeout = atoi (optarg);
  			break;
  		}
***************
*** 312,314 ****
--- 269,323 ----
  
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 	asprintf (&myport, "%d", TIME_PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ This plugin will check the time on the specified host.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', myport);
+ 
+ 	printf (_("\
+  -w, --warning-variance=INTEGER\n\
+     Time difference (sec.) necessary to result in a warning status\n\
+  -c, --critical-variance=INTEGER\n\
+     Time difference (sec.) necessary to result in a critical status\n\
+  -W, --warning-connect=INTEGER\n\
+     Response time (sec.) necessary to result in warning status\n\
+  -C, --critical-connect=INTEGER\n\
+     Response time (sec.) necessary to result in critical status\n"));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	support ();
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H <host_address> [-p port] [-w variance] [-c variance]\n\
+     [-W connect_time] [-C connect_time] [-t timeout]\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_udp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_udp.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** check_udp.c	4 Aug 2003 08:13:20 -0000	1.9
--- check_udp.c	9 Aug 2003 13:36:49 -0000	1.10
***************
*** 26,79 ****
  #include "utils.h"
  
- /* Original Command line: 
-    check_udp <host_address> [-p port] [-s send] [-e expect] \
-    [-wt warn_time] [-ct crit_time] [-to to_sec] */
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
-     [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- This plugin tests an UDP connection with the specified host.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', "none");
- 
- 	printf (_("\
-  -e, --expect=STRING <optional>\n\
-     String to expect in first line of server response\n\
-  -s, --send=STRING <optional>\n\
-     String to send to the server when initiating the connection\n"));
- 
- 	printf (_(UT_WARN_CRIT));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_("\
- This plugin will attempt to connect to the specified port on the host.\n\
- Successful connects return STATE_OK, refusals and timeouts return\n\
- STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
- 
- 	printf(_(UT_SUPPORT));
- }
- 
  int process_arguments (int, char **);
  
  int warning_time = 0;
--- 26,32 ----
  #include "utils.h"
  
  int process_arguments (int, char **);
+ void print_help (void);
+ void print_usage (void);
  
  int warning_time = 0;
***************
*** 85,89 ****
  char *server_address = NULL;
  char *server_expect = NULL;
! char *server_send = "";
  
  int
--- 38,42 ----
  char *server_address = NULL;
  char *server_expect = NULL;
! char *server_send;
  
  int
***************
*** 208,212 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			critical_time = atoi (optarg);
  			check_critical_time = TRUE;
  			break;
--- 161,166 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			else
! 				critical_time = atoi (optarg);
  			check_critical_time = TRUE;
  			break;
***************
*** 214,218 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			warning_time = atoi (optarg);
  			check_warning_time = TRUE;
  			break;
--- 168,173 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			else
! 				warning_time = atoi (optarg);
  			check_warning_time = TRUE;
  			break;
***************
*** 220,229 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Timeout interval must be a nonnegative integer\n"));
! 			socket_timeout = atoi (optarg);
  			break;
  		case 'p':									/* port */
  			if (!is_intnonneg (optarg))
  				usage (_("Server port must be a nonnegative integer\n"));
! 			server_port = atoi (optarg);
  			break;
  		case 'e':									/* expect */
--- 175,186 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Timeout interval must be a nonnegative integer\n"));
! 			else
! 				socket_timeout = atoi (optarg);
  			break;
  		case 'p':									/* port */
  			if (!is_intnonneg (optarg))
  				usage (_("Server port must be a nonnegative integer\n"));
! 			else
! 				server_port = atoi (optarg);
  			break;
  		case 'e':									/* expect */
***************
*** 246,249 ****
--- 203,266 ----
  		usage (_("Host name was not supplied\n"));
  
+ 	if (server_send == NULL)
+ 		server_send = strdup("");
+ 
  	return c;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ This plugin tests an UDP connection with the specified host.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', "none");
+ 
+ 	printf (_("\
+  -e, --expect=STRING <optional>\n\
+     String to expect in first line of server response\n\
+  -s, --send=STRING <optional>\n\
+     String to send to the server when initiating the connection\n"));
+ 
+ 	printf (_(UT_WARN_CRIT));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_("\
+ This plugin will attempt to connect to the specified port on the host.\n\
+ Successful connects return STATE_OK, refusals and timeouts return\n\
+ STATE_CRITICAL, other errors return STATE_UNKNOWN.\n\n"));
+ 
+ 	printf(_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ /* Original Command line: 
+    check_udp <host_address> [-p port] [-s send] [-e expect] \
+    [-wt warn_time] [-ct crit_time] [-to to_sec] */
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n\
+     [-e expect] [-s send] [-t to_sec] [-v]\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_ups.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ups.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -r1.8 -r1.9
*** check_ups.c	4 Aug 2003 07:42:24 -0000	1.8
--- check_ups.c	9 Aug 2003 13:36:49 -0000	1.9
***************
*** 30,95 ****
  };
  
- void
- print_usage (void)
- {
- 	printf (_("\
- Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\
-     [-t timeout] [-v]\n"), progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	char *myport;
- 	asprintf (&myport, "%d", PORT);
- 
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 2000 Tom Shields"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("This plugin tests the UPS service on the specified host.\n\
- Network UPS Tools from www.exploits.org must be running for this plugin to\n\
- work.\n\n"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_(UT_HOST_PORT), 'p', myport);
- 
- 	printf (_("\
-  -u, --ups=STRING\n\
-     Name of UPS\n"));
- 
- 	printf (_(UT_WARN_CRIT));
- 
- 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
- 
- 	printf (_(UT_VERBOSE));
- 
- 	printf (_("\
- This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\
- Supply) on a local or remote host. If the UPS is online or calibrating, the\n\
- plugin will return an OK state. If the battery is on it will return a WARNING\n\
- state.  If the UPS is off or has a low battery the plugin will return a CRITICAL\n\
- state.\n\n"));
- 
- 	printf (_("\
- You may also specify a variable to check [such as temperature, utility voltage,\n\
- battery load, etc.]  as well as warning and critical thresholds for the value of\n\
- that variable.  If the remote host has multiple UPS that are being monitored you\n\
- will have to use the [ups] option to specify which UPS to check.\n\n"));
- 
- 	printf (_("Notes:\n\n\
- This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\
- Smart UPS Tools be installed on the remote host.  If you do not have the\n\
- package installed on your system, you can download it from\n\
- http://www.exploits.org/nut\n\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  #define CHECK_NONE	 0
  
--- 30,33 ----
***************
*** 111,115 ****
  
  int server_port = PORT;
! char *server_address = "127.0.0.1";
  char *ups_name = NULL;
  double warning_value = 0.0;
--- 49,53 ----
  
  int server_port = PORT;
! char *server_address;
  char *ups_name = NULL;
  double warning_value = 0.0;
***************
*** 125,136 ****
  double ups_load_percent = 0.0;
  double ups_temperature = 0.0;
! char *ups_status = "N/A";
  
  int determine_status (void);
  int determine_supported_vars (void);
! int get_ups_variable (const char *, char *, int);
  
  int process_arguments (int, char **);
  int validate_arguments (void);
  
  int
--- 63,76 ----
  double ups_load_percent = 0.0;
  double ups_temperature = 0.0;
! char *ups_status;
  
  int determine_status (void);
  int determine_supported_vars (void);
! int get_ups_variable (const char *, char *, size_t);
  
  int process_arguments (int, char **);
  int validate_arguments (void);
+ void print_help (void);
+ void print_usage (void);
  
  int
***************
*** 142,145 ****
--- 82,86 ----
  
  	double ups_utility_deviation = 0.0;
+ 	ups_status = strdup ("N/A");
  
  	if (process_arguments (argc, argv) != OK)
***************
*** 161,165 ****
  		if (determine_status () != OK)
  			return STATE_CRITICAL;
! 		asprintf (&ups_status, "");
  		result = STATE_OK;
  
--- 102,106 ----
  		if (determine_status () != OK)
  			return STATE_CRITICAL;
! 		ups_status = strdup ("");
  		result = STATE_OK;
  
***************
*** 396,400 ****
  /* gets a variable value for a specific UPS  */
  int
! get_ups_variable (const char *varname, char *buf, int buflen)
  {
  	/*  char command[MAX_INPUT_BUFFER]; */
--- 337,341 ----
  /* gets a variable value for a specific UPS  */
  int
! get_ups_variable (const char *varname, char *buf, size_t buflen)
  {
  	/*  char command[MAX_INPUT_BUFFER]; */
***************
*** 570,573 ****
--- 511,517 ----
  	}
  
+ 	if (server_address == NULL)
+ 		server_address = strdup("127.0.0.1");
+ 
  	return validate_arguments();
  }
***************
*** 581,583 ****
--- 525,597 ----
  {
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	char *myport;
+ 	asprintf (&myport, "%d", PORT);
+ 
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 2000 Tom Shields"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("This plugin tests the UPS service on the specified host.\n\
+ Network UPS Tools from www.exploits.org must be running for this plugin to\n\
+ work.\n\n"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_(UT_HOST_PORT), 'p', myport);
+ 
+ 	printf (_("\
+  -u, --ups=STRING\n\
+     Name of UPS\n"));
+ 
+ 	printf (_(UT_WARN_CRIT));
+ 
+ 	printf (_(UT_TIMEOUT), DEFAULT_SOCKET_TIMEOUT);
+ 
+ 	printf (_(UT_VERBOSE));
+ 
+ 	printf (_("\
+ This plugin attempts to determine the status of a UPS (Uninterruptible Power\n\
+ Supply) on a local or remote host. If the UPS is online or calibrating, the\n\
+ plugin will return an OK state. If the battery is on it will return a WARNING\n\
+ state.  If the UPS is off or has a low battery the plugin will return a CRITICAL\n\
+ state.\n\n"));
+ 
+ 	printf (_("\
+ You may also specify a variable to check [such as temperature, utility voltage,\n\
+ battery load, etc.]  as well as warning and critical thresholds for the value of\n\
+ that variable.  If the remote host has multiple UPS that are being monitored you\n\
+ will have to use the [ups] option to specify which UPS to check.\n\n"));
+ 
+ 	printf (_("Notes:\n\n\
+ This plugin requires that the UPSD daemon distributed with Russel Kroll's\n\
+ Smart UPS Tools be installed on the remote host.  If you do not have the\n\
+ package installed on your system, you can download it from\n\
+ http://www.exploits.org/nut\n\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf (_("\
+ Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n\
+     [-t timeout] [-v]\n"), progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }

Index: check_users.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_users.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** check_users.c	4 Aug 2003 11:38:27 -0000	1.6
--- check_users.c	9 Aug 2003 13:36:49 -0000	1.7
***************
*** 26,66 ****
  #include "utils.h"
  
- void
- print_usage (void)
- {
- 	printf ("Usage: %s -w <users> -c <users>\n", progname);
- 	printf (_(UT_HLP_VRS), progname, progname);
- }
- 
- void
- print_help (void)
- {
- 	print_revision (progname, revision);
- 
- 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
- 	printf (_(COPYRIGHT), copyright, email);
- 
- 	printf (_("\
- 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"));
- 
- 	print_usage ();
- 
- 	printf (_(UT_HELP_VRSN));
- 
- 	printf (_("\
-  -w, --warning=INTEGER\n\
-     Set WARNING status if more than INTEGER users are logged in\n\
-  -c, --critical=INTEGER\n\
-     Set CRITICAL status if more than INTEGER users are logged in\n"));
- 
- 	printf (_(UT_SUPPORT));
- }
- 
  #define possibly_set(a,b) ((a) == 0 ? (b) : 0)
  
  int process_arguments (int, char **);
- void print_usage (void);
  void print_help (void);
  
  int wusers = -1;
--- 26,34 ----
  #include "utils.h"
  
  #define possibly_set(a,b) ((a) == 0 ? (b) : 0)
  
  int process_arguments (int, char **);
  void print_help (void);
+ void print_usage (void);
  
  int wusers = -1;
***************
*** 172,181 ****
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			cusers = atoi (optarg);
  			break;
  		case 'w':									/* warning */
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			wusers = atoi (optarg);
  			break;
  		}
--- 140,151 ----
  			if (!is_intnonneg (optarg))
  				usage (_("Critical threshold must be a nonnegative integer\n"));
! 			else
! 				cusers = atoi (optarg);
  			break;
  		case 'w':									/* warning */
  			if (!is_intnonneg (optarg))
  				usage (_("Warning threshold must be a nonnegative integer\n"));
! 			else
! 				wusers = atoi (optarg);
  			break;
  		}
***************
*** 186,190 ****
  		if (is_intnonneg (argv[c]) == FALSE)
  			usage (_("Warning threshold must be a nonnegative integer\n"));
! 		wusers = atoi (argv[c++]);
  	}
  
--- 156,161 ----
  		if (is_intnonneg (argv[c]) == FALSE)
  			usage (_("Warning threshold must be a nonnegative integer\n"));
! 		else
! 			wusers = atoi (argv[c++]);
  	}
  
***************
*** 192,198 ****
  		if (is_intnonneg (argv[c]) == FALSE)
  			usage (_("Warning threshold must be a nonnegative integer\n"));
! 		cusers = atoi (argv[c]);
  	}
  
  	return OK;
  }
--- 163,210 ----
  		if (is_intnonneg (argv[c]) == FALSE)
  			usage (_("Warning threshold must be a nonnegative integer\n"));
! 		else
! 			cusers = atoi (argv[c]);
  	}
  
  	return OK;
+ }
+ 
+ 
+ 
+ 
+ 
+ 
+ void
+ print_help (void)
+ {
+ 	print_revision (progname, revision);
+ 
+ 	printf (_("Copyright (c) 1999 Ethan Galstad\n"));
+ 	printf (_(COPYRIGHT), copyright, email);
+ 
+ 	printf (_("\
+ 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"));
+ 
+ 	print_usage ();
+ 
+ 	printf (_(UT_HELP_VRSN));
+ 
+ 	printf (_("\
+  -w, --warning=INTEGER\n\
+     Set WARNING status if more than INTEGER users are logged in\n\
+  -c, --critical=INTEGER\n\
+     Set CRITICAL status if more than INTEGER users are logged in\n"));
+ 
+ 	printf (_(UT_SUPPORT));
+ }
+ 
+ 
+ 
+ 
+ void
+ print_usage (void)
+ {
+ 	printf ("Usage: %s -w <users> -c <users>\n", progname);
+ 	printf (_(UT_HLP_VRS), progname, progname);
  }





More information about the Commits mailing list