From 89a9d6e2eeb00835657f56f7d32330eb3adc8a22 Mon Sep 17 00:00:00 2001 From: Jan R?korajski Date: Tue, 15 Dec 2009 15:01:44 +0100 Subject: [PATCH] Initial version --- plugins/other/heimdal_kdc_bandwidth | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 plugins/other/heimdal_kdc_bandwidth diff --git a/plugins/other/heimdal_kdc_bandwidth b/plugins/other/heimdal_kdc_bandwidth new file mode 100755 index 00000000..5a6e9b02 --- /dev/null +++ b/plugins/other/heimdal_kdc_bandwidth @@ -0,0 +1,80 @@ +#!/usr/bin/perl +# +# Plugin to monitor the amount of data sent by KDC server. +# Based on kdc-log-analyze.pl script from heimdal. +# +# Contributed by Jan Rękorajski +# +# Example configuration: +# +# [heimdal_kdc_*] +# env.logdir /var/log +# env.logfile secure +# +use strict; +use Munin::Plugin; + +my $LOGDIR = $ENV{'logdir'} || '/var/log'; +my $LOGFILE = $ENV{'logfile'} || 'secure'; + +my $pos = undef; +my $bw = 0; + +sub parseLogfile { + my ($fname, $start) = @_; + + my ($LOGFILE,$rotated) = tail_open($fname,$start); + + my $line; + + while (<$LOGFILE>) { + chomp ($_); + + if (/sending ([0-9]+) bytes to IPv[46]:([0-9\.:a-fA-F]+)/) { + $bw += $1; + } + } + return tail_close($LOGFILE); +} + +if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) { + print "no\n"; + exit 0; +} + +if ( $ARGV[0] and $ARGV[0] eq "config" ) { + print "graph_title Heimdal KDC bandwidth\n"; + print "graph_args --base 1024\n"; + print "graph_vlabel bytes / \${graph_period}\n"; + print "graph_scale yes\n"; + print "graph_category Heimdal\n"; + print "bw.label Bytes sent\n"; + print "bw.type ABSOLUTE\n"; + print "bw.min 0\n"; + exit 0; +} + +my $logfile = "$LOGDIR/$LOGFILE"; + +if (! -f $logfile) { + print "bw.value U\n"; + exit 1; +} + +($pos) = restore_state(); + +if (!defined($pos)) { + # No state file present. Avoid startup spike: Do not read log + # file up to now, but remember how large it is now, and next + # time read from there. + + $pos = (stat $logfile)[7]; # File size +} else { + $pos = parseLogfile ($logfile, $pos); +} + +print "bw.value $bw\n"; + +save_state($pos); + +# vim:syntax=perl