Some patch to scripts/services/samba

Roman Rybalko <[email protected]>
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Hi all.
I think, it's usable. At least for me ;)

Patch to $Id: samba,v 1.24 2006/04/20 00:17:33 bjorn Exp $

_______________________________________________
Logwatch-Devel mailing list
[email protected]
http://www2.list.logwatch.org:81/mailman/listinfo/logwatch-devel
samba.diff (text/x-patch, 2.8 KB)
--- samba.orig	2006-04-20 04:17:33.000000000 +0400
+++ samba	2007-03-12 11:15:05.000000000 +0300
@@ -104,9 +104,10 @@
    ) {
       #Don't care about these...
    } elsif ( ($Host, undef, $Service, undef, $User) = ( $ThisLine =~ /([^ ]+ \([^ ]+\)) (signed |)connect to service ([^ ]+) (initially |)as user ([^ ]+)/) ) {
+		$CurrentHost=$Host;
 		$Connect{$Service}{$User}{$Host}++;
-	} elsif ( ($NoService) = ( $ThisLine =~ /couldn't find service (\S+)/ ) ) {
-		$NoServ{$NoService}++;
+	} elsif ( ($Host,$NoService) = ( $ThisLine =~ /([^ ]+ \([^ ]+\)) couldn't find service (\S+)/ ) ) {
+		$NoServ{$Host}{$NoService}++;
 	} elsif ($ThisLine =~ s/Denied connection from\s+\((\S+)\)([ *]+|)$/$1/) {
 		$Denied{$ThisLine}++;
    } elsif ($ThisLine =~ s/ Connection denied from\s+(\S+)$/$1/) {
@@ -209,6 +210,8 @@
       $RefConnect{$Addr}++;      
    } elsif ( ($Name) = ($ThisLine =~ /passdb\/pdb_smbpasswd.c:startsmbfilepwent\([0-9]+\)  startsmbfilepwent_internal: file ([^ ]*) did not exist. File successfully created./)) {
       $CrFile{$Name}++;
+   } elsif ( ($user,$file,$read,$write) = ($ThisLine =~ /(\S+) opened file (\S+) read=(\w+) write=(\w+)/)) {
+      $OpenFile{$CurrentHost}{$user}{$file}{($read=~/Y/?"R":"").($write=~/Y/?"W":"")}++;
    } elsif ( ($Location,$Reason) = ($ThisLine =~ /tdb_log\([0-9]+\)  tdb\(([^ ]+)\): tdb_reopen: (open failed \([^ ]+\))/)) {
       $LockDbError{"$Location - $Reason"}++;
 	} else {
@@ -279,6 +282,22 @@
    }
 }
 
+if (($Detail >= 5) and (keys %OpenFile)) {
+   print "\nOpened Files:\n";
+   foreach $Host (sort {$a cmp $b} keys %OpenFile) {
+      print "   Host $Host:\n";
+      foreach $User (sort {$a cmp $b} keys %{$OpenFile{$Host}}) {
+         foreach $File (sort {$a cmp $b} keys %{$OpenFile{$Host}{$User}}) {
+            print "     File \"$File\"";
+            foreach $Mode (sort {$a cmp $b} keys %{$OpenFile{$Host}{$User}{$File}}) {
+               print " $Mode: $OpenFile{$Host}{$User}{$File}{$Mode} Time(s)";
+            }
+            print "\n";
+         }
+      }
+   }
+}
+
 if (keys %Denied) {
    print "\nConnections Denied:\n";
    foreach $Line (sort {$a cmp $b} keys %Denied) {
@@ -381,8 +400,11 @@
 
 if (($Detail >= 5) and (keys %NoServ)) {
    print "\nCouldn't find services:\n";
-   foreach $ThisOne (sort {$a cmp $b} keys %NoServ) {
-      print "   $ThisOne : $NoServ{$ThisOne} Time(s)\n";
+   foreach $Host (sort {$a cmp $b} keys %NoServ) {
+      print "   Host: $Host\n";
+      foreach $ThisOne (sort {$a cmp $b} keys %{$NoServ{$Host}}) {
+         print "      $ThisOne : $NoServ{$Host}{$ThisOne} Time(s)\n";
+      }
    }
 }
 
@@ -482,7 +504,7 @@
 }
 
 
-if (keys %OtherList) {
+if (($Detail >= 10) and keys %OtherList) {
 	print "\n**Unmatched Entries**\n";
 	foreach $Line (sort {$a cmp $b} keys %OtherList) {
 		print "$Line : $OtherList{$Line} Time(s)\n";
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.