2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00

use Munin::Plugin for statefiles

This commit is contained in:
Steve Schnepp 2013-07-19 10:59:36 +02:00
parent 6f0a884e19
commit cdfe518d36

View File

@ -3,8 +3,8 @@
#%# family=auto #%# family=auto
#%# capabilities=autoconf #%# capabilities=autoconf
use Munin::Plugin;
$statefile = "/var/lib/munin-node/plugin-state/root/plugin-dovecot.state";
$pos = undef; $pos = undef;
$connected = 0; $connected = 0;
$connectedimap = 0; $connectedimap = 0;
@ -24,7 +24,6 @@ $aborted = 0;
$logfile = $ENV{'LOGFILE'} || '/var/log/mail.log'; $logfile = $ENV{'LOGFILE'} || '/var/log/mail.log';
$DOVEADM = "/usr/bin/doveadm"; $DOVEADM = "/usr/bin/doveadm";
if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) { if ( $ARGV[0] and $ARGV[0] eq "autoconf" ) {
if (! -x $DOVEADM) { if (! -x $DOVEADM) {
@ -161,17 +160,7 @@ $connectionspop3 =~ s/\s+$//;
$connected = $connectedimap + $connectedpop3; $connected = $connectedimap + $connectedpop3;
$connections = $connectionsimap + $connectionspop3; $connections = $connectionsimap + $connectionspop3;
if (-f "$statefile") { my ($pos) = restore_state();
if (!open (IN, "$statefile")) {
print "Cannot open statefile $statefile for reading: $!\n";
exit 4;
}
my $in = <IN>;
if ($in =~ /^(\d+)$/) {
($pos) = ($1);
}
close IN;
}
$startsize = (stat $logfile)[7]; $startsize = (stat $logfile)[7];
@ -189,16 +178,7 @@ if ($startsize < $pos) {
parseDovecotfile ($logfile, $pos, $startsize); parseDovecotfile ($logfile, $pos, $startsize);
$pos = $startsize; $pos = $startsize;
if (-l $statefile) { save_state($pos);
die("$statefile is a symbolic link, refusing to touch it.");
}
if (!open (OUT, ">$statefile")) {
print "Cannot open statefile $statefile for writing: $!\n";
exit 4;
}
print OUT "$pos\n";
close OUT;
print "multigraph dovecot_connections\n"; print "multigraph dovecot_connections\n";
print "connections.value $connections\n"; print "connections.value $connections\n";