John C. Frickson 9 anni fa
parent
commit
a4fa44a112
3 ha cambiato i file con 36 aggiunte e 28 eliminazioni
  1. 30 23
      plugins-scripts/check_mailq.pl
  2. 2 1
      plugins/check_http.c
  3. 4 4
      plugins/check_mysql.c

+ 30 - 23
plugins-scripts/check_mailq.pl

@@ -59,11 +59,13 @@ if ($status){
 }
 }
 
 
 if ($opt_s) {
 if ($opt_s) {
-	if (defined $utils::PATH_TO_SUDO && -x $utils::PATH_TO_SUDO) {
-		$sudo = $utils::PATH_TO_SUDO;
-	} else {
-		print "ERROR: Cannot execute sudo\n";
-		exit $ERRORS{'UNKNOWN'};
+	if ($utils::PATH_TO_SUDO ne "") {
+		if (-x $utils::PATH_TO_SUDO) {
+			$sudo = $utils::PATH_TO_SUDO;
+		} else {
+			print "ERROR: Cannot execute sudo\n";
+			exit $ERRORS{'UNKNOWN'};
+		}
 	}
 	}
 } else {
 } else {
 	$sudo = "";
 	$sudo = "";
@@ -309,26 +311,31 @@ if ($mailq eq "sendmail") {
 elsif ( $mailq eq "postfix" ) {
 elsif ( $mailq eq "postfix" ) {
 
 
      ## open mailq
      ## open mailq
-        if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
-                if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
-                        print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
-                        exit $ERRORS{'UNKNOWN'};
-                }
-        }elsif( defined $utils::PATH_TO_MAILQ){
-                unless (-x $utils::PATH_TO_MAILQ) {
-                        print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n";
-                        exit $ERRORS{'UNKNOWN'};
-                }
-        } else {
-                print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n";
-                exit $ERRORS{'UNKNOWN'};
-        }
-
+	if ( defined $utils::PATH_TO_MAILQ ) {
+		if (-x $utils::PATH_TO_MAILQ) {
+			if (! open (MAILQ, "$utils::PATH_TO_MAILQ | ")) {
+				print "ERROR: $utils::PATH_TO_MAILQ returned an error\n";
+				exit $ERRORS{'UNKNOWN'};
+			}
+		}
+		else {
+			if ( $sudo ne "" ) {
+				if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ | " ) ) {
+					print "ERROR: $utils::PATH_TO_MAILQ is not executable with sudo by (uid $>:gid($)))\n";
+					exit $ERRORS{'UNKNOWN'};
+				}
+			} else {
+				print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($))) and sudo is not set in utils.pm\n";
+				exit $ERRORS{'UNKNOWN'};
+			}
+		}
+	} else {
+		print "ERROR: \$utils::PATH_TO_MAILQ is not defined in utils.pm\n";
+		exit $ERRORS{'UNKNOWN'};
+	}
 
 
-        @lines = reverse <MAILQ>;
 
 
-        # close qmail-qstat
-        close MAILQ;
+	@lines = reverse <MAILQ>;
 
 
         if ( $? ) {
         if ( $? ) {
 		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
 		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;

+ 2 - 1
plugins/check_http.c

@@ -750,7 +750,8 @@ header_value (const char *headers, const char *header)
 
 
   value_end = strchr(s, '\r');
   value_end = strchr(s, '\r');
   if (!value_end) {
   if (!value_end) {
-      die (STATE_UNKNOWN, _("HTTP_UNKNOWN - Failed to parse response headers\n"));
+      // Turns out there's no newline after the header... So it's at the end!
+      value_end = s + strlen(s);
   }
   }
 
 
   value_size = value_end - s;
   value_size = value_end - s;

+ 4 - 4
plugins/check_mysql.c

@@ -66,17 +66,18 @@ int verbose = 0;
 static double warning_time = 0;
 static double warning_time = 0;
 static double critical_time = 0;
 static double critical_time = 0;
 
 
-#define LENGTH_METRIC_UNIT 6
+#define LENGTH_METRIC_UNIT 7
 static const char *metric_unit[LENGTH_METRIC_UNIT] = {
 static const char *metric_unit[LENGTH_METRIC_UNIT] = {
-	"Open_files",
+	"x",
 	"Open_tables",
 	"Open_tables",
 	"Qcache_free_memory",
 	"Qcache_free_memory",
 	"Qcache_queries_in_cache",
 	"Qcache_queries_in_cache",
 	"Threads_connected",
 	"Threads_connected",
 	"Threads_running"
 	"Threads_running"
+	"Uptime"
 };
 };
 
 
-#define LENGTH_METRIC_COUNTER 9
+#define LENGTH_METRIC_COUNTER 8
 static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
 static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
 	"Connections",
 	"Connections",
 	"Qcache_hits",
 	"Qcache_hits",
@@ -86,7 +87,6 @@ static const char *metric_counter[LENGTH_METRIC_COUNTER] = {
 	"Queries",
 	"Queries",
 	"Questions",
 	"Questions",
 	"Table_locks_waited",
 	"Table_locks_waited",
-	"Uptime"
 };
 };
 
 
 thresholds *my_threshold = NULL;
 thresholds *my_threshold = NULL;