diff options
Diffstat (limited to 'web/attachments/49981-check_mailq.diff')
| -rw-r--r-- | web/attachments/49981-check_mailq.diff | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/web/attachments/49981-check_mailq.diff b/web/attachments/49981-check_mailq.diff new file mode 100644 index 0000000..314577e --- /dev/null +++ b/web/attachments/49981-check_mailq.diff | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | 295a296,379 | ||
| 2 | > elsif ( $mailq eq "postfix" ) { | ||
| 3 | > | ||
| 4 | > ## open mailq | ||
| 5 | > if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
| 6 | > if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | ||
| 7 | > print "ERROR: could not open $utils::PATH_TO_MAILQ \n"; | ||
| 8 | > exit $ERRORS{'UNKNOWN'}; | ||
| 9 | > } | ||
| 10 | > }elsif( defined $utils::PATH_TO_MAILQ){ | ||
| 11 | > unless (-x $utils::PATH_TO_MAILQ) { | ||
| 12 | > print "ERROR: $utils::PATH_TO_MAILQ is not executable by (uid $>:gid($)))\n"; | ||
| 13 | > exit $ERRORS{'UNKNOWN'}; | ||
| 14 | > } | ||
| 15 | > } else { | ||
| 16 | > print "ERROR: \$utils::PATH_TO_MAILQ is not defined\n"; | ||
| 17 | > exit $ERRORS{'UNKNOWN'}; | ||
| 18 | > } | ||
| 19 | > | ||
| 20 | > | ||
| 21 | > @lines = reverse <MAILQ>; | ||
| 22 | > | ||
| 23 | > # close qmail-qstat | ||
| 24 | > close MAILQ; | ||
| 25 | > # declare an error if we also get a non-zero return code from mailq | ||
| 26 | > # unless already set to critical | ||
| 27 | > if ( $? ) { | ||
| 28 | > $state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"} ; | ||
| 29 | > print "STDERR $?: $!\n" if $verbose; | ||
| 30 | > $msg = "$state: (stderr)\n"; | ||
| 31 | > } | ||
| 32 | > | ||
| 33 | > ## shut off the alarm | ||
| 34 | > alarm(0); | ||
| 35 | > | ||
| 36 | > # check queue length | ||
| 37 | > if ($lines[0]=~/Kbytes in (\d+)/) { | ||
| 38 | > $msg_q = $1 ; | ||
| 39 | > }elsif ($lines[0]=~/Mail queue is empty/) { | ||
| 40 | > $msg_q = 0; | ||
| 41 | > }else{ | ||
| 42 | > print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n"; | ||
| 43 | > exit $ERRORS{'UNKNOWN'}; | ||
| 44 | > } | ||
| 45 | > | ||
| 46 | > # check messages not processed | ||
| 47 | > #if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) { | ||
| 48 | > # my $msg_p = $1; | ||
| 49 | > #}else{ | ||
| 50 | > # print "Couldn't match $utils::PATH_TO_QMAIL_QSTAT output\n"; | ||
| 51 | > # exit $ERRORS{'UNKNOWN'}; | ||
| 52 | > #} | ||
| 53 | > | ||
| 54 | > # check queue length(s) | ||
| 55 | > if ($msg_q == 0){ | ||
| 56 | > $msg = "OK: mailq reports queue is empty"; | ||
| 57 | > $state = $ERRORS{'OK'}; | ||
| 58 | > } else { | ||
| 59 | > print "msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; | ||
| 60 | > | ||
| 61 | > # overall queue length | ||
| 62 | > if ($msg_q < $opt_w) { | ||
| 63 | > $msg = "OK: mailq ($msg_q) is below threshold ($opt_w/$opt_c)"; | ||
| 64 | > $state = $ERRORS{'OK'}; | ||
| 65 | > }elsif ($msg_q >= $opt_w && $msg_q < $opt_c) { | ||
| 66 | > $msg = "WARNING: mailq is $msg_q (threshold w = $opt_w)"; | ||
| 67 | > $state = $ERRORS{'WARNING'}; | ||
| 68 | > }else { | ||
| 69 | > $msg = "CRITICAL: mailq is $msg_q (threshold c = $opt_c)"; | ||
| 70 | > $state = $ERRORS{'CRITICAL'}; | ||
| 71 | > } | ||
| 72 | > | ||
| 73 | > # check messages not yet preprocessed (only compare is $opt_W and $opt_C | ||
| 74 | > # are defined) | ||
| 75 | > | ||
| 76 | > #if (defined $opt_W) { | ||
| 77 | > # $msg .= "[Preprocessed = $msg_p]"; | ||
| 78 | > # if ($msg_p >= $opt_W && $msg_p < $opt_C ) { | ||
| 79 | > # $state = $state == $ERRORS{"CRITICAL"} ? $ERRORS{"CRITICAL"} : $ERRORS{"WARNING"} ; | ||
| 80 | > # }elsif ($msg_p >= $opt_C ) { | ||
| 81 | > # $state = $ERRORS{"CRITICAL"} ; | ||
| 82 | > # } | ||
| 83 | > #} | ||
| 84 | > } | ||
| 85 | > } # end of ($mailq eq "postfixl") | ||
| 86 | 445c529 | ||
| 87 | < if ($opt_M =~ /sendmail/ || $opt_M =~ /qmail/ ) { | ||
| 88 | --- | ||
| 89 | > if ($opt_M =~ /sendmail/ || $opt_M =~ /qmail/ || $opt_M =~ /postfix/ ) { | ||
| 90 | 477c561 | ||
| 91 | < print "-M (--mailserver) = [ sendmail | qmail ] (default = sendmail)\n"; | ||
| 92 | --- | ||
| 93 | > print "-M (--mailserver) = [ sendmail | qmail | postfix ] (default = sendmail)\n"; | ||
