Lines 1-442
Link Here
|
1 |
--- stats.sh.orig 2009-01-29 13:19:18.000000000 -0500 |
|
|
2 |
+++ stats.sh 2009-01-29 20:27:14.000000000 -0500 |
3 |
@@ -1,15 +1,23 @@ |
4 |
#!/bin/sh |
5 |
|
6 |
+# This version of the script is heavily modified from the now |
7 |
+# unsupported original. |
8 |
+# |
9 |
+# This version by: |
10 |
+# J.R. Oldroyd <fbsd@opal.com> |
11 |
+# FreeBSD port maintained for ASSP |
12 |
+# |
13 |
+ |
14 |
# As a shell script (running on Unix...) it expects to find the local |
15 |
# copy of your standard Unix shell, the 'tail' utility and a working 'awk' |
16 |
# interpreter. |
17 |
|
18 |
-# I use the default location for ASSP's maillog file, and the 'maillog.log' |
19 |
+# I use the default location for ASSP's maillog file, and the 'maillog.txt' |
20 |
# name (in assp.cfg) to keep ASSP from changing it on me. |
21 |
|
22 |
-# This script attempts to go back at least 300 lines in your maillog.log |
23 |
+# This script attempts to go back at least 300 lines in your maillog.txt |
24 |
# file to give you a nice screenful of goodies to review when it |
25 |
-# first starts. If your maillog.log is nearly empty, then just |
26 |
+# first starts. If your maillog.txt is nearly empty, then just |
27 |
# be patient. As things happen - the logger will reveal it in COLOR! |
28 |
# ------------------------------------ KRL ------------------------- |
29 |
|
30 |
@@ -27,14 +35,7 @@ |
31 |
# order to give you a full screen on startup. Also, it assumes |
32 |
# ANSI Color mode for your screen to display the lines in color. |
33 |
# |
34 |
-# BS (in Red) lines are those caught by the Bayesian filter !! |
35 |
-# LW (in White .. mostly) are those Local or Whitelisted eMails |
36 |
-# Ok (in Green) are eMail that fully pass alltests without exceptions. |
37 |
-# RB (in Cyan) .. Blocked Relay attempt |
38 |
-# WL+ Whitelist ADDITION by an authorized local user |
39 |
-# BA (in Cyan) .. Bad ATTACHEMENT rejected |
40 |
-# SR (in Cyan) .. spam@ report submission |
41 |
-# NS (in Cyan) .. notspam@ report submission |
42 |
+# See "man assplog" for a description of the fields and coloring. |
43 |
# |
44 |
# I got the idea for this script from Mark Constable. He submitted |
45 |
# a similar script to follow the Courier-MTA /var/log/maillog |
46 |
@@ -46,91 +47,315 @@ |
47 |
# Some fields are truncated (with a hard-coded length value, usually 40) |
48 |
# to keep each line more or less intact on your screen as things scroll by |
49 |
# Colors are coded with ANSI Color coding, your mileage may vary ... |
50 |
-# I assume the naming convention of 'maillog.log' so ASSP won't munge |
51 |
+# I assume the naming convention of 'maillog.txt' so ASSP won't munge |
52 |
# each current log into some difficult-to-grok name. You should try |
53 |
# to use this feature - and perhaps roll the log periodically with |
54 |
# your system's 'newsyslog' functionality. You can send a SIGHUP to |
55 |
# ASSP when you roll the log so it starts afresh..KRL |
56 |
|
57 |
-tail -300 -f /usr/local/assp/maillog.log | \ |
58 |
- awk ' \ |
59 |
- /whitelisted/ { \ |
60 |
- printf("%s %s \033[1;32m%-15s L\033[0mW %s \033[1;32m->\033[0m %s\n", \ |
61 |
- substr($1,1,length($1)), \ |
62 |
- substr($2,1,length($2)), \ |
63 |
- substr($3,1,length($3)), \ |
64 |
- substr($4,1,40), \ |
65 |
- substr($6,1,length($6)) )\ |
66 |
- } \ |
67 |
- /email/ && /whitelist addition/ { \ |
68 |
- printf("%s %s \033[1;32m%-15s W\033[0mA+ %s \033[1;32m->\033[0m %s\n", \ |
69 |
- substr($1,1,length($1)), \ |
70 |
- substr($2,1,length($2)), \ |
71 |
- "+email address+", \ |
72 |
- substr($4,1,40), \ |
73 |
- substr($6,1,length($6)) )\ |
74 |
- } \ |
75 |
- /whitelist addition/ && !/email/ { \ |
76 |
- printf("%s %s \033[1;32m%-15s W\033[0mL+ %s \033[1;32m %s %s\033[0m\n", \ |
77 |
- substr($1,1,length($1)), \ |
78 |
- substr($2,1,length($2)), \ |
79 |
- substr($3,1,length($3)), \ |
80 |
- substr($4,1,40), \ |
81 |
- "-adds-", \ |
82 |
- substr($9,1,length($9)) )\ |
83 |
- } \ |
84 |
- /Bayesian spam/ { \ |
85 |
- printf("%s %s \033[1;31m%-15s BS %s -> %s\033[0m\n", \ |
86 |
- substr($1,1,length($1)), \ |
87 |
- substr($2,1,length($2)), \ |
88 |
- substr($3,1,length($3)), \ |
89 |
- substr($4,1,40), \ |
90 |
- substr($6,1,length($6)) )\ |
91 |
- } \ |
92 |
- /message ok/ { \ |
93 |
- printf("%s %s \033[1;32m%-15s Ok %s -> %s\033[0m\n", \ |
94 |
- substr($1,1,length($1)), \ |
95 |
- substr($2,1,length($2)), \ |
96 |
- substr($3,1,length($3)), \ |
97 |
- substr($4,1,40), \ |
98 |
- substr($6,1,length($6)) )\ |
99 |
- } \ |
100 |
- /bad attachment/ { \ |
101 |
- printf("%s %s \033[1;35m%-15s BA %s -> %s\033[0m\n", \ |
102 |
- substr($1,1,length($1)), \ |
103 |
- substr($2,1,length($2)), \ |
104 |
- substr($3,1,length($3)), \ |
105 |
- substr($4,1,40), \ |
106 |
- substr($6,1,length($6)) )\ |
107 |
- } \ |
108 |
- /relay attempt blocked/ { \ |
109 |
- printf("%s %s \033[1;35m%-15s RB %s -> %s %s %s %s %s\033[0m\n", \ |
110 |
- substr($1,1,length($1)), \ |
111 |
- substr($2,1,length($2)), \ |
112 |
- substr($3,1,length($3)), \ |
113 |
- substr($4,1,length($4)), \ |
114 |
- substr($5,1,length($5)), \ |
115 |
- substr($6,1,length($6)), \ |
116 |
- substr($7,1,length($7)), \ |
117 |
- substr($8,1,length($8)), \ |
118 |
- substr($9,1,length($9)) )\ |
119 |
- } \ |
120 |
- /Admin update:/ { \ |
121 |
- printf("\033[1;33m%s %s %s %s %s %s \033[0m\n", $1, $2, $3, $4, $5, $6) \ |
122 |
- } \ |
123 |
- /Email spamreport/ { \ |
124 |
- printf("%s %s\033[0;36m %-15s SR %s Email SPAM Submission\033[0m\n", \ |
125 |
- substr($1,1,length($1)), \ |
126 |
- substr($2,1,length($2)), \ |
127 |
- substr($3,1,length($3)), \ |
128 |
- substr($4,1,length($4)) ) \ |
129 |
- } \ |
130 |
- /Email hamreport/ { \ |
131 |
- printf("%s %s\033[0;36m %-15s NS %s Email NOTSPAM Submission\033[0m\n", \ |
132 |
- substr($1,1,length($1)), \ |
133 |
- substr($2,1,length($2)), \ |
134 |
- substr($3,1,length($3)), \ |
135 |
- substr($4,1,length($4)) ) \ |
136 |
- }' |
137 |
+tail -300 -f /var/db/assp/maillog.txt | awk ' |
138 |
+ { |
139 |
+ # skip over "[reason]" fields |
140 |
+ p=0 |
141 |
+ if ($(p+4) ~ /\[.*]/) p++ |
142 |
+ } |
143 |
+ /\[Local]|\[Whitelisted]|local or whitelisted/ { |
144 |
+ printf("%s %s \033[1;32m%-15s\033[0m \033[1;37mLW %s\033[0m \033[1;32m->\033[0m \033[1;37m%s\033[0m\n", |
145 |
+ $1, |
146 |
+ $2, |
147 |
+ $(p+4), |
148 |
+ substr($(p+5),1,40), |
149 |
+ $(p+7) ) |
150 |
+ next |
151 |
+ } |
152 |
+ /[Em]ail whitelist (addition|deletion):*/ { |
153 |
+ if (/(addition|deletion)$/) |
154 |
+ next |
155 |
+ printf("%s %s \033[1;36m%-15s\033[0m \033[1;36mW%s %s\033[0m \033[1;37m%s\033[0m \033[1;36m%s\033[0m\n", |
156 |
+ $1, |
157 |
+ $2, |
158 |
+ $(p+4), |
159 |
+ (/addition:/) ? "+" : "-", |
160 |
+ substr($(p+5),1,40), |
161 |
+ (/addition:/) ? "-adds-" : "-deletes-", |
162 |
+ $(p+9) ) |
163 |
+ next |
164 |
+ } |
165 |
+ /whitelist addition:/ && !/[Ee]mail/ { |
166 |
+ printf("%s %s \033[1;36m%-15s\033[0m \033[1;36mWC %s\033[0m \033[1;37m%s\033[0m \033[1;36m%s\033[0m\n", |
167 |
+ $1, |
168 |
+ $2, |
169 |
+ $(p+4), |
170 |
+ substr($(p+5),1,40), |
171 |
+ "-adds-", |
172 |
+ $(p+10) ) |
173 |
+ next |
174 |
+ next |
175 |
+ } |
176 |
+ /[Ee]mail (hamreport|help|spamreport|redlist)/ { |
177 |
+ printf("%s %s\033[1;36m %-15s EM %s %s%s\033[0m\n", |
178 |
+ $1, |
179 |
+ $2, |
180 |
+ $(p+4), |
181 |
+ $(p+5), |
182 |
+ $(p+7), |
183 |
+ ($(p+8)) ? " " $(p+8) : "" ) |
184 |
+ next |
185 |
+ } |
186 |
+ /Bayesian Check (- )?Prob/ { |
187 |
+ # suppress |
188 |
+ next |
189 |
+ } |
190 |
+ /\[Bayesian]|Bayesian [Ss]pam/ { |
191 |
+ printf("%s %s \033[1;31m%-15s BS %s -> %s\033[0m\n", |
192 |
+ $1, |
193 |
+ $2, |
194 |
+ $(p+4), |
195 |
+ substr($(p+5),1,40), |
196 |
+ $(p+7) ) |
197 |
+ next |
198 |
+ } |
199 |
+ /recipient accepted/ { |
200 |
+ # suppress |
201 |
+ next |
202 |
+ } |
203 |
+ /\[MessageOK]|message ok/ { |
204 |
+ printf("%s %s \033[1;32m%-15s OK %s -> %s\033[0m\n", |
205 |
+ $1, |
206 |
+ $2, |
207 |
+ $(p+4), |
208 |
+ substr($(p+5),1,40), |
209 |
+ $(p+7) ) |
210 |
+ next |
211 |
+ } |
212 |
+ /bad attachment/ && !/no bad/ { |
213 |
+ printf("%s %s \033[1;35m%-15s BA %s -> %s\033[0m\n", |
214 |
+ $1, |
215 |
+ $2, |
216 |
+ $(p+4), |
217 |
+ substr($(p+5),1,40), |
218 |
+ $(p+7) ) |
219 |
+ next |
220 |
+ } |
221 |
+ /relay attempt blocked/ { |
222 |
+ printf("%s %s \033[1;35m%-15s RB %s -> %s\033[0m\n", |
223 |
+ $1, |
224 |
+ $2, |
225 |
+ $(p+4), |
226 |
+ substr($(p+5),1,40), |
227 |
+ ($(p+10) ~ /^(.*):$/) ? $(p+11) : $(p+10) ) |
228 |
+ next |
229 |
+ } |
230 |
+ /no recipients left -- dropping connection/ { |
231 |
+ # suppress |
232 |
+ next |
233 |
+ } |
234 |
+ /[Ii]nvalid address rejected/ { |
235 |
+ printf("%s %s \033[1;34m%-15s IR %s -> %s\033[0m\n", |
236 |
+ $1, |
237 |
+ $2, |
238 |
+ $(p+4), |
239 |
+ substr($(p+5),1,40), |
240 |
+ $NF ) |
241 |
+ next |
242 |
+ } |
243 |
+ /malformed address/ { |
244 |
+ printf("%s %s \033[1;35m%-15s MA %s -> %s\033[0m\n", |
245 |
+ $1, |
246 |
+ $2, |
247 |
+ $(p+4), |
248 |
+ substr($(p+5),1,40), |
249 |
+ $(p+8) ) |
250 |
+ next |
251 |
+ } |
252 |
+ /\[InvalidLocalSender]|Unknown Sender (with|from) Local Domain/ { |
253 |
+ printf("%s %s \033[1;34m%-15s IS %s\033[0m\n", |
254 |
+ $1, |
255 |
+ $2, |
256 |
+ $(p+4), |
257 |
+ substr($(p+5),1,40) ) |
258 |
+ next |
259 |
+ } |
260 |
+ /(Commencing|Completed) (R|DNS|URI)BL checks/ { |
261 |
+ # suppress |
262 |
+ next |
263 |
+ } |
264 |
+ /((DNS|URI)BL )?Received-(R|DNS|URI)BL: (pass|neutral|fail)|URIBL fail|Bayesian Check URIBL/ { |
265 |
+ # suppress |
266 |
+ next |
267 |
+ } |
268 |
+ /failed (DNS|URI)BL|failed (R|URI)BL checks|Received-RBL: fail/ { |
269 |
+ printf("%s %s \033[1;35m%-15s BL %s -> %s\033[0m\n", |
270 |
+ $1, |
271 |
+ $2, |
272 |
+ $(p+4), |
273 |
+ substr($(p+5),1,40), |
274 |
+ $(p+7) ) |
275 |
+ next |
276 |
+ } |
277 |
+ /(\[DNSBL]|\[DNSBLcache]).* (listed|rejected) by / { |
278 |
+ printf("%s %s \033[1;35m%-15s BL %s (%s blacklisted by %s)\033[0m\n", |
279 |
+ $1, |
280 |
+ $2, |
281 |
+ $(p+4), |
282 |
+ substr($(p+5),1,40), |
283 |
+ /listed/ ? $(p+11) : $(p+7), |
284 |
+ /listed/ ? $(p+14) : $(p+10) ) |
285 |
+ next |
286 |
+ } |
287 |
+ /\[SPF] .* SPF: (unknown|pass|neutral)|\[SPF] .*\(SPF neutral\)|Received-SPF(\(cache\))?: (pass|neutral)| SPF: (soft)?fail|SPFstrict/ { |
288 |
+ # suppress |
289 |
+ next |
290 |
+ } |
291 |
+ /failed SPF checks|Received-SPF(\(cache\))?: ((soft)?fail|error)/ { |
292 |
+ printf("%s %s \033[1;35m%-15s SP %s -> %s\033[0m\n", |
293 |
+ $1, |
294 |
+ $2, |
295 |
+ $(p+4), |
296 |
+ substr($(p+5),1,40), |
297 |
+ $(p+7) ) |
298 |
+ next |
299 |
+ } |
300 |
+ /\[ForgedHELO]|has spam helo|HELO-Blacklist:/ { |
301 |
+ printf("%s %s \033[1;35m%-15s HL %s -> %s %s\033[0m\n", |
302 |
+ $1, |
303 |
+ $2, |
304 |
+ $(p+4), |
305 |
+ substr($(p+5),1,40), |
306 |
+ /found]/ ? "" : $(p+7), |
307 |
+ /found]/ ? "(" $(p+10) : $(p+11) ) |
308 |
+ next |
309 |
+ } |
310 |
+ /Forged HELO:/ { |
311 |
+ printf("%s %s \033[1;35m%-15s HL %s -> %s\033[0m\n", |
312 |
+ $1, |
313 |
+ $2, |
314 |
+ $(p+4), |
315 |
+ substr($(p+5),1,40), |
316 |
+ $(p+8) ) |
317 |
+ next |
318 |
+ } |
319 |
+ /Sender Validation:blocked:/ { |
320 |
+ printf("%s %s \033[1;35m%-15s HL %s %s\033[0m\n", |
321 |
+ $1, |
322 |
+ $2, |
323 |
+ $(p+4), |
324 |
+ substr($(p+5),1,40), |
325 |
+ $(p+10) ) |
326 |
+ next |
327 |
+ } |
328 |
+ /(adding new|embargoing|accepting|whitelisting) triplet|(renewing|renewing whitelisted|deleting spamming whitelisted) tuplet/ { |
329 |
+ # suppress |
330 |
+ next |
331 |
+ } |
332 |
+ /(recipient|bounce) delayed/ { |
333 |
+ printf("%s %s \033[1;35m%-15s DL %s -> %s\033[0m\n", |
334 |
+ $1, |
335 |
+ $2, |
336 |
+ $(p+4), |
337 |
+ substr($(p+5),1,40), |
338 |
+ /bounce|to:/ ? $(p+7) : $(p+8) ) |
339 |
+ next |
340 |
+ } |
341 |
+ /DATA phase delayed/ { |
342 |
+ # suppress |
343 |
+ next |
344 |
+ } |
345 |
+ /(Admin (update:|connection from ))|AdminUpdate:/ { |
346 |
+ printf("\033[1;33m%s\033[0m\n", $0) |
347 |
+ next |
348 |
+ } |
349 |
+ /ClamAV: .* - OK $/ { |
350 |
+ # suppress |
351 |
+ next |
352 |
+ } |
353 |
+ /virus detected/ { |
354 |
+ printf("%s %s\033[1;35m %-15s VI %s -> %s (%s)\033[0m\n", |
355 |
+ $1, |
356 |
+ $2, |
357 |
+ $(p+4), |
358 |
+ $(p+5), $(p+7), $(p+10) ) |
359 |
+ next |
360 |
+ } |
361 |
+ /Message-Score:/ { |
362 |
+ # suppress |
363 |
+ next |
364 |
+ } |
365 |
+ /PB:.*score: [0-9]+\+[0-9]+ => [0-9]+ reason:|PB-Message-Score|PB-IP-Score|\[scoring]/ { |
366 |
+ # suppress |
367 |
+ next |
368 |
+ } |
369 |
+# /PB:( deleting\(black\)/ { |
370 |
+# printf("%s %s\033[1;35m %-15s PB %s %s %s %s (%s)\033[0m\n", |
371 |
+# $1, |
372 |
+# $2, |
373 |
+# $(p+4), |
374 |
+# $(p+8), $(p+9), $(p+10), $(p+11), |
375 |
+# substr($(p+12),8,40) ) |
376 |
+# next |
377 |
+# } |
378 |
+ /PBextreme |PBextreme:monitoring/ { |
379 |
+ printf("%s %s\033[1;35m %-15s PB %s extreme %s\033[0m\n", |
380 |
+ $1, |
381 |
+ $2, |
382 |
+ $(p+4), |
383 |
+ substr($(p+5),1,40), |
384 |
+ $(p+7) ) |
385 |
+ next |
386 |
+ } |
387 |
+ /(\[ValidHelo]|\[InvalidHelo]|\[PTRinvalid]|\[PTRmissing])\[scoring]/ { |
388 |
+ # suppress |
389 |
+ next |
390 |
+ } |
391 |
+ /\[MessageLimit]|Message Limit/ { |
392 |
+ printf("%s %s\033[1;35m %-15s PB %s -> %s\033[0m\n", |
393 |
+ $1, |
394 |
+ $2, |
395 |
+ $(p+4), |
396 |
+ substr($(p+5),1,40), |
397 |
+ substr($(p+7),1,40) ) |
398 |
+ next |
399 |
+ } |
400 |
+ /max errors \([0-9]+\) exceeded/ { |
401 |
+ printf("%s %s\033[1;35m %-15s ME %s\033[0m\n", |
402 |
+ $1, |
403 |
+ $2, |
404 |
+ $(p+4), |
405 |
+ substr($(p+5),1,40) ) |
406 |
+ next |
407 |
+ } |
408 |
+ /Message proxied without processing/ { |
409 |
+ # suppress |
410 |
+ next |
411 |
+ } |
412 |
+ /message proxied without processing/ { |
413 |
+ printf("%s %s \033[1;32m%-15s NP %s -> %s\033[0m\n", |
414 |
+ $1, |
415 |
+ $2, |
416 |
+ $(p+4), |
417 |
+ substr($(p+5),1,40), |
418 |
+ $(p+7) ) |
419 |
+ next |
420 |
+ } |
421 |
+ /Regex:(Black|NoProcessingDomain)/ { |
422 |
+ # suppress |
423 |
+ next |
424 |
+ } |
425 |
+ /invalid remote sender for internal address/ { |
426 |
+ printf("%s %s \033[1;35m%-15s IO %s -> %s\033[0m\n", |
427 |
+ $1, |
428 |
+ $2, |
429 |
+ $(p+4), |
430 |
+ $(p+5), |
431 |
+ substr($(p+12),1,40) ) |
432 |
+ next |
433 |
+ } |
434 |
+ { |
435 |
+ printf("%s %s ", $1, $2) |
436 |
+ for (i=3; i<=NF; i++) |
437 |
+ printf("\033[1;30m%s\033[0m ", $i) |
438 |
+ printf("\n") |
439 |
+ } |
440 |
+ ' |
441 |
# end of script |
442 |
|