From: rettenbe Date: Wed, 19 Mar 2008 13:01:38 +0000 (+0000) Subject: more debug logs in server and SIPackages X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f418da54b61c9439c2f71f76c50d53620229c703;p=gosa.git more debug logs in server and SIPackages git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9939 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 54b36fd00..e69d6e620 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -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); diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 0bebf286d..1790f9990 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -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); } diff --git a/gosa-si/tests/log-parser.pl b/gosa-si/tests/log-parser.pl index 256c310f2..f888bb610 100755 --- a/gosa-si/tests/log-parser.pl +++ b/gosa-si/tests/log-parser.pl @@ -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 = ){ +while ( my $line = ){ 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; } - + }