diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 0f01caa220e8261d517b2e8fca341a7f070164f7..d9bf2393d29dd576ce5850a5106a87a3e39ecf01 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use POSIX;
use Time::HiRes qw( gettimeofday );
use POSIX;
use Time::HiRes qw( gettimeofday );
-use POE qw(Component::Server::TCP Wheel::FollowTail);
+use POE qw(Component::Server::TCP Wheel::FollowTail Wheel::Run);
use IO::Socket::INET;
use NetAddr::IP;
use Data::Dumper;
use IO::Socket::INET;
use NetAddr::IP;
use Data::Dumper;
# 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
# 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
-my $delay_set_time = 5;
+my $delay_set_time = 10;
our $prg= basename($0);
# all x seconds the client reports logged_in users to gosa-si-server
our $prg= basename($0);
# all x seconds the client reports logged_in users to gosa-si-server
sub read_configfile {
my ($cfg_file, %cfg_defaults) = @_ ;
my $cfg;
sub read_configfile {
my ($cfg_file, %cfg_defaults) = @_ ;
my $cfg;
- if( defined( $cfg_file) && ( length($cfg_file) > 0 )) {
+ if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
foreach my $section (keys %cfg_defaults) {
foreach my $param (keys %{$cfg_defaults{ $section }}) {
my $pinfo = $cfg_defaults{ $section }{ $param };
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 ] );
+ ${@$pinfo[ 0 ]} = $cfg->val( $section, $param, @$pinfo[ 1 ] );
}
}
}
}
}
}
my ($signal) = @_;
daemon_log("shutting down gosa-si-client", 1);
my ($signal) = @_;
daemon_log("shutting down gosa-si-client", 1);
- system("killall gosa-si-client");
+ system("kill `ps -C gosa-si-client -o pid=`");
}
$SIG{INT} = \&sig_int_handler;
}
$SIG{INT} = \&sig_int_handler;
# send xml hash to server with general server passwd
my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key);
# send xml hash to server with general server passwd
my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key);
+ if( $try_to_register >= @servers ) { last; }
+
# if delivery of registration msg succeed
if($res == 0) {
# reset try_to_register
# if delivery of registration msg succeed
if($res == 0) {
# reset try_to_register
next;
}
next;
}
- if( $try_to_register >= @servers ) { last; }
-
} # end of while
# one circle through all servers finished and no registration succeed
} # end of while
# one circle through all servers finished and no registration succeed
@logged_in_user_list = split(/\s/, $result);
}
@logged_in_user_list = split(/\s/, $result);
}
-# my @res_lines;
-#
-# if( defined $result ) {
-# chomp($result);
-# @res_lines = split("\n", $result);
-# }
-#
-# my @logged_in_user_list;
-# foreach my $line (@res_lines) {
-# chomp($line);
-# my @line_parts = split(/\s+/, $line);
-# push(@logged_in_user_list, $line_parts[0]);
-# }
-#
system("echo 'CURRENTLY_LOGGED_IN ".join(" ", @logged_in_user_list)."' > /var/run/gosa-si-client.socket");
$kernel->delay_set('trigger_logged_in_users_report', $trigger_logged_in_users_report_delay);
} else {
system("echo 'CURRENTLY_LOGGED_IN ".join(" ", @logged_in_user_list)."' > /var/run/gosa-si-client.socket");
$kernel->delay_set('trigger_logged_in_users_report', $trigger_logged_in_users_report_delay);
} else {
- # try it in 1 sec again
+ # try it in 10 sec again
$kernel->delay_set('trigger_logged_in_users_report', 10);
}
}
$kernel->delay_set('trigger_logged_in_users_report', 10);
}
}
-sub generic_file_reset {
- my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
-
- my $service = $heap->{services}->{$wheel_id};
- daemon_log("INFO: '$service' watching reset", 5);
- return;
-}
+#sub generic_file_reset {
+# my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
+#
+# my $service = $heap->{services}->{$wheel_id};
+# daemon_log("INFO: '$service' watching reset", 5);
+# return;
+#}
sub generic_file_error {
my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
sub generic_file_error {
my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
$kernel->yield('register_at_gosa_si_server');
# install all file watcher defined
$kernel->yield('register_at_gosa_si_server');
# install all file watcher defined
- while( my($file_name, $file) = each %files_to_watch ) {
- my $file_watcher = POE::Wheel::FollowTail->new(
+ while( my($name, $file) = each %files_to_watch ) {
+ my $watcher = POE::Wheel::FollowTail->new(
Filename => $file,
Filename => $file,
- InputEvent => $file_name."_record",
- ResetEvent => "file_reset",
+ InputEvent => $name."_record",
+ # ResetEvent => "file_reset",
ErrorEvent => "file_error",
);
ErrorEvent => "file_error",
);
- $heap->{services}->{ $file_watcher->ID } = $file_name;
- $heap->{watchers}->{ $file_watcher->ID } = $file_watcher;
+# $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;
}
$kernel->yield('trigger_logged_in_users_report');
}
}
$kernel->yield('trigger_logged_in_users_report');
}
# add gosa-si-server address from config file at first position of server list
my $server_check_cfg = Config::IniFiles->new( -file => $cfg_file );
# add gosa-si-server address from config file at first position of server list
my $server_check_cfg = Config::IniFiles->new( -file => $cfg_file );
-my $server_check = $server_check_cfg->val( "server", "ip");
+my $server_check = (defined($server_check_cfg))?$server_check_cfg->val( "server", "ip"):undef;
if( defined $server_check ) {
unshift(@servers, $server_address);
my $servers_string = join(", ", @servers);
if( defined $server_check ) {
unshift(@servers, $server_address);
my $servers_string = join(", ", @servers);