From 182b5df19a13aecaedff7a901b2c2460c2c47789 Mon Sep 17 00:00:00 2001 From: Fredrik Wahlberg Date: Wed, 17 Oct 2007 13:49:51 +0000 Subject: [PATCH] =?UTF-8?q?F=C3=B6rsta=20comitten=20av=20mina=20egna=20mun?= =?UTF-8?q?in-plugins.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bind9 | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ denyhosts | 37 ++++++++++++++++++++ milter_greylist | 44 ++++++++++++++++++++++++ spamassassin | 59 ++++++++++++++++++++++++++++++++ 4 files changed, 230 insertions(+) create mode 100755 bind9 create mode 100755 denyhosts create mode 100755 milter_greylist create mode 100755 spamassassin diff --git a/bind9 b/bind9 new file mode 100755 index 0000000..d8dc77c --- /dev/null +++ b/bind9 @@ -0,0 +1,90 @@ +#!/usr/bin/perl -w +# +# Plugin to monitor usage of bind 9 servers +# +# Parameters: +# +# logfile - Location of the query log +# statefile - Where to put temporary statefile. +# +# Contributed by Nicolai Langfeldt +# +#%# family=contrib + +use strict; + +my $QUERYLOG=$ENV{logfile} || '/var/log/named/bind.log'; +my $STATEFILE=$ENV{statefile} || '/var/cache/munin/bind9.state'; +my $OTHER=0; +my %IN; + +sub get_state { + open(Q,"< $STATEFILE") or die; + while () { + chomp; + my ($q,$n) = split(/\s+/,$_,2); + $IN{$q}=$n unless defined($IN{$q}); + } + close(Q); +} + + +sub do_stats { + my $k; + + open(Q,"< $QUERYLOG") or die "$!"; + while () { + chomp; + if (/client \d+\.\d+.\d+.\d+\#\d+: query\: \S+ (\w+) (\w+)/) { + if ($1 eq 'IN' and $2 !~ /^TYPE/) { + $IN{$2}++; + } else { + $OTHER++; + } + } + } + close(Q); + + get_state; + + open(Q,"> $STATEFILE") or die; + foreach $k (keys %IN) { + print "query_$k.value ",$IN{$k},"\n"; + print Q "$k ",$IN{$k},"\n"; + } + close(Q); + + print "query_other.value ",$OTHER,"\n"; +} + + +sub do_config { + my $k; + + print "graph_title DNS Queries by type +graph_vlabel Queries / \${graph_period} +query_other.label Other +query_other.type DERIVE +query_other.min 0 +query_other.draw AREA +"; + get_state; + + foreach $k (keys %IN) { + print "query_$k.label $k +query_$k.type DERIVE +query_$k.min 0 +query_$k.draw STACK +"; + } +}; + +if (defined($ARGV[0]) and ($ARGV[0] eq 'config')) { + do_config; + exit(0); +} + +do_stats; + + +# vim:syntax=perl diff --git a/denyhosts b/denyhosts new file mode 100755 index 0000000..39c2191 --- /dev/null +++ b/denyhosts @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Plugin to check /etc/hosts.deny for blocked hosts +# +# Parameters: +# +# config (required) +# autoconf (optional - only used by munin-config) +# +#%# family=auto +#%# capabilities=autoconf + + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Denyhosts' + echo 'graph_args -l 0 --base 1000' + echo 'graph_vlabel blocked hosts' + echo 'graph_category network' + echo 'graph_period second' + echo 'graph_info This graph shows the current number of blocked hosts for SSHD.' + echo 'blocked.label active' + echo 'blocked.max 1000' + echo 'blocked.min 0' + echo 'blocked.info The number of active blocked hosts.' + exit 0 +fi + +echo -n "blocked.value " +grep -c "^# DenyHosts:" /etc/hosts.deny + diff --git a/milter_greylist b/milter_greylist new file mode 100755 index 0000000..f1b6fe0 --- /dev/null +++ b/milter_greylist @@ -0,0 +1,44 @@ +#!/bin/sh +# +# Plugin to check /var/run/milter-greylist/greylist.db status +# +# Parameters: +# +# config (required) +# autoconf (optional - only used by munin-config) +# +#%# family=auto +#%# capabilities=autoconf + + + +if [ "$1" = "autoconf" ]; then + echo yes + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title Milter-greylist' + echo 'graph_args -l 0 --base 1000' + echo 'graph_vlabel Greylisted' + echo 'graph_category Mail' + echo 'graph_period second' + echo 'graph_info This graph shows the current number of greylisted and whitelisted senders.' + echo 'grey.label Greylisted' + echo 'grey.max 1000' + echo 'grey.min 0' + echo 'grey.info The number of greylisted hosts.' + echo 'white.label Whitelisted' + echo 'white.max 1000' + echo 'white.min 0' + echo 'white.info The number of whitelisted hosts.' + exit 0 +fi + +echo -n "grey.value " +grep "\# Summary:" /var/run/milter-greylist/greylist.db |awk '{ print $5 }' + +echo -n "white.value " +grep "\# Summary:" /var/run/milter-greylist/greylist.db |awk '{ print $7 }' + diff --git a/spamassassin b/spamassassin new file mode 100755 index 0000000..5b32bab --- /dev/null +++ b/spamassassin @@ -0,0 +1,59 @@ +#!/bin/sh +# +# Plugin to count the SpamAssassin troughput +# +# Contributed by David Obando - 16.11.2005 +# +# 2006.aug.21. - grin@grin.hu - fix autoconf, insecure tmp file +# - added mail count +# - save less irrelevant data into tmp +# - requires in plugin-conf.d/munin-node (to access syslog): +# [spamassassin] +# group adm +# +# Magic markers - optional - used by installation scripts and +# munin-config: +# +#%# family=manual +#%# capabilities=autoconf + +if [ "$1" = "autoconf" ]; then + if [ -r /var/log/syslog ]; then + echo "yes" + else + echo "no (cannot read /var/log/syslog)" + fi + exit 0 +fi + +if [ "$1" = "config" ]; then + + echo 'graph_title SpamAssassin stats' + echo 'graph_args --base 1000 -l 0 ' + echo 'graph_vlabel SpamAssassin mail/sec' + echo 'graph_order spam ham' + echo 'graph_category Mail' + echo 'mail.label mail' + echo 'mail.type DERIVE' + echo 'mail.min 0' + echo 'mail.draw LINE2' + echo 'ham.label ham' + echo 'ham.type DERIVE' + echo 'ham.min 0' + echo 'ham.draw LINE2' + echo 'spam.label spam' + echo 'spam.type DERIVE' + echo 'spam.min 0' + echo 'spam.draw AREA' + exit 0 +fi + +# create a secure tmp file +TEMP=`/bin/mktemp /tmp/munin-sa-XXXXXX` +egrep "spamd: (processing message|identified spam|clean message)" /var/log/syslog >> $TEMP + +echo -n "mail.value " && grep "processing message" $TEMP | wc -l +echo -n "spam.value " && grep "identified spam" $TEMP | wc -l +echo -n "ham.value " && grep "clean message" $TEMP | wc -l + +rm $TEMP