From b85c11e640e45e47c5c93a2d8dc0c5bf0b41e1ab Mon Sep 17 00:00:00 2001 From: Ryan Frame Date: Thu, 23 May 2019 12:42:40 -0400 Subject: [PATCH] Fix regular expression for exim logging to syslog. --- mailgraph.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mailgraph.pl b/mailgraph.pl index 42bebda..b87b241 100755 --- a/mailgraph.pl +++ b/mailgraph.pl @@ -117,7 +117,7 @@ sub main daemonize if $opt{daemon}; - my $logfile = defined $opt{logfile} ? $opt{logfile} : '/var/log/syslog'; + $logfile = defined $opt{logfile} ? $opt{logfile} : '/var/log/syslog'; my $file; if($opt{cat}) { $file = $logfile; @@ -372,10 +372,11 @@ ($) } } elsif($prog eq 'exim') { - if($text =~ /^[0-9a-zA-Z]{6}-[0-9a-zA-Z]{6}-[0-9a-zA-Z]{2} <= \S+/) { + my $prefix = (index($logfile, 'syslog') == -1) ? '^' : ''; + if($text =~ /$prefix[0-9a-zA-Z]{6}-[0-9a-zA-Z]{6}-[0-9a-zA-Z]{2} <= \S+/) { event($time, 'received'); } - elsif($text =~ /^[0-9a-zA-Z]{6}-[0-9a-zA-Z]{6}-[0-9a-zA-Z]{2} => \S+/) { + elsif($text =~ /$prefix[0-9a-zA-Z]{6}-[0-9a-zA-Z]{6}-[0-9a-zA-Z]{2} => \S+/) { event($time, 'sent'); } elsif($text =~ / rejected because \S+ is in a black list at \S+/) {