From 767bfa0c38a069aecf1833c41982641a2ca688cf Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 9 Sep 2013 15:28:00 +0000 Subject: [PATCH] munin plugin to monitor /dev/log/daemon.log git-svn-id: svn://svn.rot13.org/sysadmin-cookbook@303 191e9f34-6774-4a6d-acfc-7664dacd4a2a --- recepies/munin/plugins/log | 106 +++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100755 recepies/munin/plugins/log diff --git a/recepies/munin/plugins/log b/recepies/munin/plugins/log new file mode 100755 index 0000000..7155346 --- /dev/null +++ b/recepies/munin/plugins/log @@ -0,0 +1,106 @@ +#!/usr/bin/perl +use warnings; +use strict; +use lib $ENV{'MUNIN_LIBDIR'}; +use Munin::Plugin; + +# -*- perl -*- + +=head1 NAME + +log - Plugin to monitor log files + +=head1 CONFIGURATION + +add munin user to adm group if needed to read C + + [log] + group adm + +=head1 MAGIC MARKERS + + #%# family=auto + #%# capabilities=autoconf + +=cut + +my $log = '/var/log/daemon.log'; + +if ( $ARGV[0] ) { + + if ( $ARGV[0] eq 'autoconf' ) { + print -r $log ? "yes\n" : "no\n"; + } elsif ( $ARGV[0] eq 'config' ) { + print <) { + if ( m/stunnel/ ) { + $stat->{lines}->{stunnel}++; + if ( m/accepted connection from (.+):\d+/ ) { + $ip->{$1}++; + } elsif ( m/Connection closed: (\d+) bytes sent to SSL, (\d+) bytes sent to socket/i ) { + $stat->{stunnel_transfer}->{ssl} += $1; + $stat->{stunnel_transfer}->{socket} += $2; + } + } elsif ( m/n2n/ ) { + $stat->{lines}->{n2n}++; + if ( m/Pending peers list size=(\d+)/ ) { + $stat->{n2n}->{pending} = $1; # latest + } elsif ( m/Operational peers list size=(\d+)/ ) { + $stat->{n2n}->{operational} = $1; # latest + } elsif ( m/pending=(\d+), operational=(\d+)/ ) { + $stat->{n2n} = { pending => 1, operational => 2 }; + } + } else { + $stat->{lines}->{ignored}++; + } +} + +$stat->{stunnel}->{clients} = scalar keys %$ip if $ip; + +foreach my $graph ( keys %$stat ) { + print "multigraph $graph\n"; + print "$_.value $stat->{$graph}->{$_}\n" foreach keys %{ $stat->{$graph} }; +} + +$pos = tail_close($fh); +save_state($pos); + -- 2.20.1