Fixed bug 2871383: show name resolution errors when using fping. Also added mutliple interface support to pping.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4301 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
470a0f957f
commit
5b959685d6
@ -21,7 +21,7 @@ use IO::Handle;
|
||||
use IO::Select;
|
||||
use Getopt::Long;
|
||||
|
||||
my $USAGE="Usage: pping [-i|--interface interface] noderange
|
||||
my $USAGE="Usage: pping [-i|--interface interfaces] noderange
|
||||
pping -h|--help
|
||||
pping -v|--version\n";
|
||||
|
||||
@ -95,35 +95,54 @@ unless (scalar(@nodes)) {
|
||||
exit 1;
|
||||
}
|
||||
|
||||
my $children = 0;
|
||||
my $inputs = new IO::Select;
|
||||
$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { $children--; } };
|
||||
if ($interface) {
|
||||
foreach (@nodes) {
|
||||
s/$/-$interface/;
|
||||
}
|
||||
# I think this was only needed when we forked ping ourselves
|
||||
#my $children = 0;
|
||||
#my $inputs = new IO::Select;
|
||||
#$SIG{CHLD} = sub { while (waitpid(-1,WNOHANG) > 0) { $children--; } };
|
||||
|
||||
my $usenmap = (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap');
|
||||
|
||||
my @interfaces;
|
||||
if ($interface) { @interfaces = split(/,/, $interface); }
|
||||
else { $interfaces[0] = ''; }
|
||||
|
||||
# Do the pings to the nodes for each interface in sequence. We could consider doing all the interfaces
|
||||
# in parallel, but then the output would get all mixed up and be confusing for the user.
|
||||
foreach my $interf (@interfaces) {
|
||||
my $noderef;
|
||||
if ($interf) {
|
||||
# make a copy of the node list and add the interface on
|
||||
$noderef = [ @nodes ];
|
||||
foreach (@$noderef) { s/$/-$interf/; }
|
||||
}
|
||||
else {
|
||||
$noderef = \@nodes; # use the original node list
|
||||
}
|
||||
|
||||
if ($usenmap) { nmap_pping($noderef); }
|
||||
else { fping_pping($noderef); }
|
||||
}
|
||||
|
||||
if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') {
|
||||
nmap_pping();
|
||||
exit;
|
||||
}
|
||||
open (FPING, "fping ".join(' ',@nodes). " 2> /dev/null|") or die("Cannot open fping pipe: $!");
|
||||
while (<FPING>) {
|
||||
if ($_ =~ /is unreachable/) {
|
||||
s/ is unreachable/: noping/;
|
||||
} elsif ($_ =~ /is alive/) {
|
||||
s/ is alive/: ping/;
|
||||
}
|
||||
print $_;
|
||||
sub fping_pping {
|
||||
my $nodes = shift;
|
||||
open (FPING, "fping ".join(' ',@$nodes). " 2>&1 |") or die("Cannot open fping pipe: $!");
|
||||
while (<FPING>) {
|
||||
if ($_ =~ /is unreachable/) {
|
||||
s/ is unreachable/: noping/;
|
||||
} elsif ($_ =~ /is alive/) {
|
||||
s/ is alive/: ping/;
|
||||
}
|
||||
print $_;
|
||||
}
|
||||
}
|
||||
|
||||
sub nmap_pping {
|
||||
my $nodes = shift;
|
||||
my %deadnodes;
|
||||
foreach (@nodes) {
|
||||
foreach (@$nodes) {
|
||||
$deadnodes{$_}=1;
|
||||
}
|
||||
open (FPING, "nmap -PE --send-ip -sP ".join(' ',@nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
open (FPING, "nmap -PE --send-ip -sP ".join(' ',@$nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
my $node;
|
||||
while (<FPING>) {
|
||||
if (/Host (.*) \(.*\) appears to be up/) {
|
||||
|
@ -5,7 +5,7 @@ B<pping> - parallel ping the nodes.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<pping> [B<-i>|B<--interface> I<interface>] I<noderange>
|
||||
B<pping> [B<-i>|B<--interface> I<interfaces>] I<noderange>
|
||||
|
||||
B<pping> [B<-h>|B<--help>]
|
||||
|
||||
@ -16,7 +16,7 @@ B<pping> {B<-v>|B<--version>}
|
||||
|
||||
B<pping> is a utility used to ping a list of nodes in parallel.
|
||||
B<pping> will return an unsorted list of nodes with a ping or noping status.
|
||||
B<pping> front-ends nmap and fping if available.
|
||||
B<pping> front-ends nmap or fping if available.
|
||||
|
||||
This command does not support the xcatd client/server communication. It must be run on the management node.
|
||||
|
||||
@ -24,12 +24,14 @@ This command does not support the xcatd client/server communication. It must be
|
||||
|
||||
=over 10
|
||||
|
||||
=item B<-i>|B<--interface> I<interface>
|
||||
=item B<-i>|B<--interface> I<interfaces>
|
||||
|
||||
An interface name that should be pinged instead of the interface represented by the nodename/hostname.
|
||||
A comma separated list of network interface names that should be pinged instead of the interface represented by the nodename/hostname.
|
||||
The following name resolution convention is assumed: an interface is reachable by the hostname <nodename>-<interface>. For example,
|
||||
the ib2 interface on node3 has a hostname of node3-ib2.
|
||||
|
||||
If more than one interface is specified, each interface will be combined with the nodenames as described above and will be pinged in turn.
|
||||
|
||||
=item B<-h>|B<--help>
|
||||
|
||||
Show usage information.
|
||||
@ -48,18 +50,20 @@ Display the installed version of xCAT.
|
||||
|
||||
pping all
|
||||
|
||||
blade7: ping
|
||||
blade8: ping
|
||||
blade9: ping
|
||||
devmaster: ping
|
||||
node4: ping
|
||||
node2: noping
|
||||
node1: ping
|
||||
node2: ping
|
||||
node3: noping
|
||||
|
||||
=item 2.
|
||||
|
||||
pping all -i eth1
|
||||
pping all -i ib0,ib1
|
||||
|
||||
node2-eth1: noping
|
||||
node1-ib0: ping
|
||||
node2-ib0: ping
|
||||
node3-ib0: noping
|
||||
node1-ib1: ping
|
||||
node2-ib1: ping
|
||||
node3-ib1: noping
|
||||
|
||||
=back
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user