[Nagiosplug-checkins] nagiosplug/plugins check_apt.c,1.5,1.6 check_snmp.c,1.59,1.60 check_smtp.c,1.50,1.51 check_http.c,1.89,1.90

Ton Voon tonvoon at users.sourceforge.net
Thu May 25 05:34:20 CEST 2006


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv20401/plugins

Modified Files:
	check_apt.c check_snmp.c check_smtp.c check_http.c 
Log Message:
Use coreutils' regexp libraries, so regexp always available now


Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- check_smtp.c	2 Nov 2005 08:47:26 -0000	1.50
+++ check_smtp.c	25 May 2006 12:33:24 -0000	1.51
@@ -59,8 +59,7 @@
 void print_usage (void);
 int my_close(void);
 
-#ifdef HAVE_REGEX_H
-#include <regex.h>
+#include "regex.h"
 char regex_expect[MAX_INPUT_BUFFER] = "";
 regex_t preg;
 regmatch_t pmatch[10];
@@ -69,7 +68,6 @@
 int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
 int eflags = 0;
 int errcode, excode;
-#endif
 
 int server_port = SMTP_PORT;
 char *server_address = NULL;
@@ -308,7 +306,6 @@
 				printf("%s", buffer);
 			strip (buffer);
 			if (n < nresponses) {
-#ifdef HAVE_REGEX_H
 				cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
 				errcode = regcomp (&preg, responses[n], cflags);
 				if (errcode != 0) {
@@ -329,12 +326,6 @@
 					printf (_("Execute Error: %s\n"), errbuf);
 					result = STATE_UNKNOWN;
 				}
-#else
-				if (strstr(buffer, responses[n])!=buffer) {
-					result = STATE_WARNING;
-					printf (_("SMTP %s - Invalid response '%s' to command '%s'\n"), state_text (result), buffer, commands[n]);
-				}
-#endif
 			}
 			n++;
 		}

Index: check_apt.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_apt.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- check_apt.c	5 Apr 2006 06:58:34 -0000	1.5
+++ check_apt.c	25 May 2006 12:33:24 -0000	1.6
@@ -30,7 +30,7 @@
 #include "common.h"
 #include "runcmd.h"
 #include "utils.h"
-#include <regex.h>
+#include "regex.h"
 
 /* some constants */
 typedef enum { UPGRADE, DIST_UPGRADE, NO_UPGRADE } upgrade_type;

Index: check_snmp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_snmp.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- check_snmp.c	24 May 2006 09:05:35 -0000	1.59
+++ check_snmp.c	25 May 2006 12:33:24 -0000	1.60
@@ -75,8 +75,7 @@
 void print_usage (void);
 void print_help (void);
 
-#ifdef HAVE_REGEX_H
-#include <regex.h>
+#include "regex.h"
 char regex_expect[MAX_INPUT_BUFFER] = "";
 regex_t preg;
 regmatch_t pmatch[10];
@@ -86,7 +85,6 @@
 int cflags = REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
 int eflags = 0;
 int errcode, excode;
-#endif
 
 char *server_address = NULL;
 char *community = NULL;
@@ -292,7 +290,6 @@
 
 		/* Process this block for regex matching */
 		else if (eval_method[i] & CRIT_REGEX) {
-#ifdef HAVE_REGEX_H
 			excode = regexec (&preg, response, 10, pmatch, eflags);
 			if (excode == 0) {
 				iresult = STATE_OK;
@@ -305,10 +302,6 @@
 			else {
 				iresult = STATE_CRITICAL;
 			}
-#else
-			printf (_("Call for regex which was not a compiled option"));
-			exit (STATE_UNKNOWN);
-#endif
 		}
 
 		/* Process this block for existence-nonexistence checks */
@@ -542,11 +535,8 @@
 			ii++;
 			break;
 		case 'R':									/* regex */
-#ifdef HAVE_REGEX_H
 			cflags = REG_ICASE;
-#endif
 		case 'r':									/* regex */
-#ifdef HAVE_REGEX_H
 			cflags |= REG_EXTENDED | REG_NOSUB | REG_NEWLINE;
 			strncpy (regex_expect, optarg, sizeof (regex_expect) - 1);
 			regex_expect[sizeof (regex_expect) - 1] = 0;
@@ -558,10 +548,6 @@
 			}
 			eval_method[jj++] = CRIT_REGEX;
 			ii++;
-#else
-			printf (_("call for regex which was not a compiled option"));
-			exit (STATE_UNKNOWN);
-#endif
 			break;
 
 	/* Format */

Index: check_http.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_http.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- check_http.c	5 Apr 2006 07:58:27 -0000	1.89
+++ check_http.c	25 May 2006 12:33:24 -0000	1.90
@@ -51,19 +51,17 @@
 int no_body = FALSE;
 int maximum_age = -1;
 
-#ifdef HAVE_REGEX_H
 enum {
   REGS = 2,
   MAX_RE_SIZE = 256
 };
-#include <regex.h>
+#include "regex.h"
 regex_t preg;
 regmatch_t pmatch[REGS];
 char regexp[MAX_RE_SIZE];
 char errbuf[MAX_INPUT_BUFFER];
 int cflags = REG_NOSUB | REG_EXTENDED | REG_NEWLINE;
 int errcode;
-#endif
 
 struct timeval tv;
 
@@ -333,13 +331,6 @@
     case 'T': /* Content-type */
       asprintf (&http_content_type, "%s", optarg);
       break;
-#ifndef HAVE_REGEX_H
-    case 'l': /* linespan */
-    case 'r': /* linespan */
-    case 'R': /* linespan */
-      usage4 (_("Call for regex which was not a compiled option"));
-      break;
-#else
     case 'l': /* linespan */
       cflags &= ~REG_NEWLINE;
       break;
@@ -355,7 +346,6 @@
         return ERROR;
       }
       break;
-#endif
     case '4':
       address_family = AF_INET;
       break;
@@ -992,7 +982,7 @@
       exit (STATE_CRITICAL);
     }
   }
-#ifdef HAVE_REGEX_H
+
   if (strlen (regexp)) {
     errcode = regexec (&preg, page, REGS, pmatch, 0);
     if (errcode == 0) {
@@ -1016,7 +1006,6 @@
       }
     }
   }
-#endif
 
   /* make sure the page is of an appropriate size */
   /* page_len = get_content_length(header); */
@@ -1270,7 +1259,6 @@
  -T, --content-type=STRING\n\
    specify Content-Type header media type when POSTing\n"), HTTP_EXPECT);
 
-#ifdef HAVE_REGEX_H
   printf (_("\
  -l, --linespan\n\
     Allow regex to span newlines (must precede -r or -R)\n\
@@ -1278,7 +1266,6 @@
     Search page for regex STRING\n\
  -R, --eregi=STRING\n\
     Search page for case-insensitive regex STRING\n"));
-#endif
 
   printf (_("\
  -a, --authorization=AUTH_PAIR\n\





More information about the Commits mailing list