Joseph Young
involved.com
SystemAdmin
Quick notes on running spamassassin from daemontools and patching
qmailmrtg7 for mrtg
Once you have spamassassin working
add /var/qmail/supervise/spamassassin/run
-----
#!/bin/sh
exec /usr/bin/spamd -x -q -u qmailq -s\
stderr 2>&1 | multilog t s10000000000 n20 /var/log/spamassassin/
------
ln -s /var/qmail/supervise/spamassassin/ spamassassin
MRTG
---
Title[spam]: Spam Email
MaxBytes[spam]: 5000
AbsMax[spam]: 10000
Options[spam]: gauge,nopercent,dorelpercent
Target[spam]: `/usr/local/bin/qmailmrtg7 f /var/log/spamassassin`
PageTop[spam]: <H1>Spam Email</H1> <P>We assume that a Spam level > 5 is
real spam
YLegend[spam]: Spam Emails
ShortLegend[spam]: mails
Legend1[spam]: Spam
Legend2[spam]: processed mails
LegendI[spam]: Spam:
LegendO[spam]: processed:
---
QMAILMRTG7.PATCH
-------
# adds spamassassin filtering w/ multilog
diff -crN ./qmailmrtg7.c ../qmailmrtg7-3.4-joe/qmailmrtg7.c
*** ./qmailmrtg7.c Sat Jan 19 23:11:53 2002
--- ../qmailmrtg7-3.4-joe/qmailmrtg7.c Thu Mar 27 14:21:43 2003
***************
*** 40,45 ****
--- 40,46 ----
int local;
int remote;
int max_files;
+ int spam;
time_t end_time;
time_t start_time;
***************
*** 62,68 ****
if ( argc != 3 ) {
usage();
printf("usage: type dir\n");
! printf("where type is one of t, a, m, c, s, b, q \n");
printf("and dir is a directory containing multilog files\n");
printf("for q option dir is the qmail queue dir\n");
exit(-1);
--- 63,69 ----
if ( argc != 3 ) {
usage();
printf("usage: type dir\n");
! printf("where type is one of t, a, m, c, s, b, q, f\n");
printf("and dir is a directory containing multilog files\n");
printf("for q option dir is the qmail queue dir\n");
exit(-1);
***************
*** 77,82 ****
--- 78,84 ----
case 'c':
case 's':
case 'b':
+ case 'f':
case 'q':
break;
default:
***************
*** 97,102 ****
--- 99,105 ----
local = 0;
remote = 0;
max_files = 0;
+ spam = 0;
if ( TheType == 'q' ) {
***************
*** 168,173 ****
--- 171,183 ----
printf("\n");
printf("\n");
break;
+ /* spam/totalemail */
+ case 'f':
+ printf("%i\n",spam);
+ printf("%i\n",ttotal);
+ printf("\n");
+ printf("\n");
+ break;
/* bytes */
case 'b':
***************
*** 250,255 ****
--- 260,269 ----
if(strstr(TmpBuf,"success:")) success++;
if(strstr(TmpBuf,"failure:")) failure++;
break;
+ case 'f':
+ if(strstr(TmpBuf,"checking message")) ttotal++;
+ if(strstr(TmpBuf,"identified spam")) spam++;
+ break;
case 'b':
if((tmpstr1=strstr(TmpBuf,": bytes "))!=NULL) {