mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-24 09:57:09 +00:00
Initial version
This commit is contained in:
parent
6115c965b4
commit
89a9d6e2ee
1 changed files with 80 additions and 0 deletions
80
plugins/other/heimdal_kdc_bandwidth
Executable file
80
plugins/other/heimdal_kdc_bandwidth
Executable file
|
@ -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 <baggins@pld-linux.org>
|
||||
#
|
||||
# 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
|
Loading…
Add table
Add a link
Reference in a new issue