Procházet zdrojové kódy

fix the revert from master - update changelog and thanks file

Marc před 8 roky
rodič
revize
19f0fe5200
4 změnil soubory, kde provedl 59 přidání a 3 odebrání
  1. 1 0
      NEWS
  2. 1 0
      THANKS.in
  3. 11 0
      configure.ac
  4. 46 3
      plugins-scripts/check_mailq.pl

+ 1 - 0
NEWS

@@ -10,6 +10,7 @@ This file documents the major additions and syntax changes between releases.
 	check_mailq: Add support for opensmtpd
 	check_mailq: Add support for opensmtpd
 	check_mailq: Add mailq -C option for config dir or config file
 	check_mailq: Add mailq -C option for config dir or config file
 	check_disk: Add -s option to show status for each path/partition
 	check_disk: Add -s option to show status for each path/partition
+	check_mailq.pl: Add option for opensmtpd (brigriffin)
 
 
 
 
 2.2.2 xxxx-xx-xx
 2.2.2 xxxx-xx-xx

+ 1 - 0
THANKS.in

@@ -42,6 +42,7 @@ Booker C. Bense
 Bradley Baetz
 Bradley Baetz
 Brian De Wolf
 Brian De Wolf
 Brian Landers
 Brian Landers
+brigriffin
 Bryan Irvine
 Bryan Irvine
 Carlos Canau
 Carlos Canau
 Carole Verdon
 Carole Verdon

+ 11 - 0
configure.ac

@@ -1557,6 +1557,17 @@ else
 	AC_MSG_WARN([Could not find qmail-qstat or equivalent])
 	AC_MSG_WARN([Could not find qmail-qstat or equivalent])
 fi
 fi
 
 
+AC_PATH_PROG(PATH_TO_SMTPCTL,smtpctl)
+AC_ARG_WITH(smtpctl_command,
+            ACX_HELP_STRING([--with-smtpctl-command=PATH],
+                            [sets path to smtpctl]), PATH_TO_SMTPCTL=$withval)
+if test -n "$PATH_TO_SMTPCTL"
+then
+	AC_DEFINE_UNQUOTED(PATH_TO_SMTPCTL,"$PATH_TO_SMTPCTL",[path to smtpctl])
+else
+	AC_MSG_WARN([Could not find smtpctl or equivalent])
+fi
+
 dnl SWAP info required is amount allocated/available and amount free
 dnl SWAP info required is amount allocated/available and amount free
 dnl The plugin works through all the swap devices and adds up the total swap
 dnl The plugin works through all the swap devices and adds up the total swap
 dnl available.
 dnl available.

+ 46 - 3
plugins-scripts/check_mailq.pl

@@ -526,7 +526,47 @@ elsif ( $mailq eq "exim" ) {
 		$state = $ERRORS{'CRITICAL'};
 		$state = $ERRORS{'CRITICAL'};
 	}
 	}
 } # end of ($mailq eq "exim")
 } # end of ($mailq eq "exim")
+elsif ( $mailq eq "opensmtpd" ) {
+	## open smtpctl
+	if ( defined $utils::PATH_TO_SMTPCTL && -x $utils::PATH_TO_SMTPCTL ) {
+		if (! open (MAILQ, "$sudo $utils::PATH_TO_SMTPCTL show queue | " ) ) {
+			print "ERROR: could not open $utils::PATH_TO_SMTPCTL \n";
+			exit $ERRORS{'UNKNOWN'};
+		}
+	}elsif( defined $utils::PATH_TO_SMTPCTL){
+		unless (-x $utils::PATH_TO_SMTPCTL) {
+			print "ERROR: $utils::PATH_TO_SMTPCTL is not executable by (uid $>:gid($)))\n";
+			exit $ERRORS{'UNKNOWN'};
+		}
+	} else {
+		print "ERROR: \$utils::PATH_TO_SMTPCTL is not defined\n";
+		exit $ERRORS{'UNKNOWN'};
+	}
 
 
+	while (<MAILQ>) {
+
+		# 34357f5b3f589feb|inet4|mta||f.someone@domaina.org|no-reply@domainb.com|no-reply@domainb.com|1498235412|1498581012|0|25|pending|17168|Network error on destination MXs
+		if (/^.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*|.*$/) {
+			$msg_q++ ;
+		}
+	}
+	close(MAILQ);
+
+	if ( $? ) {
+		print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_SMTPCTL",$/;
+		exit $ERRORS{CRITICAL};
+	}
+	if ($msg_q < $opt_w) {
+		$msg = "OK: $mailq mailq ($msg_q) is below threshold ($opt_w/$opt_c)";
+		$state = $ERRORS{'OK'};
+	}elsif ($msg_q >= $opt_w  && $msg_q < $opt_c) {
+		$msg = "WARNING: $mailq mailq is $msg_q (threshold w = $opt_w)";
+		$state = $ERRORS{'WARNING'};
+	}else {
+		$msg = "CRITICAL: $mailq mailq is $msg_q (threshold c = $opt_c)";
+		$state = $ERRORS{'CRITICAL'};
+	}
+} # end of ($mailq eq "opensmtpd")
 elsif ( $mailq eq "nullmailer" ) {
 elsif ( $mailq eq "nullmailer" ) {
 	## open mailq
 	## open mailq
 	if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
 	if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
@@ -658,7 +698,7 @@ sub process_arguments(){
 	}
 	}
 
 
 	if (defined $opt_M) {
 	if (defined $opt_M) {
-		if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer|opensmtp)$/) {
+		if ($opt_M =~ /^(sendmail|qmail|postfix|exim|nullmailer|opensmtpd)$/) {
 			$mailq = $opt_M ;
 			$mailq = $opt_M ;
 		}elsif( $opt_M eq ''){
 		}elsif( $opt_M eq ''){
 			$mailq = 'sendmail';
 			$mailq = 'sendmail';
@@ -688,6 +728,10 @@ sub process_arguments(){
 		{
 		{
 			$mailq = 'nullmailer';
 			$mailq = 'nullmailer';
 		}
 		}
+		elsif (defined $utils::PATH_TO_SMTPCTL && -x $utils::PATH_TO_SMTPCTL)
+		{
+			$mailq = 'opensmtpd';
+		}
 		else {
 		else {
 			$mailq = 'sendmail';
 			$mailq = 'sendmail';
 		}
 		}
@@ -713,8 +757,7 @@ sub print_help () {
 	print "-W (--Warning)   = Min. number of messages for same domain in queue to generate warning\n";
 	print "-W (--Warning)   = Min. number of messages for same domain in queue to generate warning\n";
 	print "-C (--Critical)  = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
 	print "-C (--Critical)  = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
 	print "-t (--timeout)   = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
 	print "-t (--timeout)   = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
-	print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
-	print "-d (--configdir) = Config file or directory\n";
+	print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer | opensmtpd ] (default = autodetect)\n";
 	print "-h (--help)\n";
 	print "-h (--help)\n";
 	print "-V (--version)\n";
 	print "-V (--version)\n";
 	print "-v (--verbose)   = debugging output\n";
 	print "-v (--verbose)   = debugging output\n";