--- check_mailq.pl.orig	2005-11-28 21:41:11.000000000 +0100
+++ check_mailq.pl	2005-11-28 21:51:19.000000000 +0100
@@ -30,7 +30,7 @@
 use strict;
 use Getopt::Long;
 use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t
-					$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines
+					$opt_Q $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq_options @lines
 					%srcdomains %dstdomains);
 use lib  utils.pm;
 use utils qw(%ERRORS &print_revision &support &usage );
@@ -45,6 +45,7 @@
 $ENV{'ENV'}='';
 $PROGNAME = "check_mailq";
 $mailq = 'sendmail';	# default
+$mailq_options = '';
 $msg_q = 0 ;
 $msg_p = 0 ;
 $state = $ERRORS{'UNKNOWN'};
@@ -68,7 +69,7 @@
 
 	## open mailq 
 	if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
-		if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
+		if (! open (MAILQ, "$utils::PATH_TO_MAILQ $mailq_options | " ) ) {
 			print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
 			exit $ERRORS{'UNKNOWN'};
 		}
@@ -516,6 +517,7 @@
 		("V"   => \$opt_V, "version"	=> \$opt_V,
 		 "v"   => \$opt_v, "verbose"	=> \$opt_v,
 		 "h"   => \$opt_h, "help"		=> \$opt_h,
+         "Q"   => \$opt_Q, "clientmqueue" => \$opt_Q, # check clientmqueue
 		 "M:s" => \$opt_M, "mailserver:s" => \$opt_M, # mailserver (default	sendmail)
 		 "w=i" => \$opt_w, "warning=i"  => \$opt_w,   # warning if above this number
 		 "c=i" => \$opt_c, "critical=i" => \$opt_c,	  # critical if above this number
@@ -572,12 +574,19 @@
 	}else{
 		$mailq = 'sendmail' ;
 	}
+
+    if ($mailq =~ /^sendmail$/) {
+        $mailq_options = '-Ac';
+    } else {
+        print "-Q: only supported with sendmail\n";
+        exit $ERRORS{'UNKNOWN'};
+    }
 		
 	return $ERRORS{'OK'};
 }
 
 sub print_usage () {
-	print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n";
+	print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA> [-Q] ] [-t <timeout>] [-v verbose]\n";
 }
 
 sub print_help () {
@@ -588,12 +597,13 @@
 	print "\n";
 	print "   Checks the number of messages in the mail queue (supports multiple sendmail queues, qmail)\n";
 	print "   Feedback/patches to support non-sendmail mailqueue welcome\n\n";
-	print "-w (--warning)   = Min. number of messages in queue to generate warning\n";
-	print "-c (--critical)  = Min. number of messages in queu to generate critical alert ( w < c )\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 "-t (--timeout)   = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
-	print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n";
+	print "-w (--warning)       = Min. number of messages in queue to generate warning\n";
+	print "-c (--critical)      = Min. number of messages in queu to generate critical alert ( w < c )\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 "-t (--timeout)       = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
+	print "-M (--mailserver)    = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n";
+    print "-Q (--clientmqueue)  = Show the mail submission queue specified in /etc/mail/submit.cf (sendmail only)\n";
 	print "-h (--help)\n";
 	print "-V (--version)\n";
 	print "-v (--verbose)   = debugging output\n";

