New upstream version 2.3.2
This commit is contained in:
parent
09f4277f49
commit
21323d25dd
104 changed files with 34386 additions and 7430 deletions
|
@ -28,9 +28,9 @@
|
|||
use POSIX;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s
|
||||
$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines
|
||||
%srcdomains %dstdomains);
|
||||
use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t $opt_s $opt_d
|
||||
$opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq $mailq_args
|
||||
@lines %srcdomains %dstdomains);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use utils qw(%ERRORS &print_revision &support &usage );
|
||||
|
@ -48,6 +48,8 @@ $PROGNAME = "check_mailq";
|
|||
$mailq = 'sendmail'; # default
|
||||
$msg_q = 0 ;
|
||||
$msg_p = 0 ;
|
||||
# If appended, must start with a space
|
||||
$mailq_args = '' ;
|
||||
$state = $ERRORS{'UNKNOWN'};
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
|
@ -68,6 +70,10 @@ if ($opt_s) {
|
|||
$sudo = "";
|
||||
}
|
||||
|
||||
if ($opt_d) {
|
||||
$mailq_args = $mailq_args . ' -C ' . $opt_d;
|
||||
}
|
||||
|
||||
$SIG{'ALRM'} = sub {
|
||||
print ("ERROR: timed out waiting for $utils::PATH_TO_MAILQ \n");
|
||||
exit $ERRORS{"WARNING"};
|
||||
|
@ -309,8 +315,8 @@ elsif ( $mailq eq "postfix" ) {
|
|||
|
||||
## 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";
|
||||
if (! open (MAILQ, "$sudo $utils::PATH_TO_MAILQ$mailq_args | " ) ) {
|
||||
print "ERROR: could not open $utils::PATH_TO_MAILQ$mailq_args \n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif( defined $utils::PATH_TO_MAILQ){
|
||||
|
@ -330,7 +336,7 @@ elsif ( $mailq eq "postfix" ) {
|
|||
close MAILQ;
|
||||
|
||||
if ( $? ) {
|
||||
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ",$/;
|
||||
print "CRITICAL: Error code ".($?>>8)." returned from $utils::PATH_TO_MAILQ$mailq_args",$/;
|
||||
exit $ERRORS{CRITICAL};
|
||||
}
|
||||
|
||||
|
@ -343,7 +349,7 @@ elsif ( $mailq eq "postfix" ) {
|
|||
}elsif ($lines[0]=~/Mail queue is empty/) {
|
||||
$msg_q = 0;
|
||||
}else{
|
||||
print "Couldn't match $utils::PATH_TO_MAILQ output\n";
|
||||
print "Couldn't match $utils::PATH_TO_MAILQ$mailq_args output\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
|
@ -533,7 +539,7 @@ elsif ( $mailq eq "nullmailer" ) {
|
|||
while (<MAILQ>) {
|
||||
#2006-06-22 16:00:00 282 bytes
|
||||
|
||||
if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-2][0-9]\:[0-2][0-9]\s{2}[0-9]+\sbytes$/) {
|
||||
if (/^[1-9][0-9]*-[01][0-9]-[0-3][0-9]\s[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\s+[0-9]+\sbytes/) {
|
||||
$msg_q++ ;
|
||||
}
|
||||
}
|
||||
|
@ -561,16 +567,17 @@ exit $state;
|
|||
|
||||
sub process_arguments(){
|
||||
GetOptions
|
||||
("V" => \$opt_V, "version" => \$opt_V,
|
||||
"v" => \$opt_v, "verbose" => \$opt_v,
|
||||
"h" => \$opt_h, "help" => \$opt_h,
|
||||
("V" => \$opt_V, "version" => \$opt_V,
|
||||
"v" => \$opt_v, "verbose" => \$opt_v,
|
||||
"h" => \$opt_h, "help" => \$opt_h,
|
||||
"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
|
||||
"c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
|
||||
"W=i" => \$opt_W, "warning-domain=i" => \$opt_W, # Warning if above this number
|
||||
"C=i" => \$opt_C, "critical-domain=i" => \$opt_C, # Critical if above this number
|
||||
"t=i" => \$opt_t, "timeout=i" => \$opt_t,
|
||||
"s" => \$opt_s, "sudo" => \$opt_s,
|
||||
"W=i" => \$opt_W, # warning if above this number
|
||||
"C=i" => \$opt_C, # critical if above this number
|
||||
"d:s" => \$opt_d, "configdir:s" => \$opt_d,
|
||||
);
|
||||
|
||||
if ($opt_V) {
|
||||
|
@ -651,7 +658,7 @@ sub process_arguments(){
|
|||
}
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-v]\n";
|
||||
print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-s] [-d <CONFIGDIR>] [-v]\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
|
@ -664,14 +671,15 @@ sub print_help () {
|
|||
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 queue to generate critical alert ( w < c )\n";
|
||||
print "-W = Min. number of messages for same domain in queue to generate warning\n";
|
||||
print "-C = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
|
||||
print "-W (--warning-domain) = Min. number of messages for same domain in queue to generate warning\n";
|
||||
print "-C (--critical-domain) = 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 | nullmailer ] (default = autodetect)\n";
|
||||
print "-s (--sudo) = Use sudo to call the mailq command\n";
|
||||
print "-d (--configdir) = Config file or directory\n";
|
||||
print "-h (--help)\n";
|
||||
print "-V (--version)\n";
|
||||
print "-v (--verbose) = debugging output\n";
|
||||
print "-v (--verbose) = debugging output\n";
|
||||
print "\n\n";
|
||||
print "Note: -w and -c are required arguments. -W and -C are optional.\n";
|
||||
print " -W and -C are applied to domains listed on the queues - both FROM and TO. (sendmail)\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue