From 42a45748ccc69826a93c6adcb41c79390105832d Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 20 Feb 2008 08:12:57 +0000 Subject: [PATCH] add new event module to gosa-si-server git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8976 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/server/events/siTriggered.pm | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 gosa-si/server/events/siTriggered.pm diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm new file mode 100644 index 000000000..4cd6abff2 --- /dev/null +++ b/gosa-si/server/events/siTriggered.pm @@ -0,0 +1,69 @@ +package siTriggered; +use Exporter; +@ISA = qw(Exporter); +my @events = ( + "got_ping", + ); +@EXPORT = @events; + +use strict; +use warnings; +use GOSA::GosaSupportDaemon; + + +BEGIN {} + +END {} + +### Start ###################################################################### + +#&main::read_configfile($main::cfg_file, %cfg_defaults); + +sub get_events { + return \@events; +} + + +sub got_ping { + my ($msg, $msg_hash, $session_id) = @_; + + my $source = @{$msg_hash->{source}}[0]; + my $target = @{$msg_hash->{target}}[0]; + my $header = @{$msg_hash->{header}}[0]; + my $act_time = &get_time; + my @out_msg_l; + my $out_msg; + + $session_id = @{$msg_hash->{'session_id'}}[0]; + + # check known_clients_db + my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$source'"; + my $query_res = $main::known_clients_db->select_dbentry( $sql_statement ); + if( 1 == keys %{$query_res} ) { + my $sql_statement= "UPDATE known_clients ". + "SET status='$header', timestamp='$act_time' ". + "WHERE hostname='$source'"; + my $res = $main::known_clients_db->update_dbentry( $sql_statement ); + } + + # check known_server_db + $sql_statement = "SELECT * FROM known_server WHERE hostname='$source'"; + $query_res = $main::known_server_db->select_dbentry( $sql_statement ); + if( 1 == keys %{$query_res} ) { + my $sql_statement= "UPDATE known_server ". + "SET status='$header', timestamp='$act_time' ". + "WHERE hostname='$source'"; + my $res = $main::known_server_db->update_dbentry( $sql_statement ); + } + + # create out_msg + my $out_hash = &create_xml_hash($header, $source, "GOSA"); + &add_content2xml_hash($out_hash, "session_id", $session_id); + $out_msg = &create_xml_string($out_hash); + push(@out_msg_l, $out_msg); + + return @out_msg_l; +} + + +1; -- 2.30.2