diff options
Diffstat (limited to 'web/attachments/74206-check_mailq.diffs')
-rw-r--r-- | web/attachments/74206-check_mailq.diffs | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/web/attachments/74206-check_mailq.diffs b/web/attachments/74206-check_mailq.diffs new file mode 100644 index 0000000..67fa086 --- /dev/null +++ b/web/attachments/74206-check_mailq.diffs | |||
@@ -0,0 +1,178 @@ | |||
1 | --- plugins-scripts/utils.pm.in.orig 2004-01-13 12:45:04.000000000 -0500 | ||
2 | +++ plugins-scripts/utils.pm.in 2004-01-13 12:45:39.000000000 -0500 | ||
3 | @@ -43,6 +43,7 @@ | ||
4 | $PATH_TO_SMBCLIENT = "@PATH_TO_SMBCLIENT@" ; | ||
5 | $PATH_TO_MAILQ = "@PATH_TO_MAILQ@"; | ||
6 | $PATH_TO_QMAIL_QSTAT = "@PATH_TO_QMAIL_QSTAT@"; | ||
7 | +$PATH_TO_SENDMAIL_CF = "@PATH_TO_SENDMAIL_CF@"; | ||
8 | |||
9 | ## common variables | ||
10 | $TIMEOUT = 15; | ||
11 | --- plugins-scripts/check_mailq.pl.orig 2004-01-13 12:45:47.000000000 -0500 | ||
12 | +++ plugins-scripts/check_mailq.pl 2004-01-20 14:53:05.000000000 -0500 | ||
13 | @@ -28,15 +28,16 @@ | ||
14 | use strict; | ||
15 | use Getopt::Long; | ||
16 | use vars qw($opt_V $opt_h $opt_v $verbose $PROGNAME $opt_w $opt_c $opt_t | ||
17 | - $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $mailq @lines | ||
18 | - %srcdomains %dstdomains); | ||
19 | + $opt_M $mailq $status $state $msg $msg_q $msg_p $opt_W $opt_C $opt_f | ||
20 | + $mailq @lines %srcdomains %dstdomains); | ||
21 | use lib utils.pm; | ||
22 | use utils qw(%ERRORS &print_revision &support &usage ); | ||
23 | - | ||
24 | +use File::Glob ':glob'; | ||
25 | |||
26 | sub print_help (); | ||
27 | sub print_usage (); | ||
28 | sub process_arguments (); | ||
29 | +sub get_queue_directories (;$); | ||
30 | |||
31 | $ENV{'PATH'}=''; | ||
32 | $ENV{'BASH_ENV'}=''; | ||
33 | @@ -47,7 +48,7 @@ | ||
34 | $msg_p = 0 ; | ||
35 | $state = $ERRORS{'UNKNOWN'}; | ||
36 | |||
37 | -Getopt::Long::Configure('bundling'); | ||
38 | +Getopt::Long::Configure('bundling','no_ignore_case'); | ||
39 | $status = process_arguments(); | ||
40 | if ($status){ | ||
41 | print "ERROR: processing arguments\n"; | ||
42 | @@ -64,6 +65,22 @@ | ||
43 | |||
44 | if ($mailq eq "sendmail") { | ||
45 | |||
46 | +## get configuration file, and from that, the queue directories | ||
47 | + my @queuedirs=(); | ||
48 | + my $configfile=""; | ||
49 | + if ( defined($opt_f) && -r $opt_f ) { | ||
50 | + $configfile="-C$opt_f"; | ||
51 | + @queuedirs=get_queue_directories($opt_f); | ||
52 | + }else { | ||
53 | + @queuedirs=get_queue_directories(); | ||
54 | + } | ||
55 | + | ||
56 | + if (!defined($queuedirs[0])) { | ||
57 | + print "UNKNOWN: check_mailq: no queue directories | msq_q = 0\n"; | ||
58 | + exit $ERRORS{"UNKNOWN"}; | ||
59 | + } | ||
60 | + my $qpattern=join("|",@queuedirs); | ||
61 | + | ||
62 | ## open mailq | ||
63 | if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) { | ||
64 | if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) { | ||
65 | @@ -163,21 +180,16 @@ | ||
66 | |||
67 | # Finally look at the overall queue length | ||
68 | # | ||
69 | - if (/mqueue/) { | ||
70 | + # the pattern helps us get one or more queue directories, and adds up | ||
71 | + # all the requests | ||
72 | + if (/\b$qpattern\b/) { | ||
73 | print "$utils::PATH_TO_MAILQ = $_ "if $verbose ; | ||
74 | - if (/ \((\d+) request/) { | ||
75 | - # | ||
76 | - # single queue: first line | ||
77 | - # multi queue: one for each queue. overwrite on multi queue below | ||
78 | - $msg_q = $1 ; | ||
79 | + if (/empty/) { | ||
80 | + }elsif (/\((\d+)\s*requests\)/i) { | ||
81 | + $msg_q+=$1; | ||
82 | + print "size = $1, msg_q = $msg_q warn=$opt_w crit=$opt_c\n" if $verbose; | ||
83 | } | ||
84 | - } elsif (/^\s+Total\sRequests:\s(\d+)$/) { | ||
85 | - print "$utils::PATH_TO_MAILQ = $_ \n" if $verbose ; | ||
86 | - # | ||
87 | - # multi queue: last line | ||
88 | - $msg_q = $1 ; | ||
89 | } | ||
90 | - | ||
91 | } | ||
92 | |||
93 | |||
94 | @@ -519,7 +531,8 @@ | ||
95 | "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number | ||
96 | "W=i" => \$opt_W, "Warning=i" => \$opt_W, # warning if above this number | ||
97 | "C=i" => \$opt_C, "Critical=i" => \$opt_C, # critical if above this number | ||
98 | - "t=i" => \$opt_t, "timeout=i" => \$opt_t | ||
99 | + "t=i" => \$opt_t, "timeout=i" => \$opt_t, | ||
100 | + "f=s" => \$opt_f, "configfile" => \$opt_f | ||
101 | ); | ||
102 | |||
103 | if ($opt_V) { | ||
104 | @@ -572,12 +585,19 @@ | ||
105 | }else{ | ||
106 | $mailq = 'sendmail' ; | ||
107 | } | ||
108 | + | ||
109 | + if (defined $opt_f) { | ||
110 | + if (! -r $opt_f) { | ||
111 | + print "Can't read config file (-f): $opt_f!W\n"; | ||
112 | + exit $ERRORS{'UNKNOWN'}; | ||
113 | + } | ||
114 | + } | ||
115 | |||
116 | return $ERRORS{'OK'}; | ||
117 | } | ||
118 | |||
119 | sub print_usage () { | ||
120 | - print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose]\n"; | ||
121 | + print "Usage: $PROGNAME -w <warn> -c <crit> [-W <warn>] [-C <crit>] [-M <MTA>] [-t <timeout>] [-v verbose] [-f configfile]\n"; | ||
122 | } | ||
123 | |||
124 | sub print_help () { | ||
125 | @@ -594,6 +614,7 @@ | ||
126 | print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; | ||
127 | print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; | ||
128 | print "-M (--mailserver) = [ sendmail | qmail | postfix | exim ] (default = sendmail)\n"; | ||
129 | + print "-f (--configfile) = configuration file for sendmail (default = $utils::PATH_TO_SENDMAIL_CF)\n"; | ||
130 | print "-h (--help)\n"; | ||
131 | print "-V (--version)\n"; | ||
132 | print "-v (--verbose) = debugging output\n"; | ||
133 | @@ -608,3 +629,45 @@ | ||
134 | print "\n\n"; | ||
135 | support(); | ||
136 | } | ||
137 | + | ||
138 | +sub get_queue_directories (;$) | ||
139 | +{ | ||
140 | + my $cfin=shift; | ||
141 | + my @cfs=(); | ||
142 | + my @qdirs=(); | ||
143 | + | ||
144 | + if ($cfin) { | ||
145 | + @cfs=($cfin); | ||
146 | + }else { | ||
147 | + if (-r $utils::PATH_TO_SENDMAIL_CF) { | ||
148 | + @cfs=($utils::PATH_TO_SENDMAIL_CF); | ||
149 | + }else { | ||
150 | + @cfs=qw(/etc/mail/sendmail.cf); | ||
151 | + } | ||
152 | + } | ||
153 | + | ||
154 | + my @cffiles=grep { -r $_} @cfs; | ||
155 | + if (scalar(@cffiles)==0) { | ||
156 | + warn "unable to find a sendmail configuration file"; | ||
157 | + return (undef); | ||
158 | + } | ||
159 | + | ||
160 | + my $qdir; | ||
161 | + foreach my $cf (@cffiles) { | ||
162 | + if (open(CF,$cf)) { | ||
163 | + while(<CF>) { | ||
164 | + chomp; | ||
165 | + next unless (/^O\s*QueueDirectory=(.*)$/ && ($qdir=$1)); | ||
166 | + push(@qdirs,bsd_glob($qdir)); | ||
167 | + last; | ||
168 | + } | ||
169 | + } | ||
170 | + close(CF); | ||
171 | + } | ||
172 | + | ||
173 | + if (@qdirs==0) { | ||
174 | + warn "no QueueDirectory variable found in sendmail configuration file"; | ||
175 | + return (undef); | ||
176 | + }; | ||
177 | + return @qdirs; | ||
178 | +} | ||