Code

more debug logs in server and SIPackages
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Mar 2008 13:01:38 +0000 (13:01 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 19 Mar 2008 13:01:38 +0000 (13:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9939 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/modules/SIPackages.pm
gosa-si/tests/log-parser.pl

index 54b36fd008caa71ac8bd7b334183b06eb135d873..e69d6e620c5469888e7b95801477d075b63764a2 100755 (executable)
@@ -1059,7 +1059,8 @@ sub process_task {
     ######################
     # process incoming msg
     if( $error == 0) {
-        daemon_log("$session_id INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0]."'", 5); 
+        daemon_log("$session_id INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0].
+                               "' from '".$heap->{'remote_ip'}."'", 5); 
         daemon_log("$session_id DEBUG: Processing module ".$module, 7);
         $answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $session_id);
 
index 0bebf286da63c53ce4ca659835bc181ab3f05d6a..1790f9990318ac1e4bec13487a76599c3e43f429 100644 (file)
@@ -872,16 +872,18 @@ sub hardware_config {
        } else {
                my $entry= $mesg->entry(0);
                my $dn= $entry->dn;
-               if(defined($entry->get_value("gotoHardwareChecksum"))) {
-                       if(! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
+               if (defined($entry->get_value("gotoHardwareChecksum"))) {
+                       if (! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
                                $entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum);
                                if($entry->update($main::ldap_handle)) {
-                                       &main::daemon_log("Hardware changed! Detection triggered.", 4);
+                                       &main::daemon_log("$session_id INFO: Hardware changed! Detection triggered.", 5);
                                }
                        } else {
                                # Nothing to do
                                return;
                        }
+               } else {
+                       &main::daemon_log("$session_id WARNING: there is no 'gotoHardwareChecksum' found in LDAP for host '$macaddress'", 3); 
                }
        } 
 
@@ -910,7 +912,9 @@ sub hardware_config {
        &main::daemon_log("$session_id INFO: add '$macaddress' to job queue as an installing job", 5);
 
        # Send information
-       &main::daemon_log("$session_id INFO: Send detect_hardware message to $address", 5);
+
+       # log info not needed
+       #&main::daemon_log("$session_id INFO: Send detect_hardware message to $address", 5);
        return &build_msg("detect_hardware", $server_address, $address, \%data);
 }
 
index 256c310f232a0dd13d10d51b1e6c6b5d99ab0a2e..f888bb610f0e71572263279529bca211215c7151 100755 (executable)
@@ -25,8 +25,31 @@ use Getopt::Long;
 my $log_file = "/var/log/gosa-si-server.log"; 
 my $within_session = 0;
 my $within_incoming = 0;
+my $within_header = 0;
 my $session;
 my $incoming;
+my $header;
+
+sub check_header {
+       my ($line) = @_ ;
+       my @line_list = split(" ", $line);
+
+       # new header, set all values back to default
+       if ($line =~ /INFO: Incoming msg with header/ ) {
+               $within_header = 0; 
+       }
+
+       if ($line =~ /INFO: Incoming msg with header '$header'/) {
+               $within_header = 1;
+               return $line;
+       } else {
+               if ($within_header) {
+                       return $line;
+               } else {
+                       return;
+               }
+       }
+}
 
 sub check_incoming {
        my ($line) = @_ ;
@@ -72,52 +95,76 @@ sub check_session {
 ### MAIN ######################################################################
 
 GetOptions(
-               "s|session=s" => \$session,
+               "s|session=s"  => \$session,
                "i|incoming=s" => \$incoming,
+               "h|header=s"   => \$header,
                );
 
 # check script pram
-my $check_script_pram = 0;
+my $script_pram = {};
 if (defined $session) { 
        print "session: $session\n";
-       $check_script_pram++;
-}
+       $script_pram->{'session'} = $session;
+       }
 if (defined $incoming) { 
-       print "incoming msg for mac: $incoming\n";
-       $check_script_pram++;
+       print "incoming: $incoming\n";
+       $script_pram->{'incoming'} = $incoming;
 } 
+if (defined $header) {
+       print "header: $header\n";
+       $script_pram->{'header'} = $header;
+}      
 
-if ($check_script_pram == 0) {
+if (keys(%$script_pram) == 0) {
        # print usage and die
        print "exiting script\n"; 
        exit(0);
 }
 
 open(FILE, "<$log_file") or die "\t can not open log-file"; 
+my @lines;
+my $positive_msg = 0;
 # Read lines
-my $line;
-while ($line = <FILE>){
+while ( my $line = <FILE>){
     chomp($line);
-       my $line2print;
-       if (defined $session && (not defined $incoming)) {
-               $line2print = &check_session($line);
-               
-       } elsif (defined $incoming && (not defined $session)) {
-               $line2print = &check_incoming($line);
+
+       # start of a new message, plot saved log lines
+       if ($line =~ /INFO: Incoming msg with session ID \d+ from / ) {
+               if ($positive_msg) {
+                       print join("\n", @lines)."\n"; 
+                       $positive_msg = 0;
+               }
+
+               $within_session = 0;
+               $within_header = 0;
+               $within_incoming = 0;
+               @lines = ();
+       }
+
+       push (@lines, $line); 
+
+       my $positiv_counter = 0;
+       while (my ($pram, $val) = each %$script_pram) {
+               if ($pram eq 'session') {
+                       my $l = &check_session($line);
+                       if (defined $l) { $positiv_counter++; } 
+               }
+
+               elsif ($pram eq 'incoming') {
+                       my $l = &check_incoming($line);
+                       if (defined $l) { $positiv_counter++; } 
+               }
                
-       } elsif ((defined $incoming) && (defined $session)) {
-               my $line1 = &check_session($line);
-               my $line2 = &check_incoming($line);
-               if ((defined $line1) && (defined $line2)) {
-                       $line2print = $line;
+               elsif ($pram eq 'header') {
+                       my $l = &check_header($line);
+                       if (defined $l) { $positiv_counter++; } 
                }
        }
 
-       # printing
-       if (defined $line2print) {
-               print "$line\n";
+       if (keys(%$script_pram) == $positiv_counter) {
+               $positive_msg = 1;
        }
-       
+
 }