1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

dovecot plugin check log file type by name

If dovecot plugin found dovecot-only log it will analyze it without filtering by 'dovecot' tag
This commit is contained in:
Alexander Shurakov 2016-01-26 15:28:23 +03:00
parent 65e4a94cea
commit e5260be436

View file

@ -21,8 +21,14 @@ $aborted = 0;
($dirname = $0) =~ s/[^\/]+$//;
$dovelogfile = 0 ;
$logfile = $ENV{'LOGFILE'} || '/var/log/mail.log';
if ( $logfile =~ /dovecot/ ) {
$dovelogfile = 1 ;
}
# Use an overrided $PATH for all external programs if needed
$DOVEADM = "doveadm";
@ -171,6 +177,10 @@ if (!defined $pos) {
$pos = $startsize;
}
print "# Logfile: $logfile\n";
print "# Pos: $pos\n";
print "# Startsize: $startsize\n";
if ($startsize < $pos) {
# Log rotated
parseDovecotfile ($rotlogfile, $pos, (stat $rotlogfile)[7]);
@ -208,25 +218,26 @@ sub parseDovecotfile {
my $line =<logf>;
chomp ($line);
if ($line !~ m/dovecot/) { next; }
if ( $dovelogfile == 0 and $line !~ m/dovecot/) { next; }
else {
if ($line =~ m/Aborted/) {
$aborted++;
if ($line =~ m/Aborted/) {
$aborted++;
} elsif ($line =~ m/Login:/) {
$login++;
} elsif ($line =~ m/Login:/) {
$login++;
if ( $line =~ m/TLS/) {
$tls++;
} elsif ($line =~ m/SSL/) {
$ssl++;
}
if ( $line =~ m/TLS/) {
$tls++;
} elsif ($line =~ m/SSL/) {
$ssl++;
}
if ( $line =~ m/pop3-login:/) {
$pop3login++;
} elsif ($line =~ m/imap-login:/) {
$imaplogin++;
}
if ( $line =~ m/pop3-login:/) {
$pop3login++;
} elsif ($line =~ m/imap-login:/) {
$imaplogin++;
}
}
}
}
close(logf);