summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e1477e)
raw | patch | inline | side by side (parent: 8e1477e)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 May 2009 10:04:39 +0000 (10:04 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 20 May 2009 10:04:39 +0000 (10:04 +0000) |
* configuration options 'system-com', 'ts-load-file', 'waiting-for-ts-info'
* plugin enables si-client to request system load information from terminal server and evaluate the replying terminal server answers
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13654 594d385d-05f5-0310-b6e9-bd551577e9d8
* plugin enables si-client to request system load information from terminal server and evaluate the replying terminal server answers
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13654 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/server/events/siTriggered.pm | patch | blob | history | |
gosa-si/tests/deploy-gosa-si.pl | patch | blob | history |
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index ee8be12b035ac6f5bea37720192f71ce4317607c..44ddd467c5370a100011c74709fb4c18c8bc164c 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
my $default_server_key;
my @servers;
my $gotoHardwareChecksum;
-my $gosa_si_client_fifo;
-my %files_to_watch;
+my $system_com;
$verbose= 1;
# globalise variables which are used in imported events
our $client_dnsname;
our $client_force_hostname;
our $server_key;
+our $terminal_server_hash;
# default variables
our $REGISTERED = 0;
# path to fifo for non-gosa-si-client messages to gosa-si-server
-$gosa_si_client_fifo = "/var/run/gosa-si-client.socket";
-%files_to_watch = (fifo => $gosa_si_client_fifo);
+my $fai_com_fifo = "/var/run/gosa-si-client-fai-com.socket";
+my $system_com_fifo = "/var/run/gosa-si-client-system-com.socket";
+my %files_to_watch = (fai_fifo => $fai_com_fifo, system_fifo => $system_com_fifo);
# in function register_at_gosa_si_server, after which period of seconds a new registration should be tried if a registration was
# not successful until now
"nss-config" => [\$nss_config, "/etc/libnss-ldap.conf"],
"fai-logpath" => [\$fai_logpath, "/var/log/fai/fai.log"],
"force-hostname" => [\$client_force_hostname, "false"],
+ "system-com" => [\$system_com, "disabled"],
},
"server" => {
"ip" => [\$server_ip, "127.0.0.1"],
}
}
+sub trigger_set_terminal_server
+{
+ # Function is defined in load_reporter.pm
+ if (exists $event_hash->{set_terminal_server})
+ {
+ no strict 'refs';
+ &{$event_hash->{set_terminal_server}."::set_terminal_server"};
+ }
+ else
+ {
+ &daemon_log("0 ERROR: load_reporter.pm needs function set_terminal_server to write terminal server load information to client. Processing aborted!", 1);
+ }
+ return;
+}
sub trigger_seen_messages {
my ($kernel) = $_[KERNEL] ;
}
-sub fifo_got_record {
+sub fai_fifo_got_record {
my $file_record = $_[ARG0];
my $header;
my $content = "";
}
+sub system_fifo_got_record {
+ my ($kernel, $socket_com_record) = @_[KERNEL, ARG0];
+ $socket_com_record =~ /^(\S+)\s?([\s\S]*)$/;
+ my $function = $1;
+ my $content = $2;
+
+ if( exists $event_hash->{$function} )
+ {
+ # a event exists with the header as name
+ daemon_log("INFO: found event '$function' at event-module '".$event_hash->{$function}."'", 5);
+ no strict 'refs';
+ my $answer = &{$event_hash->{$function}."::$function"}($content, $kernel);
+ &post_processing_and_sending($answer)
+ }
+ else
+ {
+ daemon_log("ERROR: Got input '$socket_com_record' from socket '$system_com_fifo'", 1);
+ daemon_log("ERROR: No event '$function' found in event modules under '$event_dir'.", 1);
+ }
+
+# # Sanity check of fifo record
+#
+# # Create record message
+# my $lr_msg_hash = &create_xml_hash("load_report", $client_address, $server_address, $file_record);
+# &add_content2xml_hash($lr_msg_hash, "macaddress", $client_mac_address);
+# my $utc_ts = &main::get_utc_time();
+# &add_content2xml_hash($lr_msg_hash, "timestamp", $utc_ts);
+# my $lr_msg = &create_xml_string($lr_msg_hash);
+#
+# # Report message to si-server
+# &send_msg_to_target($lr_msg, $server_address, $server_key, "load_report");
+
+ return;
+}
+
+
sub save_fai_log {
my ($fai_log_dir) = @_ ;
my $FAI_DIR;
my $watcher = POE::Wheel::FollowTail->new(
Filename => $file,
InputEvent => $name."_record",
- # ResetEvent => "file_reset",
ErrorEvent => "file_error",
);
-# $heap->{tail} = POE::Wheel::Run->new(
-# Program => [ "/usr/bin/tail", "-f", $file ],
-# StdoutEvent => $file_name."_record",
-# );
$heap->{services}->{ $watcher->ID } = $name;
$heap->{watchers}->{ $watcher->ID } = $watcher;
}
########
# answer
- if( $answer ) {
-
- #check gosa-si envelope validity
- my $answer_hash = &check_outgoing_xml_validity($answer);
-
- if( $answer_hash ) {
- # answer is valid
-
- # preprocessing
- if( $answer =~ "<header>registered</header>") {
- # set registered flag to true to stop sending further registered msgs
- $REGISTERED = 1;
- }
- else {
- $answer =~ /<header>(\S+)<\/header>/;
- &send_msg_to_target($answer, $server_address, $server_key, $1);
- }
+ &post_processing_and_sending($answer);
- # postprocessing
- if( $answer =~ "<header>new_key</header>") {
- # set new key to global variable
- $answer =~ /<new_key>(\S*?)<\/new_key>/;
- my $new_key = $1;
- $server_key = $new_key;
- }
- }
+ return;
+}
- }
+sub post_processing_and_sending
+{
+ my ($answer) = @_ ;
- return;
+ # Do nothing if answer does not exists
+ if (not defined $answer) { return; }
+
+ # Check gosa-si envelope validity
+ my $answer_hash = &check_outgoing_xml_validity($answer);
+
+ if( $answer_hash )
+ {
+ # Answer is valid
+ # Pre-sending
+ if( $answer =~ "<header>registered</header>")
+ {
+ # Set registered flag to true to stop sending further registered msgs
+ $REGISTERED = 1;
+ }
+ else
+ {
+ $answer =~ /<header>(\S+)<\/header>/;
+ &send_msg_to_target($answer, $server_address, $server_key, $1);
+ }
+
+ # Post-sending
+ if( $answer =~ "<header>new_key</header>")
+ {
+ # Set new key to global variable
+ $answer =~ /<new_key>(\S*?)<\/new_key>/;
+ my $new_key = $1;
+ $server_key = $new_key;
+ }
+ }
+
+ return;
}
}
-# open fifo for non-gosa-si-client-msgs to gosa-si-server
-POSIX::mkfifo("$gosa_si_client_fifo", "0600");
+# Open a new fifo for FAI messages to gosa-si-server
+if (-p $fai_com_fifo) { unlink $fai_com_fifo }
+POSIX::mkfifo("$fai_com_fifo", "0600");
+# Open a new fifo for system communication,
+if (-p $system_com_fifo) { unlink $system_com_fifo }
+if ($system_com eq "enabled")
+{
+ POSIX::mkfifo("$system_com_fifo", "0600");
+}
POE::Session->create(
inline_states => {
trigger_new_key => \&trigger_new_key,
trigger_logged_in_users_report => \&trigger_logged_in_users_report,
trigger_seen_messages => \&trigger_seen_messages,
+
+ # trigger non periodical tasks
+ trigger_set_terminal_server => \&trigger_set_terminal_server,
# handle records from each defined file differently
- fifo_record => \&fifo_got_record,
+ fai_fifo_record => \&fai_fifo_got_record,
+ system_fifo_record => \&system_fifo_got_record,
# handle file resets and errors the same way for each file
file_reset => \&generic_file_reset,
index e4493282d1b224feba7a9794add3c17cadf912eb..8b9b53b1c4e42720b20b6a68c675df3fd5c66162 100644 (file)
"detected_hardware",
"trigger_wake",
"reload_ldap_config",
+ "get_terminal_server",
);
@EXPORT = @events;
use strict;
use warnings;
+use Data::Dumper;
use GOSA::GosaSupportDaemon;
use Socket;
+
BEGIN {}
END {}
&GOSA::GosaSupportDaemon::read_configfile($main::cfg_file, %cfg_defaults);
-sub get_events {
- return \@events;
-}
+sub get_terminal_server
+{
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $source = @{$msg_hash->{source}}[0];
+ my @out_msg_l;
+
+ # Send get_load message to all si-clients at terminal server specified in LDAP
+ my $ldap_handle = &main::get_ldap_handle();
+ if (defined $ldap_handle)
+ {
+ my $ldap_mesg = $ldap_handle->search(
+ base => $ldap_base,
+ scope => 'sub',
+ attrs => ['macAddress'],
+ filter => "objectClass=goTerminalServer",
+ );
+ if ($ldap_mesg->count)
+ {
+ # Parse all LDAP results to a sql compliant where statement
+ my @entries = $ldap_mesg->entries;
+ @entries = map ($_->get_value("macAddress"), @entries);
+ @entries = map ("macaddress LIKE '$_'", @entries);
+
+ my ($hit, $hash, $db_res, $out_msg);
+ # Check known clients if a terminal server is active
+ $db_res = $main::known_clients_db->select_dbentry("SELECT * FROM $main::known_clients_tn WHERE ".join(" AND ", @entries));
+ while (($hit, $hash) = each %$db_res)
+ {
+ $out_msg = &create_xml_string(&create_xml_hash('get_load', $source, $hash->{macaddress}));
+ push(@out_msg_l, $out_msg);
+ }
+ # Check foreign_clients if a terminal server is active
+ $db_res = $main::foreign_clients_db->select_dbentry("SELECT * FROM $main::foreign_clients_tn WHERE ".join(" AND ", @entries));
+ while (($hit, $hash) = each %$db_res)
+ {
+ $out_msg = &create_xml_string(&create_xml_hash('get_load', $source, $hash->{macaddress}));
+ push(@out_msg_l, $out_msg);
+ }
+
+### JUST FOR DEBUGGING # CAN BE DELETED AT ANY TIME ###########################
+ my $db_res = $main::foreign_clients_db->select_dbentry("SELECT * FROM $main::foreign_clients_tn WHERE macaddress LIKE '00:01:6c:9d:b9:fa'");
+ while (($hit, $hash) = each %$db_res)
+ {
+ $out_msg = &create_xml_string(&create_xml_hash('get_load', $source, $hash->{macaddress}));
+ push(@out_msg_l, $out_msg);
+ }
+### JUST FOR DEBUGGING # CAN BE DELETED AT ANY TIME ###########################
+ }
+ # Translating errors ?
+ if ($ldap_mesg->code)
+ {
+ &main::daemon_log("0 ERROR: Cannot fetch terminal server from LDAP: \n\tbase='$ldap_base'\n\tscope='sub'\n\tattrs='['macAddress']'\n\tfilter='objectClass=goTerminalServer'", 1);
+ }
+ }
+ &main::release_ldap_handle($ldap_handle);
+ return @out_msg_l;
+}
-#sub read_configfile {
-# my ($cfg_file, %cfg_defaults) = @_;
-# my $cfg;
-#
-# if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) {
-# if( -r $cfg_file ) {
-# $cfg = Config::IniFiles->new( -file => $cfg_file );
-# } else {
-# &main::daemon_log("ERROR: siTriggered.pm couldn't read config file!", 1);
-# }
-# } else {
-# $cfg = Config::IniFiles->new() ;
-# }
-# foreach my $section (keys %cfg_defaults) {
-# foreach my $param (keys %{$cfg_defaults{ $section }}) {
-# my $pinfo = $cfg_defaults{ $section }{ $param };
-# ${@$pinfo[0]} = $cfg->val( $section, $param, @$pinfo[1] );
-# }
-# }
-#}
+sub get_events {
+ return \@events;
+}
sub reload_ldap_config {
my ($msg, $msg_hash, $session_id) = @_;
index 87a28578298fd50299e0ffe0a60a6caa0080af7d..5d2156815833d080ad1e01becebd7df7fb527799 100755 (executable)
"/usr/lib/gosa-si/client/events/gosaTriggered.pm" => "client/events/gosaTriggered.pm",
"/usr/lib/gosa-si/client/events/installation.pm" => "client/events/installation.pm",
"/usr/lib/gosa-si/client/events/mailqueue.pm" => "client/events/mailqueue.pm",
+ "/usr/lib/gosa-si/client/events/load_reporter.pm" => "client/events/load_reporter.pm",
);
while( my($new_file, $file_name) = each %copies ) {