[Nagiosplug-devel] check_tcp patch against 1.3.1

Jason Martin jhmartin at toger.us
Tue Jun 1 09:27:05 CEST 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The attached patch against check_tcp from the 1.3.1 release does the 
following:

 * 02-14-04 Jason Martin <jhmartin at toger.us>
 *  Allow non-integer timing thresholds
 * 02-06-04 Todd Carter <na_ape_finder at yahoo.com>
 * Corrected core problem in solaris 2.6 - 2.9 enviroments.
 * Seems that getopt_long.c returns a NULL value in Solaris and "" in 
Linux.
 * The result is in solaris this condition causes this plugin to core dump


A new function 	is_numnonneg is iuncluded in aws-utils.c, but of course 
that should be merged with utils.c.

- -Jason Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.3.5 (GNU/Linux)
Comment: pgpenvelope 2.10.2 - http://pgpenvelope.sourceforge.net/

iD8DBQFAvK4il2ODWuqVSBMRAjDuAJwK00RPe0pwIE0QhtCV/lbOZaF2hACeLHPx
0CN+QMTRI8DClXc1g/aOGtk=
=ixnO
-----END PGP SIGNATURE-----
-------------- next part --------------
--- check_tcp.c	Mon Jun  9 21:56:47 2003
+++ /home/nagios/plugins_build/nagios-plugins-1.3.1/plugins/aws_check_tcp.c	Thu Feb 26 12:29:26 2004
@@ -18,11 +18,20 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: check_tcp.c,v 1.13.2.3 2003/06/02 14:46:48 kdebisschop Exp $
- *
+ * $Id: aws_check_tcp.c,v 1.1.1.1 2004/02/26 20:29:26 nagios Exp $
+ * 
+ * Revision:
+ * 02-14-04 Jason Martin <jhmartin at toger.us>
+ *  Allow non-integer timing thresholds
+ * 02-06-04 Todd Carter <na_ape_finder at yahoo.com>
+ * Corrected core problem in solaris 2.6 - 2.9 enviroments.
+ * Seems that getopt_long.c returns a NULL value in Solaris and "" in Linux.
+ * The result is in solaris this condition causes this plugin to core dump
+ * - corrected. Also corrected in check_tcp, check_udp, check_http, check_nt,
+ * check_overcr and check_dns plugins.
  *****************************************************************************/
 
-#define REVISION "$Revision: 1.13.2.3 $"
+#define REVISION "$Revision: 1.1.1.1 $"
 #define DESCRIPTION "Check a TCP port"
 #define AUTHOR "Ethan Galstad"
 #define EMAIL "nagios at nagios.org"
@@ -393,7 +402,10 @@
 			break;
 
 		switch (c) {
-		case '?':                 /* print short usage statement if args not parsable */
+		case '?':                 
+		/* print short usage statement if args not parsable */
+		/* TEC and JSM Fix 2/6/04 */
+		        if (optarg != NULL)
 			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			exit (STATE_UNKNOWN);
@@ -401,7 +413,7 @@
 			print_help ();
 			exit (STATE_OK);
 		case 'V':                 /* version */
-			print_revision (progname, "$Revision: 1.13.2.3 $");
+			print_revision (progname, "$Revision: 1.1.1.1 $");
 			exit (STATE_OK);
 		case 'v':                 /* verbose mode */
 			verbose = TRUE;
@@ -412,14 +424,14 @@
 			server_address = optarg;
 			break;
 		case 'c':                 /* critical */
-			if (!is_intnonneg (optarg))
-				usage ("Critical threshold must be a nonnegative integer\n");
+			if (!is_numnonneg (optarg))
+				usage ("Critical threshold must be a nonnegative number\n");
 			critical_time = strtod (optarg, NULL);
 			check_critical_time = TRUE;
 			break;
 		case 'w':                 /* warning */
-			if (!is_intnonneg (optarg))
-				usage ("Warning threshold must be a nonnegative integer\n");
+			if (!is_numnonneg (optarg))
+				usage ("Warning threshold must be a nonnegative number\n");
 			warning_time = strtod (optarg, NULL);
 			check_warning_time = TRUE;
 			break;
@@ -501,7 +513,7 @@
 void
 print_help (void)
 {
-	print_revision (progname, "$Revision: 1.13.2.3 $");
+	print_revision (progname, "$Revision: 1.1.1.1 $");
 	printf
 		("Copyright (c) 1999 Ethan Galstad (nagios at nagios.org)\n\n"
 		 "This plugin tests %s connections with the specified host.\n\n",
-------------- next part --------------
/* plugins/aws-utils.h.  Generated automatically by configure.  */
int is_numnonneg(char *);
-------------- next part --------------
/*****************************************************************************
 *
 * utils.c
 *
 * Library of useful functions for plugins
 *
 * Copyright (c) 2000 Karl DeBisschop (karl at debisschop.net)
 * License: GPL
 *
 * $Revision: 1.1.1.1 $
 * $Date: 2004/02/26 20:29:26 $
 ****************************************************************************/

#include "config.h"
#include "common.h"
#include "version.h"
#include <stdarg.h>
#include <limits.h>

int is_numnonneg (char *);

#define LABELLEN 63
#define STRLEN 64
#define TXTBLK 128

/* **************************************************************************
 * max_state(STATE_x, STATE_y)
 * compares STATE_x to  STATE_y and returns result based on the following
 * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL
 *
 * Note that numerically the above does not hold
 ****************************************************************************/

#define max(a,b) (((a)>(b))?(a):(b))

int
is_numnonneg (char *number)
{
	if (strcmp("0",number) != 0 && strtod(number,NULL) == 0.0 &&
strtod(number,NULL) >= 0.0) 
		return FALSE;
	else
		return TRUE;
}



More information about the Devel mailing list