Första comitten av mina egna munin-plugins.

This commit is contained in:
2007-10-17 13:49:51 +00:00
parent a349d8e5ef
commit 182b5df19a
4 changed files with 230 additions and 0 deletions

90
bind9 Executable file
View File

@@ -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 (<Q>) {
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 (<Q>) {
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

37
denyhosts Executable file
View File

@@ -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

44
milter_greylist Executable file
View File

@@ -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 }'

59
spamassassin Executable file
View File

@@ -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