|
|
|
@ -15,6 +15,7 @@ $opts{dbhost} = 'localhost'; |
|
|
|
|
$opts{dbname} = 'samba_log'; |
|
|
|
|
$opts{dbuser} = 'samba'; |
|
|
|
|
$opts{dbpass} = 'samba'; |
|
|
|
|
our @exclude = (); |
|
|
|
|
|
|
|
|
|
# get command line arguments |
|
|
|
|
GetOptions( |
|
|
|
@ -23,9 +24,12 @@ GetOptions( |
|
|
|
|
"dbhost=s" => \$opts{dbhost}, |
|
|
|
|
"dbname=s" => \$opts{dbname}, |
|
|
|
|
"dbuser=s" => \$opts{dbuser}, |
|
|
|
|
"dbpass=s" => \$opts{dbpass} |
|
|
|
|
"dbpass=s" => \$opts{dbpass}, |
|
|
|
|
"exclude=s" => \@exclude |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
@exclude = split(/,/,join(',',@exclude)); |
|
|
|
|
|
|
|
|
|
# Disable output buffering |
|
|
|
|
select(STDOUT); |
|
|
|
|
$| = 1; |
|
|
|
@ -92,6 +96,9 @@ 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+)/){ |
|
|
|
|
$username = $1; |
|
|
|
|