Revert nodestat being messed up
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@814 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
6828430247
commit
2dbfc4932c
@ -2,9 +2,7 @@ package xCAT_plugin::nodestat;
|
||||
|
||||
use Socket;
|
||||
use IO::Handle;
|
||||
use Storable qw/freeze thaw/;
|
||||
my $stat;
|
||||
my $children;
|
||||
|
||||
sub handled_commands {
|
||||
return {
|
||||
@ -67,98 +65,37 @@ sub process_request {
|
||||
my $doreq = shift;
|
||||
my @nodes = @{$request->{node}};
|
||||
my $node;
|
||||
my $child_handles = new IO::Select;
|
||||
$children=0;
|
||||
$SIG{CHLD} = sub {while (waitpid(-1, WNOHANG) > 0) { $children--; }};
|
||||
foreach $node (@nodes) {
|
||||
my $parent;
|
||||
my $childfd;
|
||||
undef ($parent);
|
||||
undef ($childfd);
|
||||
socketpair($childfd,$parent,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die "socketpair: $!";
|
||||
my $child;
|
||||
$child = xCAT::Utils->xfork;
|
||||
unless (defined $child) { die "Fork failure"; }
|
||||
if ($child==0) { #This is the child
|
||||
close($childfd);
|
||||
undef $SIG{CHLD};
|
||||
my %rsp;
|
||||
my $text="";
|
||||
$rsp{name}=[$node];
|
||||
unless (pinghost($node)) {
|
||||
$rsp{data} = [ 'noping' ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
}
|
||||
if (nodesockopen($node,15002)) {
|
||||
$rsp{data} = [ 'pbs' ];
|
||||
print $parent freeze({node=>[\%rsp]})
|
||||
} elsif (nodesockopen($node,22)) {
|
||||
$rsp{data} = [ 'sshd' ];
|
||||
print "$node is sshd\n";
|
||||
print $parent freeze({node=>[\%rsp]});
|
||||
} elsif ($text = installer_query($node)) {
|
||||
$rsp{data} = [ $text ];
|
||||
print $parent freeze({node=>[\%rsp]});
|
||||
} else {
|
||||
$doreq->({command=>['nodeset'],
|
||||
node=>[$node],
|
||||
arg=>['stat']},
|
||||
\&getstat);
|
||||
$rsp{data} = [ 'ping '.$stat ];
|
||||
print $parent freeze({node=>[\%rsp]});
|
||||
}
|
||||
print $parent "\nENDOFFREEZEx3a93\n";
|
||||
$parent->flush;
|
||||
print "Wait for $node ack...\n";
|
||||
<$parent>;
|
||||
print "$node acked...\n";
|
||||
close($parent);
|
||||
exit 0;
|
||||
my %rsp;
|
||||
my $text="";
|
||||
$rsp{name}=[$node];
|
||||
unless (pinghost($node)) {
|
||||
$rsp{data} = [ 'noping' ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
}
|
||||
close($parent);
|
||||
$children++;
|
||||
$child_handles->add($childfd);
|
||||
}
|
||||
print "wait for kids\n";
|
||||
while ($children) {
|
||||
relay_responses($child_handles,$callback);
|
||||
}
|
||||
print "kids gone\n";
|
||||
while (relay_responses($child_handles,$callback)) {}
|
||||
print "out i go\n";
|
||||
}
|
||||
|
||||
sub relay_responses {
|
||||
my $fhs = shift;
|
||||
my $callback = shift;
|
||||
my @handles = $fhs->can_read(0.2);
|
||||
foreach my $input (@handles) {
|
||||
print "I can haz input\n";
|
||||
my $data;
|
||||
$data = "";
|
||||
print "here\n";
|
||||
if ($data = <$input>) {
|
||||
print $data;
|
||||
while ($data !~ /ENDOFFREEZEx3a93/) { #<$input>) {
|
||||
$data .= <$input>;
|
||||
}
|
||||
my $response = thaw($data);
|
||||
print "fin issued\n";
|
||||
print $input "fin\n";
|
||||
$input->flush;
|
||||
$callback->($response);
|
||||
} else {
|
||||
print "not here....\n";
|
||||
$fhs->remove($input);
|
||||
close($input);
|
||||
if (nodesockopen($node,15002)) {
|
||||
$rsp{data} = [ 'pbs' ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
} elsif (nodesockopen($node,22)) {
|
||||
$rsp{data} = [ 'sshd' ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
} elsif ($text = installer_query($node)) {
|
||||
$rsp{data} = [ $text ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
} else {
|
||||
$doreq->({command=>['nodeset'],
|
||||
node=>[$node],
|
||||
arg=>['stat']},
|
||||
\&getstat);
|
||||
$rsp{data} = [ 'ping '.$stat ];
|
||||
$callback->({node=>[\%rsp]});
|
||||
next;
|
||||
}
|
||||
}
|
||||
return scalar(@handles);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user