added nmapoptions in the site table to resolve network slow response issues in nmap. defect 4300
This commit is contained in:
parent
7e8c02bf07
commit
73d08b58fa
@ -2182,7 +2182,13 @@ sub pingNodeStatus {
|
||||
foreach (@mon_nodes) {
|
||||
$deadnodes{$_}=1;
|
||||
}
|
||||
open (NMAP, "nmap -PE --system-dns --send-ip -sP ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
|
||||
# get additional options from site table
|
||||
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
|
||||
my $more_options = $nmap_options[0];
|
||||
|
||||
#call namp
|
||||
open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
my $node;
|
||||
while (<NMAP>) {
|
||||
if (/Host (.*) \(.*\) appears to be up/) {
|
||||
|
@ -14,7 +14,7 @@ use xCAT::Usage;
|
||||
use xCAT::NodeRange;
|
||||
use xCAT::DBobjUtils;
|
||||
use xCAT::FSPUtils;
|
||||
use xCAT::TableUtils qw(get_site_Master);
|
||||
use xCAT::TableUtils;
|
||||
%::QUERY_ATTRS = (
|
||||
'savingstatus' => 1,
|
||||
'dsavingstatus' => 1,
|
||||
@ -223,7 +223,6 @@ sub renergy {
|
||||
my ($node, $attrs) = %$nodehash;
|
||||
my $cec_name = @$attrs[2];
|
||||
my $hw_type = @$attrs[4];
|
||||
|
||||
|
||||
if (!$cec_name) {
|
||||
return ([[$node, "ERROR: Cannot find the cec name, check the attributes: vpd.serial, vpd.mtm.", 1]]);
|
||||
@ -295,7 +294,12 @@ sub renergy {
|
||||
foreach (@hcps_ip) {
|
||||
$deadnodes{$_}=1;
|
||||
}
|
||||
open (NMAP, "nmap -PE --system-dns --send-ip -sP ". join(' ',@hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
|
||||
# get additional options from site table
|
||||
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
|
||||
my $more_options = $nmap_options[0];
|
||||
|
||||
open (NMAP, "nmap -PE --system-dns --send-ip -sP $more_options ". join(' ',@hcps_ip) . " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
my $node;
|
||||
while (<NMAP>) {
|
||||
#print "$_\n";
|
||||
|
@ -116,6 +116,9 @@ sub dodiscover {
|
||||
send_message($args{reqcallback}, 0, "The rarge is too large and may be time consuming. Broadcast is recommended.");
|
||||
}
|
||||
}
|
||||
|
||||
#no need to check site.nmapoptions because it specifilly
|
||||
# uses T5 for certain performance requirement.
|
||||
`/usr/bin/nmap $range -sn -PE -n --send-ip -T5 `;
|
||||
my $nmapres = `/usr/bin/nmap $range -PE -p 427 -n --send-ip -T5 `;
|
||||
foreach my $line (split(/\n\n/,$nmapres)) {
|
||||
|
@ -1122,6 +1122,13 @@ site => {
|
||||
" httpport: The port number that the booting/installing nodes should contact the\n".
|
||||
" http server on the MN/SN on. It is your responsibility to configure\n".
|
||||
" the http server to listen on that port - xCAT will not do that.\n\n".
|
||||
" nmapoptions: Additional options for the nmap command. nmap is used in pping, \n".
|
||||
" nodestat, xdsh -v and updatenode commands. Sometimes additional \n".
|
||||
" performance tuning may be needed for nmap due to network traffic.\n".
|
||||
" For example, if the network response time is too slow, nmap may not\n".
|
||||
" give stable output. You can increase the timeout value by specifying \n".
|
||||
" '--min-rtt-timeout 1s'. xCAT will append the options defined here to \n".
|
||||
" the nmap command.\n\n".
|
||||
" ntpservers: A comma delimited list of NTP servers for the cluster - often the\n".
|
||||
" xCAT management node.\n\n".
|
||||
" svloglocal: if set to 1, syslog on the service node will not get forwarded to the\n".
|
||||
|
@ -169,7 +169,11 @@ sub nmap_pping {
|
||||
foreach (@$nodes) {
|
||||
$deadnodes{$_}=1;
|
||||
}
|
||||
open (FPING, "nmap -PE --system-dns --send-ip -sP ".join(' ',@$nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
# get additional options from site table
|
||||
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
|
||||
my $more_options = $nmap_options[0];
|
||||
|
||||
open (FPING, "nmap -PE --system-dns --send-ip -sP $more_options ".join(' ',@$nodes). " 2> /dev/null|") or die("Cannot open nmap pipe: $!");
|
||||
my $node;
|
||||
while (<FPING>) {
|
||||
if (/Host (.*) \(.*\) appears to be up/) {
|
||||
|
@ -187,8 +187,8 @@ sub preprocess_request
|
||||
#my $sitetab = xCAT::Table->new('site');
|
||||
#if ($sitetab) {
|
||||
#(my $ref) = $sitetab->getAttribs({key => 'useNmapfromMN'}, 'value');
|
||||
my @entries = xCAT::TableUtils->get_site_attribute("useNmapfromMN");
|
||||
my $t_entry = $entries[0];
|
||||
my @entries = xCAT::TableUtils->get_site_attribute("useNmapfromMN");
|
||||
my $t_entry = $entries[0];
|
||||
if (defined($t_entry)) {
|
||||
if ($t_entry =~ /1|yes|YES|Y|y/) { $usenmapfrommn=1; }
|
||||
}
|
||||
@ -634,79 +634,84 @@ sub process_request_nmap {
|
||||
my %rsp;
|
||||
my $installquerypossible=0;
|
||||
my @nodesetnodes=();
|
||||
|
||||
# get additional options from site table
|
||||
my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions");
|
||||
my $more_options = $nmap_options[0];
|
||||
|
||||
foreach my $ip6 (0,1) { #first pass, ipv4, second pass ipv6
|
||||
if ($ip6 and scalar(@ip6s)) {
|
||||
open($fping,"nmap -6 -PS$ports,3001 -n --send-ip -p $ports,3001 ".join(' ',@ip6s). " 2> /dev/null|") or die("Can't start nmap: $!");
|
||||
} elsif (not $ip6 and scalar(@ips)) {
|
||||
open($fping,"nmap -PE -n --send-ip -p $ports,3001 ".join(' ',@ips). " 2> /dev/null|") or die("Can't start nmap: $!");
|
||||
} else { next; }
|
||||
while (<$fping>) {
|
||||
if (/Interesting ports on ([^ ]*)[: ]/ or /Nmap scan report for ([^ ]*)/) {
|
||||
my $tmpnode=$1;
|
||||
if ($currnode) { #if still thinking about last node, flush him out
|
||||
my $status = join ',',sort keys %states ;
|
||||
my $appsd="";
|
||||
foreach my $portnum(keys %portservices) {
|
||||
my $app_t=$portservices{$portnum};
|
||||
if ($states{$app_t}) {$appsd .= $app_t . "=up,";}
|
||||
else {$appsd .= $app_t . "=down,";}
|
||||
}
|
||||
$appsd =~ s/,$//;
|
||||
my $target=$currnode;
|
||||
if ($hostsents{$target} and $hostsents{$target}->[0]->{ip}) { $target = $hostsents{$target}->[0]->{ip}; }
|
||||
|
||||
if ($status or ($installquerypossible and $status = installer_query($target))) { #pingable, but no *clue* as to what the state may be
|
||||
$ret->{$currnode}->{'status'}="ping";
|
||||
$ret->{$currnode}->{'appstatus'}=$status;
|
||||
$ret->{$currnode}->{'appsd'}=$appsd;
|
||||
$currnode="";
|
||||
%states=();
|
||||
} else {
|
||||
push @nodesetnodes,$currnode; #Aggregate call to nodeset
|
||||
}
|
||||
}
|
||||
$currnode=$tmpnode;
|
||||
$currnode =~ s/:$//;
|
||||
$currnode =~ s/\n$//;
|
||||
|
||||
|
||||
my $nip;
|
||||
if ($nip = xCAT::NetworkUtils->getipaddr($currnode)) { #reverse lookup may not resemble the nodename, key by ip
|
||||
if ($nodebyip{$nip}) {
|
||||
$currnode = $nodebyip{$nip};
|
||||
}
|
||||
}
|
||||
$installquerypossible=0; #reset possibility indicator
|
||||
%rsp=();
|
||||
unless ($deadnodes{$1}) {
|
||||
my $shortname;
|
||||
foreach (keys %deadnodes) {
|
||||
if (/\./) {
|
||||
$shortname = $_;
|
||||
$shortname =~ s/\..*//;
|
||||
}
|
||||
if ($currnode =~ /^$_\./ or ($shortname and $shortname eq $currnode)) {
|
||||
$currnode = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete $deadnodes{$currnode};
|
||||
} elsif ($currnode) {
|
||||
#if (/^MAC/) { #oops not all nmap records end with MAC
|
||||
if (/^PORT/) { next; }
|
||||
($port,$state) = split;
|
||||
if ($port and $port =~ /^(\d*)\// and $state eq 'open') {
|
||||
if ($1 eq "3001" and defined($chainhash{$currnode}->[0]->{currstate}) and $chainhash{$currnode}->[0]->{currstate} =~ /^install/) {
|
||||
$installquerypossible=1; #It is possible to actually query node
|
||||
} elsif ($1 ne "3001") {
|
||||
$states{$portservices{$1}}=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ip6 and scalar(@ip6s)) {
|
||||
open($fping,"nmap -6 -PS$ports,3001 -n --send-ip -p $ports,3001 $more_options ".join(' ',@ip6s). " 2> /dev/null|") or die("Can't start nmap: $!");
|
||||
} elsif (not $ip6 and scalar(@ips)) {
|
||||
open($fping,"nmap -PE -n --send-ip -p $ports,3001 $more_options ".join(' ',@ips). " 2> /dev/null|") or die("Can't start nmap: $!");
|
||||
} else { next; }
|
||||
while (<$fping>) {
|
||||
if (/Interesting ports on ([^ ]*)[: ]/ or /Nmap scan report for ([^ ]*)/) {
|
||||
my $tmpnode=$1;
|
||||
if ($currnode) { #if still thinking about last node, flush him out
|
||||
my $status = join ',',sort keys %states ;
|
||||
my $appsd="";
|
||||
foreach my $portnum(keys %portservices) {
|
||||
my $app_t=$portservices{$portnum};
|
||||
if ($states{$app_t}) {$appsd .= $app_t . "=up,";}
|
||||
else {$appsd .= $app_t . "=down,";}
|
||||
}
|
||||
$appsd =~ s/,$//;
|
||||
my $target=$currnode;
|
||||
if ($hostsents{$target} and $hostsents{$target}->[0]->{ip}) { $target = $hostsents{$target}->[0]->{ip}; }
|
||||
|
||||
if ($status or ($installquerypossible and $status = installer_query($target))) { #pingable, but no *clue* as to what the state may be
|
||||
$ret->{$currnode}->{'status'}="ping";
|
||||
$ret->{$currnode}->{'appstatus'}=$status;
|
||||
$ret->{$currnode}->{'appsd'}=$appsd;
|
||||
$currnode="";
|
||||
%states=();
|
||||
} else {
|
||||
push @nodesetnodes,$currnode; #Aggregate call to nodeset
|
||||
}
|
||||
}
|
||||
$currnode=$tmpnode;
|
||||
$currnode =~ s/:$//;
|
||||
$currnode =~ s/\n$//;
|
||||
|
||||
|
||||
my $nip;
|
||||
if ($nip = xCAT::NetworkUtils->getipaddr($currnode)) { #reverse lookup may not resemble the nodename, key by ip
|
||||
if ($nodebyip{$nip}) {
|
||||
$currnode = $nodebyip{$nip};
|
||||
}
|
||||
}
|
||||
$installquerypossible=0; #reset possibility indicator
|
||||
%rsp=();
|
||||
unless ($deadnodes{$currnode}) {
|
||||
my $shortname;
|
||||
foreach (keys %deadnodes) {
|
||||
if (/\./) {
|
||||
$shortname = $_;
|
||||
$shortname =~ s/\..*//;
|
||||
}
|
||||
if ($currnode =~ /^$_\./ or ($shortname and $shortname eq $currnode)) {
|
||||
$currnode = $_;
|
||||
last;
|
||||
}
|
||||
}
|
||||
}
|
||||
delete $deadnodes{$currnode};
|
||||
} elsif ($currnode) {
|
||||
#if (/^MAC/) { #oops not all nmap records end with MAC
|
||||
if (/^PORT/) { next; }
|
||||
($port,$state) = split;
|
||||
if ($port and $port =~ /^(\d*)\// and $state eq 'open') {
|
||||
if ($1 eq "3001" and defined($chainhash{$currnode}->[0]->{currstate}) and $chainhash{$currnode}->[0]->{currstate} =~ /^install/) {
|
||||
$installquerypossible=1; #It is possible to actually query node
|
||||
} elsif ($1 ne "3001") {
|
||||
$states{$portservices{$1}}=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($currnode) {
|
||||
my $status = join ',',sort keys %states ;
|
||||
my $appsd="";
|
||||
|
Loading…
Reference in New Issue
Block a user