From 60e522ff5bb60bf029b585e7dbed4766f01d0ef4 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sat, 20 Oct 2012 12:47:04 +0200 Subject: [PATCH] Various fix in log parser --- root/usr/bin/samba-db-logd | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/root/usr/bin/samba-db-logd b/root/usr/bin/samba-db-logd index 3230cf3..db9970c 100755 --- a/root/usr/bin/samba-db-logd +++ b/root/usr/bin/samba-db-logd @@ -20,7 +20,7 @@ our @exclude = (); # get command line arguments GetOptions( "debug=i" => \$opts{debug}, - "log=s" => \$opts{squidlog}, + "log=s" => \$opts{log}, "dbhost=s" => \$opts{dbhost}, "dbname=s" => \$opts{dbname}, "dbuser=s" => \$opts{dbuser}, @@ -96,16 +96,15 @@ while (defined(my $line=$tail->read)){ my ($username, $client_ip, $client_name, $share, $action, $status, $access_mode, $file_src, $file_dst) = undef; - # Skip logging if listed in --exclude - next if (grep { $action eq $_ } @exclude); - # Oct 12 17:20:24 sme8 smbd[11176]: admin|192.168.7.50|pc10-45|intranet|mkdir|Nouveau dossier - if ($line =~ m/^\w+\s\d+\s\d+:\d+:\d+\s\w+\ssmbd\[\d+\]:\s+(\w+)\|(\d+\.\d+\.\d+\.\d+)\|([\w\.]+)\|(\w+)\|(\w+)/){ + if ($line =~ m/^\w+\s\d+\s\d+:\d+:\d+\s\w+\ssmbd\[\d+\]:\s+(\w+)\|(\d+\.\d+\.\d+\.\d+)\|([\w\.\-]+)\|(\w+)\|(\w+)/){ $username = $1; $client_ip = $2; $client_name = $3; $share = $4; $action = $5; + # Skip logging if listed in --exclude + next if (grep { $action eq $_ } @exclude); } else{ printlog("Couldn't parse this line: $line"); @@ -114,7 +113,6 @@ while (defined(my $line=$tail->read)){ my @other = split /\|/, $line; if (($action eq 'opendir') || - ($action eq 'chdir') || ($action eq 'connect') || ($action eq 'disconnect') || ($action eq 'close')){