1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51: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/[^\/]+$//; ($dirname = $0) =~ s/[^\/]+$//;
$dovelogfile = 0 ;
$logfile = $ENV{'LOGFILE'} || '/var/log/mail.log'; $logfile = $ENV{'LOGFILE'} || '/var/log/mail.log';
if ( $logfile =~ /dovecot/ ) {
$dovelogfile = 1 ;
}
# Use an overrided $PATH for all external programs if needed # Use an overrided $PATH for all external programs if needed
$DOVEADM = "doveadm"; $DOVEADM = "doveadm";
@ -171,6 +177,10 @@ if (!defined $pos) {
$pos = $startsize; $pos = $startsize;
} }
print "# Logfile: $logfile\n";
print "# Pos: $pos\n";
print "# Startsize: $startsize\n";
if ($startsize < $pos) { if ($startsize < $pos) {
# Log rotated # Log rotated
parseDovecotfile ($rotlogfile, $pos, (stat $rotlogfile)[7]); parseDovecotfile ($rotlogfile, $pos, (stat $rotlogfile)[7]);
@ -208,25 +218,26 @@ sub parseDovecotfile {
my $line =<logf>; my $line =<logf>;
chomp ($line); 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/) { } elsif ($line =~ m/Login:/) {
$aborted++; $login++;
} elsif ($line =~ m/Login:/) { if ( $line =~ m/TLS/) {
$login++; $tls++;
} elsif ($line =~ m/SSL/) {
$ssl++;
}
if ( $line =~ m/TLS/) { if ( $line =~ m/pop3-login:/) {
$tls++; $pop3login++;
} elsif ($line =~ m/SSL/) { } elsif ($line =~ m/imap-login:/) {
$ssl++; $imaplogin++;
} }
}
if ( $line =~ m/pop3-login:/) {
$pop3login++;
} elsif ($line =~ m/imap-login:/) {
$imaplogin++;
}
} }
} }
close(logf); close(logf);