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