1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-24 18:07:20 +00:00

Category Tree: reduce number of categories

This commit is contained in:
dipohl 2017-02-22 04:48:52 +01:00
parent 84c28707eb
commit c4b2d9a8e3
22 changed files with 377 additions and 377 deletions

View file

@ -1,110 +0,0 @@
#!/bin/sh
#
# Plugin to monitor the amavis mail filter for Debian
# (based upon a plugin authored by Geoffroy Desvernay)
#
# This plugin is built and tested on Debian Etch using:
# munin 1.2.5-1
# amavisd-new 2.4.2-6.1
#
# With some minor modification it should also work on non-debian systems
# This, however, is up to you
#
# Munin graph will sum up: Passed CLEAN, Blocked VIRUS, Blocked SPAM, Other
#
# Parameters understood:
# config (required)
# autoconf (optional)
#
# Config variables:
# AMAVIS_LOG - file where amavis logs are written
# STATEFILE - file which is needed to keep track of AMAVIS_LOG
# LOGTAIL - location of logtail
# BC - location of bc
#
# Enjoy!
# Fili Wiese
#
AMAVIS_LOG=${logfile:-/var/log/mail.log}
STATEFILE=/var/lib/munin/plugin-state/amavis.offset
LOGTAIL=${logtail:-`which logtail`}
BC=${bc:-`which bc`}
mktempfile () {
mktemp
}
if [ "$1" = "autoconf" ]; then
if [ -f "${AMAVIS_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" -a -n "${BC}" -a -x "${BC}" ] ; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Amavis filter statistics'
echo 'graph_category antivirus'
echo 'graph_order total clean spam virus other'
echo 'graph_vlabel Mails filtered'
echo 'graph_scale no'
echo 'total.label Total'
echo 'total.draw AREA'
echo 'total.colour DDDDDD'
echo 'clean.label Passed CLEAN'
echo 'clean.draw LINE1'
echo 'clean.colour 32FA00'
echo 'spam.label Blocked SPAM'
echo 'spam.draw LINE1'
echo 'spam.colour FF0000'
echo 'virus.label Blocked VIRUS'
echo 'virus.draw LINE1'
echo 'virus.colour 880088'
echo 'other.label Other'
echo 'other.draw LINE1'
echo 'other.colour 0099FF'
exit 0
fi
clean=0
virus=0
spams=0
other=0
total=0
ARGS=0
`$LOGTAIL /etc/hosts 2>/dev/null >/dev/null`
if [ $? = 66 ]; then
if [ ! -n "$logtail" ]; then
ARGS=1
fi
fi
TEMP_FILE=`mktempfile munin-amavis.XXXXXX`
if [ -n "$TEMP_FILE" -a -f "$TEMP_FILE" ]
then
if [ $ARGS != 0 ]; then
$LOGTAIL ${AMAVIS_LOG} $STATEFILE | grep 'amavis\[.*\]:' | grep -v 'TIMED OUT' > ${TEMP_FILE}
else
$LOGTAIL ${AMAVIS_LOG} $STATEFILE | grep 'amavis\[.*\]:' | grep -v 'TIMED OUT' > ${TEMP_FILE}
fi
total=`cat ${TEMP_FILE} | wc -l`
clean=`grep 'CLEAN' ${TEMP_FILE} | wc -l`
virus=`grep 'INFECTED' ${TEMP_FILE} | wc -l`
spam=`grep 'Blocked SPAM' ${TEMP_FILE} | wc -l`
other=`echo ${total}-${clean}-${virus}-${other}-${spam} | ${BC}`
/bin/rm -f $TEMP_FILE
fi
echo "clean.value ${clean}"
echo "virus.value ${virus}"
echo "spam.value ${spam}"
echo "other.value ${other}"
echo "total.value ${total}"

View file

@ -1,192 +0,0 @@
#!/usr/bin/perl -w
#
# Plugin to monitor amavisd-new statistics. Values are retrieved by querying
# the BerkeleyDB database 'snmp.db', in which amavisd-new stores its
# statistics.
#
# The plugin requires the Perl module BerkeleyDB.
#
# To use, setup /etc/munin/plugin-conf.d/amavis e.g. as follows:
#
# [amavis_*]
# env.amavis_db_home /var/lib/amavis/db
# user amavis
#
# Where env.amavis_db_home is the path to the amavisd-new BerkeleyDB files
# (/var/amavis/db by default).
#
# Then create symlinks in the Munin plugin directory named "amavis_time",
# "amavis_cache" and "amavis_content", or use munin-node-configure.
#
# Parameters:
#
# config
# autoconf
# suggest
#
# Config variables:
#
# amavis_db_home - where the amavisd-new berkeley db files are located
#
# Magic markers
#%# family=auto
#%# capabilities=autoconf
#%# capabilities=suggest
use strict;
no warnings 'uninitialized';
use BerkeleyDB;
my($dbfile) = 'snmp.db';
my($db_home) = # DB databases directory
defined $ENV{'amavis_db_home'} ? $ENV{'amavis_db_home'} : '/var/amavis/db';
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
if (-x "/usr/sbin/amavisd-agent") {
print "yes\n";
exit 0;
} else {
print "no (/usr/sbin/amavisd-agent not found or not executable)\n";
exit 1;
}
} elsif ($ARGV[0] and $ARGV[0] eq "suggest") {
print "time\n";
print "cache\n";
print "content\n";
exit 0;
}
my $stats_type = "";
if ($0 =~ /^(?:|.*\/)amavis_(cache|content|time)$/) {
$stats_type = $1;
} else {
print "You need to create a symlink to this plugin called either amavis_cache, amavis_time or amavis_content to be able to use it.\n";
exit 2;
}
if ($ARGV[0] and $ARGV[0] eq "config") {
if ($stats_type eq "cache") {
print "graph_title Amavis cache hit / miss ratio\n";
print "graph_args --lower-limit 0 --upper-limit 100 --rigid\n";
print "graph_category antivirus\n";
print "graph_info The ratio of cache hits and misses for AMaViSd-new.\n";
print "graph_order hits misses\n";
print "graph_scale no\n";
print "graph_vlabel %\n";
print "hits.label Cache hits\n";
print "hits.draw AREA\n";
print "hits.max 100\n";
print "hits.min 0\n";
print "misses.label Cache misses\n";
print "misses.draw STACK\n";
print "misses.max 100\n";
print "misses.min 0\n";
} elsif ($stats_type eq "content") {
print "graph_title Amavis scanned mails\n";
print "graph_category antivirus\n";
print "graph_period minute\n";
print "graph_vlabel msgs / \${graph_period}\n";
foreach my $type (qw(total clean spam spammy virus)) {
print "$type.label " . ucfirst($type) . " mails \n";
print "$type.type DERIVE\n";
print "$type.min 0\n";
}
print "clean.info Legitimate mail.\n";
print "spammy.info Mails with a spam score above the tag2 level.\n";
print "spam.info Mails with a spam score above the kill level for spam.\n";
print "virus.info Mails with a virus.\n";
print "total.info Total number of scanned mails.\n";
} elsif ($stats_type eq "time") {
print "graph_title Amavis average scan time\n";
print "graph_info Average time spent in each phase of the mail scanning process, per mail.\n";
print "graph_category antivirus\n";
print "graph_vlabel sec / mail\n";
print "graph_scale no\n";
print "msgs.label Total number of messages\n";
print "msgs.graph no\n";
print "msgs.type DERIVE\n";
print "msgs.min 0\n";
foreach my $type (qw(decoding receiving sending spamcheck viruscheck total)) {
print "${type}.label " . ucfirst($type) . "\n";
print "${type}.type DERIVE\n";
print "${type}.min 0\n";
print "${type}.cdef ${type},1000,/,msgs,/\n";
}
}
exit 0;
}
my ($env, $db, @dbstat, $cursor);
@dbstat = stat("$db_home/$dbfile");
my $errn = @dbstat ? 0 : 0+$!;
$errn == 0 or die "stat $db_home/$dbfile: $!";
$env = BerkeleyDB::Env->new(
-Home => $db_home,
-Flags => DB_INIT_CDB | DB_INIT_MPOOL,
-ErrFile => \*STDOUT,
-Verbose => 1,
);
defined $env or die "BDB no env: $BerkeleyDB::Error $!";
$db = BerkeleyDB::Hash->new(-Filename => $dbfile, -Env => $env);
defined $db or die "BDB no db: $BerkeleyDB::Error $!";
my %values = ();
my ($eval_stat, $stat, $key, $val);
$cursor = $db->db_cursor; # obtain read lock
defined $cursor or die "db_cursor error: $BerkeleyDB::Error";
while (($stat = $cursor->c_get($key, $val, DB_NEXT)) == 0) {
$values{$key} = $val;
}
$stat == DB_NOTFOUND or die "c_get: $BerkeleyDB::Error $!";
$cursor->c_close == 0 or die "c_close error: $BerkeleyDB::Error";
$cursor = undef;
$eval_stat = $@;
if ($eval_stat ne '') { chomp($eval_stat); die "BDB $eval_stat\n"; }
for my $k (sort keys %values) {
if ($values{$k} =~ /^(?:C32|C64) (.*)\z/) {
$values{$k} = $1;
}
}
if ($stats_type eq "cache") {
my $hits = $values{'CacheHits'};
my $misses = $values{'CacheMisses'};
my $misses_ratio = $misses * 100.00 / ($hits + $misses);
my $hits_ratio = $hits * 100.00 / ($hits + $misses);
printf("hits.value %.1f\n", $hits_ratio);
printf("misses.value %.1f\n", $misses_ratio);
} elsif ($stats_type eq "content") {
printf("total.value %d\n", $values{'InMsgs'});
my $clean = $values{'ContentCleanMsgs'};
if (defined($values{'ContentCleanTagMsgs'})) {
$clean += $values{'ContentCleanTagMsgs'};
}
printf("clean.value %d\n", $clean);
printf("spam.value %d\n", $values{'ContentSpamMsgs'});
printf("spammy.value %d\n", $values{'ContentSpammyMsgs'});
printf("virus.value %d\n", $values{'ContentVirusMsgs'});
} elsif ($stats_type eq "time") {
printf("decoding.value %d\n", $values{'TimeElapsedDecoding'});
printf("receiving.value %d\n", $values{'TimeElapsedReceiving'});
printf("sending.value %d\n", $values{'TimeElapsedSending'});
printf("spamcheck.value %d\n", $values{'TimeElapsedSpamCheck'});
printf("viruscheck.value %d\n", $values{'TimeElapsedVirusCheck'});
printf("total.value %d\n", $values{'TimeElapsedTotal'});
printf("msgs.value %d\n", $values{'InMsgs'});
}
$db->db_close == 0 or die "BDB db_close error: $BerkeleyDB::Error $!";

View file

@ -1,84 +0,0 @@
#!/bin/bash
#
# Plugin to monitor Amavis virus and spam statistics.
#
#
# Based on a routine by William Towle
# Uncomment the cdef lines to convert the graph to mails/minute
# Comment out the line "total.graph no" to show the total on the graph. This may not be aesthetically pleasing.
#
# Parameters understood:
#
# config (required)
# autoconf (optional)
#
# requires logtail
LOGDIR=${logdir:-/var/log/amavis}
MAIL_LOG=$LOGDIR/${logfile:-amavisd.log}
LOGTAIL=${logtail:-`which logtail`}
STATEFILE=/var/lib/munin/plugin-state/amavis.offset
if [ "$1" = "autoconf" ]; then
if [ -f "${MAIL_LOG}" -a -n "${LOGTAIL}" -a -x "${LOGTAIL}" ] ; then
echo yes
exit 0
else
echo no
exit 1
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title Amavis message filtering'
echo 'graph_category antivirus'
echo 'graph_vlabel Mails per minute'
echo 'graph_args --base 1000 -l 0'
echo 'graph_order clean p_spam b_spam virus total'
echo 'clean.min 0'
echo 'clean.type ABSOLUTE'
#echo 'clean.cdef clean,60,*'
echo 'clean.draw AREA'
for i in p_spam b_spam virus;
do
echo "$i.min 0"
echo "$i.type ABSOLUTE";
#echo "$i.cdef $i,60,*";
echo "$i.draw STACK";
done
echo 'clean.label Passed CLEAN'
echo 'p_spam.label Passed SPAMMY'
echo 'b_spam.label Blocked SPAMMY'
echo 'virus.label Blocked INFECTED'
echo 'total.label Total'
echo 'total.graph no'
echo 'clean.colour 00ff00'
echo 'p_spam.colour ff4000'
echo 'b_spam.colour ff0000'
echo 'virus.colour 000000'
exit 0
fi
$LOGTAIL ${MAIL_LOG} $STATEFILE | \
awk 'BEGIN { na= 0; nb= 0; nc= 0; nd= 0; total= 0 }
{
if (index($0, "Passed CLEAN")) { na++ ; total++ }
else if (index($0, "Passed SPAMMY")) { nb++ ; total++ }
else if (index($0, "Blocked SPAMMY")) { nc++ ; total++ }
else if (index($0, "INFECTED")) { nd++ ; total++ }
}
END { print "clean.value " na"\np_spam.value " nb"\nb_spam.value " nc"\nvirus.value " nd"\ntotal.value " total }'

View file

@ -1,31 +0,0 @@
#!/bin/sh
#%# family=manual
#%# capabilities=autoconf
log=/var/log/clamav/clamd.log
if [ "$1" = "autoconf" ]; then
if [ -r $log ]; then
echo "yes"
else
echo "no (cannot read $log)"
fi
exit 0
fi
if [ "$1" = "config" ]; then
cat <<EOT
graph_title ClamAV stats
graph_args --base 1000 -l 0
graph_vlabel virus/day
graph_category antivirus
virus.label virus
virus.type DERIVE
virus.min 0
virus.draw AREA
virus.cdef virus,86400,*
EOT
exit 0
fi
echo -n "virus.value " && fgrep -c FOUND $log

View file

@ -1,126 +0,0 @@
#! /bin/bash
#
# Munin Plugin
# to count logins to your dovecot mailserver
#
# Created by Dominik Schulz <lkml@ds.gauner.org>
# http://developer.gauner.org/munin/
# Contributions by:
# - Stephane Enten <tuf@delyth.net>
# - Steve Schnepp <steve.schnepp@pwkf.org>
#
# Parameters understood:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# Config variables:
#
# logfile - Where to find the syslog file
#
# Add the following line to a file in /etc/munin/plugin-conf.d:
# env.logfile /var/log/your/logfile.log
#
# Magic markers (optional - used by munin-config and installation scripts):
#
#%# family=auto
#%# capabilities=autoconf
######################
# Configuration
######################
EXPR_BIN=/usr/bin/expr
LOGFILE=${logfile:-/var/log/mail.log}
######################
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Dovecot Logins'
echo 'graph_category Mail'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel Login Counters'
for t in Total TLS SSL IMAP POP3
do
field=$(echo $t | tr '[:upper:]' '[:lower:]')
echo "login_$field.label $t Logins"
echo "login_$field.type DERIVE"
echo "login_$field.min 0"
done
echo 'connected.label Connected Users'
exit 0
fi
######################
# Total Logins
######################
echo -en "login_total.value "
VALUE=$(egrep -c '[dovecot]?.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
echo "0"
fi
echo -n
######################
# Connected Users
######################
DISCONNECTS=$(egrep -c '[dovecot]?.*Disconnected' $LOGFILE)
CONNECTS=$(egrep -c '[dovecot]?.*Login' $LOGFILE)
VALUE=$($EXPR_BIN $CONNECTS - $DISCONNECTS)
if [ -z "$VALUE" ] || [ "$VALUE" -lt 0 ]; then
VALUE=0
fi
echo -en "connected.value "
echo $VALUE
echo -n
######################
# TLS Logins
######################
echo -en "login_tls.value "
VALUE=$(egrep -c '[dovecot]?.*Login.*TLS' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
echo "0"
fi
echo -n
######################
# SSL Logins
######################
echo -en "login_ssl.value "
VALUE=$(egrep -c '[dovecot]?.*Login.*SSL' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
echo "0"
fi
echo -n
######################
# IMAP Logins
######################
echo -en "login_imap.value "
VALUE=$(egrep -c '[dovecot]?.*imap.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
echo "0"
fi
echo -n
######################
# POP3 Logins
######################
echo -en "login_pop3.value "
VALUE=$(egrep -c '[dovecot]?.*pop3.*Login' $LOGFILE)
if [ ! -z "$VALUE" ]; then
echo "$VALUE"
else
echo "0"
fi
echo -n

View file

@ -1,135 +0,0 @@
#!/bin/bash
: <<=cut
=head1 NAME
dovecot_stats_ - Munin plugin to display statistics for the dovecot mail server
=head1 CONFIGURATION
This plugin must be run with permissions to run "doveadm". That usually means root, but to test, run the following as any user:
doveadm who
If you get a permission denied message, check the permissions on the socket mentioned in the error line.
=head1 MAGIC MARKERS
#%# family=contrib
#%# capability=autoconf suggest
=head1 AUTHOR
Paul Saunders <darac+munin@darac.org.uk>
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
is_multigraph
if [[ "$1" == "autoconf" ]]; then
if [[ -x /usr/bin/doveadm ]]; then
echo yes
else
echo no
fi
exit 0
fi
if [[ "$1" == "suggest" ]]; then
doveadm stats dump domain|awk 'NR!=1 {print $1}'
exit 0
fi
domain=$(basename $0)
domain=${domain#dovecot_stats_}
if [[ -z $domain ]]; then
exit 1
fi
if [[ "$1" == "config" ]]; then
cat <<EOF
multigraph dovecot_cpu_${domain//\./_}
graph_title Dovecot CPU Usage for $domain
graph_vlabel Seconds
graph_category mail
user_cpu.label User CPU
user_cpu.type DERIVE
user_cpu.min 0
user_cpu.cdef user_cpu,1000000,/
sys_cpu.label System CPU
sys_cpu.type DERIVE
sys_cpu.min 0
sys_cpu.cdef sys_cpu,1000000,/
multigraph dovecot_system_${domain//\./_}
graph_title Dovecot System Usage for $domain
graph_category mail
min_faults.label Minor page faults
min_faults.type DERIVE
min_faults.min 0
maj_faults.label Major page faults
maj_faults.type DERIVE
maj_faults.min 0
vol_cs.label Voluntary context switches
vol_cs.type DERIVE
vol_cs.min 0
invol_cs.label Involuntary context switches
invol_cs.type DERIVE
invol_cs.min 0
read_count.label read() syscalls
read_count.type DERIVE
read_count.min 0
write_count.label write() syscalls
write_count.type DERIVE
write_count.min 0
multigraph dovecot_mail_${domain//\./_}
graph_title Dovecot Mail Access for $domain
graph_category mail
num_logins.label Logins
num_logins.type DERIVE
num_logins.min 0
num_cmds.label Commands
num_cmds.type DERIVE
num_cmds.min 0
mail_lookup_path.label Path Lookups
mail_lookup_path.type DERIVE
mail_lookup_path.min 0
mail_lookup_attr.label Attr lookups
mail_lookup_attr.type DERIVE
mail_lookup_attr.min 0
mail_read_count.label Messages read
mail_read_count.type DERIVE
mail_read_count.min 0
mail_cache_hits.label Cache hits
mail_cache_hits.type DERIVE
mail_cache_hits.min 0
EOF
exit 0
fi
# Fetch data
# Gawk script cadged from http://awk.info/?JanisP
doveadm stats dump domain domain=$domain | gawk -F\\t -v cols="user_cpu sys_cpu min_faults maj_faults vol_cs invol_cs read_count write_count num_logins num_cmds mail_lookup_path mail_lookup_attr mail_read_count mail_cache_hits " -v domain=${domain//\./_} '
BEGIN {
n=split(cols,col," ")
for (i=1; i<=n; i++) s[col[i]]=i
}
NR==1 {
for (f=1;f<=NF; f++)
if ($f in s) c[s[$f]]=f
next
}
{ for (f=1; f<=n; f++) {
if (col[f] == "user_cpu") printf ("\nmultigraph dovecot_cpu_%s\n", domain)
if (col[f] == "min_faults") printf ("\nmultigraph dovecot_system_%s\n", domain)
if (col[f] == "num_logins") printf ("\nmultigraph dovecot_mail_%s\n", domain)
if (col[f] == "user_cpu" || col[f] == "sys_cpu")
printf("%s.value %d\n",col[f],$c[f] * 1000000)
else
printf("%s.value %d\n",col[f],$c[f])
}
}
'