From bdfa6048a290a8f6326711011ceb42eb924ebc20 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 28 May 2008 08:44:56 +0000 Subject: [PATCH] * gosa-si-server-nobus * under construction git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11060 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/corefunctions.pm | 18 +++ gosa-si/gosa-si-server-nobus | 22 ++-- gosa-si/server/events/gosaTriggered.pm | 4 +- gosa-si/tests/log-parser.pl | 150 ++----------------------- 4 files changed, 44 insertions(+), 150 deletions(-) diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index a6f96e3bc..1e7717f12 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -10,6 +10,7 @@ my @events = ( "detect_hardware", "confirm_new_key", "ping", + "new_ping", "import_events", # no implementations ); @EXPORT = @events; @@ -490,4 +491,21 @@ sub ping { } + +sub new_ping { + my ($msg, $msg_hash) = @_ ; + my $header = @{$msg_hash->{'header'}}[0]; + my $source = @{$msg_hash->{'source'}}[0]; + my $target = @{$msg_hash->{'target'}}[0]; + my $session_id = @{$msg_hash->{'session_id'}}[0]; + + + # switch target and source and send msg back + my $out_hash = &main::create_xml_hash("answer_$session_id", $target, $source); + &add_content2xml_hash($out_hash, "session_id", $session_id); + my $out_msg = &main::create_xml_string($out_hash); + return $out_msg; + +} + 1; diff --git a/gosa-si/gosa-si-server-nobus b/gosa-si/gosa-si-server-nobus index 7bd0ba270..4529bcaa8 100755 --- a/gosa-si/gosa-si-server-nobus +++ b/gosa-si/gosa-si-server-nobus @@ -925,7 +925,7 @@ sub send_msg_to_target { print $socket $crypted_msg."\n"; daemon_log("$session_id INFO: send ".$header."msg to $address", 5); - daemon_log("DEBUG: message:\n$msg", 9); + daemon_log("$session_id DEBUG: message:\n$msg", 9); } @@ -1311,24 +1311,30 @@ sub session_start { $kernel->yield('watch_for_next_tasks'); $kernel->sig(USR1 => "sig_handler"); $kernel->sig(USR2 => "create_packages_list_db"); -} - -sub trigger_db_loop { - my ($kernel) = @_ ; $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay); $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay); $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay); $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay); + +} + +sub trigger_db_loop { + my ($kernel) = @_ ; +# $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay); +# $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay); +# $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay); +# $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay); +# $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay); +# $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay); } sub watch_for_done_jobs { my ($kernel,$heap) = @_[KERNEL, HEAP]; - my $sql_statement = "SELECT * FROM ".$job_queue_tn. - " WHERE status='done'"; + my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE status='done'"; my $res = $job_db->select_dbentry( $sql_statement ); while( my ($id, $hit) = each %{$res} ) { @@ -1648,7 +1654,7 @@ sub watch_for_old_known_clients { sub watch_for_next_tasks { my ($kernel,$heap) = @_[KERNEL, HEAP]; - + my $sql = "SELECT * FROM $incoming_tn"; my $res = $incoming_db->select_dbentry($sql); diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 0c0a1cf4e..8f55b3368 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -373,9 +373,7 @@ sub new_ping { my $target = @{$msg_hash->{target}}[0]; $sql = "SELECT * FROM $main::known_clients_tn WHERE ((hostname='$target') || (macaddress LIKE '$target'))"; - #&main::daemon_log("$sql",1); $res = $main::known_clients_db->exec_statement($sql); - #&main::daemon_log(Dumper($res), 1); my $host_name = @{@$res[0]}[0]; $out_msg =~ s/\S+<\/target>/$host_name<\/target>/; $out_msg =~ s/\S+<\/source>/$main::server_address<\/source>/; @@ -397,7 +395,7 @@ sub new_ping { } my $answer_xml = @{@$res[0]}[3]; my %data = ( 'answer_xml' => 'bin noch da' ); - my $answer_msg = &build_msg("got_ping", "$main::server_address", "GOSA", \%data); + my $answer_msg = &build_msg("got_new_ping", "$main::server_address", "GOSA", \%data); $sql = "DELETE FROM $main::incoming_tn WHERE id=$message_id"; $res = $main::incoming_db->exec_statement($sql); diff --git a/gosa-si/tests/log-parser.pl b/gosa-si/tests/log-parser.pl index 0efe9eab9..7a7cd5e74 100755 --- a/gosa-si/tests/log-parser.pl +++ b/gosa-si/tests/log-parser.pl @@ -23,157 +23,29 @@ use warnings; use Getopt::Long; use Data::Dumper; -my $log_file = "/home/hickert/log.gosa-si-server"; -#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; -my $syslog_state; - -sub check_syslog_state { - my ($line) = @_ ; - if($line =~ /$syslog_state:/ ) { - return $line; - } - return; -} - -sub check_header { - my ($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; } - } - return; -} - -sub check_incoming { - my ($line) = @_ ; - - # new incoming msg, set all values back to default - if ($line =~ /INFO: Incoming msg with session ID \d+ from/ ) { - $within_incoming = 0; - } - - if ($line =~ /INFO: Incoming msg with session ID \d+ from '$incoming'/) { - $within_incoming = 1; - return $line; - } else { - if ($within_incoming) { return $line; } - } - return; -} - -sub check_session { - my ($line) = @_ ; - - if ($line =~ /gosa-si-server (\d+) / ) { - if ((defined $1) && ($1 eq $session)) { - return $line; - } - } - return; -} - +my $pattern; +my $log_file = "/var/log/gosa-si-server.log"; ### MAIN ###################################################################### GetOptions( - "s|session=s" => \$session, - "i|incoming=s" => \$incoming, - "h|header=s" => \$header, - "l|log=s" => \$syslog_state, + "p|pattern=s" => \$pattern, ); -# check script pram -my $script_pram = {}; -if (defined $session) { - print "session: $session\n"; - $script_pram->{'session'} = $session; - } -if (defined $incoming) { - print "incoming: $incoming\n"; - $script_pram->{'incoming'} = $incoming; -} -if (defined $header) { - print "header: $header\n"; - $script_pram->{'header'} = $header; -} -if (defined $syslog_state) { - print "syslog_state: $syslog_state\n"; - $script_pram->{'syslog_state'} = $syslog_state; -} - -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"; +open(FILE, "<$log_file") or die "\ncan not open log-file '$log_file'\n"; my @lines; -my $positive_msg = 0; +my $messages = {}; + # Read lines while ( my $line = ){ chomp($line); - + # start of a new message, plot saved log lines - if ($line =~ /INFO: Incoming msg with session ID \d+ from / ) { - if ($positive_msg) { - print "#####################################################\n"; - 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 ($pram eq 'header') { - my $l = &check_header($line); - if (defined $l) { $positiv_counter++; } - } - - elsif ($pram eq 'syslog_state') { - my $l = &check_syslog_state($line); - if (defined $l) { $positiv_counter++; } - } - } - - if (keys(%$script_pram) == $positiv_counter) { - $positive_msg = 1; - } + if ($line =~ /$pattern/ ) { + print "$line\n"; + } } - - +close FILE; -- 2.30.2