Lade...
 

killclients

killclients.txt

 

# $Header$ # Utility to kill all clients attached to an ObjectStore server # Version 2011-08-23 11:45 use warnings; use strict; die "wrong number of arguments: @ARGV" if (@ARGV < 1); my $serverHost = shift @ARGV || die "missing server host as parameter: $!"; my @execResult; my %clientspid = (); # Any clients to kill? print("Connected clients:\n"); @execResult = `"ossvrstat -clients $serverHost"`; for (@execResult) { # Client #123 (sg.classix.local/2296/SG/SG) if ($_ =~ /Client.*\((.+?)\/([0-9]+)\//) { print(" $1 $2\n"); $clientspid{$1} += 1; } } # Kill clients print("\nKilling clients...\n"); foreach my $key ( keys %clientspid ) { print(" $key\n"); `"ossvrclntkill $serverHost -h $key -a"`; } sleep(10); # Still any clients? print("\nStill connected clients:\n"); my @clients = (); @execResult = `"ossvrstat -clients $serverHost"`; ##print @execResult; for (@execResult) { # Client #123 (sg.classix.local/2296/SG/SG) if ($_ =~ /Client.*\((.+?)\//) { print(" $1\n"); push(@clients, $1); } } if (scalar(@clients)) { die "There are still connected clients\n"; }