Skip to content

Commit

Permalink
Added two new plugins contributed by Jacques Caruso, generic/exim_mai…
Browse files Browse the repository at this point in the history
…lqueue_alt and generic/mailscanner.
  • Loading branch information
jomono committed Dec 9, 2004
1 parent 8e93fb5 commit fe52ddc
Show file tree
Hide file tree
Showing 4 changed files with 173 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog
Expand Up @@ -21,6 +21,8 @@ munin (work)
* Plugin: linux/fw_forwarded_local now initialises properly (Deb#284673).
* Plugin: Added more sensible autoconf to generic/sybase_space.
* Plugin: Added more sensible autoconf to generic/munin_graph,munin_update.
* Plugin: Added two new plugins contributed by Jacques Caruso,
generic/exim_mailqueue_alt and generic/mailscanner.

munin (1.1.7)

Expand Down
5 changes: 4 additions & 1 deletion node/munin-node.in
Expand Up @@ -20,6 +20,9 @@
# $Id$
#
# $Log$
# Revision 1.19 2004/12/09 20:03:25 jimmyo
# Added two new plugins contributed by Jacques Caruso, generic/exim_mailqueue_alt and generic/mailscanner.
#
# Revision 1.18 2004/12/09 19:34:54 jimmyo
# host_name in plugin-conf.d now overrides plugin output.
#
Expand Down Expand Up @@ -785,7 +788,7 @@ sub get_var_arr
{
(my $tmpservice = $wildservice) =~ s/\*$//;
next unless ($name =~ /^$tmpservice/);
print STDERR "Checking $wildservice...\n" if $DEBUG;
print STDERR "# Checking $wildservice...\n" if $DEBUG;

if (defined $sconf->{$wildservice}{$var})
{
Expand Down
65 changes: 65 additions & 0 deletions node/node.d/exim_mailqueue_alt.in
@@ -0,0 +1,65 @@
#!/bin/bash
#
# Plugin to monitor Exim's mail queue
#
# Usage: Link into /etc/munin/plugins/
#
# Requirements:
#
# Needs to be run as user mail
#
# Parameters:
#
# config (required)
#
# Configurable variables:
#
# exim - exim binary location
# queuewarn - warning limit
# queuecrit - critical limit
#
# $Log$
# Revision 1.1 2004/12/09 20:03:26 jimmyo
# Added two new plugins contributed by Jacques Caruso, generic/exim_mailqueue_alt and generic/mailscanner.
#
#
# Magic markers:
#%# family=contrib
#%# capabilities=

PATH='/bin:/sbin:/usr/bin:/usr/sbin'
EXIM=`which exim 2>/dev/null || which exim4 2>/dev/null`
QUEUEWARN=100
QUEUECRIT=200

[ "$exim" ] && EXIM=$exim
[ "$queuewarn" ] && QUEUEWARN=$queuewarn
[ "$queuecrit" ] && QUEUECRIT=$queuecrit

if [ "$1" == "config" ]; then
echo 'graph_title Exim mailqueue'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel mails in queue'
echo 'graph_category exim'
echo 'active.label active'
echo 'active.draw LINE2'
echo 'bounced.label bounced'
echo 'bounced.draw LINE2'
echo 'frozen.label frozen'
echo 'frozen.draw LINE2'
echo 'total.label total'
echo 'total.draw LINE2'
echo "total.warning $QUEUEWARN"
echo "total.critical $QUEUECRIT"
exit 0
fi

ACTIVE=`$EXIM -bpr | grep -Ev '(^\ \ |^$|<>|frozen)' | wc -l`
BOUNCED=`$EXIM -bpr | awk '{print $4}' | grep '<>' | wc -l`
FROZEN=`$EXIM -bpr | awk '{print $6}' | grep frozen | wc -l`
TOTAL=`$EXIM -bpc`

echo "active.value $ACTIVE"
echo "bounced.value $BOUNCED"
echo "frozen.value $FROZEN"
echo "total.value $TOTAL"
102 changes: 102 additions & 0 deletions node/node.d/mailscanner.in
@@ -0,0 +1,102 @@
#!@@PERL@@ -w
#
# Graphs statistics for e-mails passing through a MailScanner filter
#
# Usage: Link into /etc/munin/plugins/
#
# Requirements:
#
# The logtail command
#
# Parameters supported:
#
# config (required)
#
# Configurable variables:
#
# logfile - The file where MailScanner logs its action (default: /var/log/mail.log)
# logtail - The location of the logtail command (default: /usr/sbin/logtail)
# offsetfile - The location of the offset file (default: /tmp/lrrd-mailscanner.offset)
#
# Bugs:
#
# None known
#
# $Log$
# Revision 1.1 2004/12/09 20:03:26 jimmyo
# Added two new plugins contributed by Jacques Caruso, generic/exim_mailqueue_alt and generic/mailscanner.
#
#
# Magic markers:
#%# family=contrib
#%# capabilities=

use strict;

my $logfile = '/var/log/mail.log';
my $logtail = '/usr/sbin/logtail';
my $offsetfile = '/tmp/lrrd-mailscanner.offset';
my ($clean, $viruses, $spams, $others, $total) = (0, 0, 0, 0, 0);
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';

(defined($ENV{'logfile'})) and $logfile = $ENV{'logfile'};
(defined($ENV{'logtail'})) and $logtail = $ENV{'logtail'};
(defined($ENV{'offsetfile'})) and $offsetfile = $ENV{'offsetfile'};

if ($cmd eq 'config') {
print("graph_title MailScanner statistics\n");
print("graph_args --lower-limit 0\n");
print("graph_vlabel messages\n");
print("clean.label clean\n");
print("clean.type GAUGE\n");
print("clean.draw LINE2\n");
print("viruses.label viruses\n");
print("viruses.type GAUGE\n");
print("viruses.draw LINE2\n");
print("spams.label spams\n");
print("spams.type GAUGE\n");
print("spams.draw LINE2\n");
print("others.label others\n");
print("others.type GAUGE\n");
print("others.draw LINE2\n");
print("total.label total\n");
print("total.type GAUGE\n");
print("total.draw LINE2\n");

exit(0);
}

my @lines = split(/\n/, qx($logtail -f $logfile -o $offsetfile));
foreach (@lines) {
SWITCH: {
if (/New Batch: S/) {
s/.*New Batch: Scanning ([0-9]+) messages.*/$1/;
$total += $_;
last SWITCH;
}
if (/Virus Scanning: F/) {
s/.*Virus Scanning: Found ([0-9]+) viruses.*/$1/g;
$viruses += $_;
last SWITCH;
}
if (/Spam Checks: F/) {
s/.*Spam Checks: Found ([0-9]+) spam.*/$1/g;
$spams += $_;
last SWITCH;
}
if (/Other Checks: F/) {
s/.*Other Checks: Found ([0-9]+) problems.*/$1/g;
$others += $_;
last SWITCH;
}
}
}
$clean = $total - ($viruses + $spams + $others);

print("clean.value $clean\n");
print("viruses.value $viruses\n");
print("spams.value $spams\n");
print("others.value $others\n");
print("total.value $total\n");

exit(0);

0 comments on commit fe52ddc

Please sign in to comment.