Skip opendir lines (they are flooding logs)

tags/0.1.2
Daniel Berteaud 12 years ago
parent a4a71d12e6
commit 318bc49acf
  1. 9
      root/usr/bin/samba-db-logd
  2. 2
      root/var/service/samba-db-logd/run

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

@ -10,7 +10,7 @@ my $dbhost = $rec->prop('DbHost') || 'localhost';
open(STDERR, ">&STDOUT"); open(STDERR, ">&STDOUT");
my @args = ("--debug=1", "--dbname=$dbname", "--dbuser=$dbuser", "--dbpass=$dbpass"); my @args = ("--debug=1", "--dbname=$dbname", "--dbuser=$dbuser", "--dbpass=$dbpass", "--exclude=opendir");
push @args, "--dbhost=$dbhost" if ($dbhost ne 'localhost'); push @args, "--dbhost=$dbhost" if ($dbhost ne 'localhost');

Loading…
Cancel
Save