3
# $Log: spamstats.in,v $
4
# Revision 1.1 2004/01/02 18:50:00 jimmyo
5
# Renamed occurrances of lrrd -> munin
7
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
8
# Import of LRRD CVS tree after renaming to Munin
10
# Revision 1.1 2003/11/10 18:51:50 jimmyo
15
$statefile = $ENV{statefile} || "@@PLUGSTATE@@/munin-spamstats.state";
20
$logfile = $ENV{logdir} || "/var/log/";
21
$logfile .= $ENV{logfile} || "syslog";
25
$rotlogfile = $logfile . ".0";
27
elsif (-f "$logfile.1")
29
$rotlogfile = $logfile . ".1";
31
elsif (-f "$logfile.01")
33
$rotlogfile = $logfile . ".01";
37
$rotlogfile = $logfile . ".0";
40
if ( $ARGV[0] and $ARGV[0] eq "config" )
42
print "host_name $ENV{FQDN}\n";
43
print "graph_title SpamAssassin throughput\n";
44
print "graph_args --base 1000 -v mails/min -l 0\n";
45
print "graph_order ham spam\n";
46
print "ham.label ham\n";
47
print "ham.type COUNTER\n";
48
print "ham.draw AREA\n";
49
print "ham.cdef ham,60,*\n";
50
print "spam.label spam\n";
51
print "spam.type COUNTER\n";
52
print "spam.cdef spam,60,*\n";
53
print "spam.draw STACK\n";
57
if (! -f $logfile and ! -f $rotlogfile)
59
print "ham.value U\n";
60
print "spam.value U\n";
66
open (IN, "$statefile") or exit 4;
67
if (<IN> =~ /^(\d+):(\d+):(\d+)/)
69
($pos, $ham, $spam) = ($1, $2, $3);
74
$startsize = (stat $logfile)[7];
82
if ($startsize < $pos)
85
parselogfile ($rotlogfile, $pos, (stat $rotlogfile)[7]);
89
parselogfile ($logfile, $pos, $startsize);
92
print "ham.value $ham\n";
93
print "spam.value $spam\n";
95
open (OUT, ">$statefile") or exit 4;
96
print OUT "$pos:$ham:$spam\n";
101
my ($fname, $start, $stop) = @_;
102
open (LOGFILE, $fname) or exit 3;
103
seek (LOGFILE, $start, 0) or exit 2;
105
while (tell (LOGFILE) < $stop)
110
if ($line =~ m/clean message/)
114
elsif ($line =~ m/identified spam/)