diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 7d42970ba..6bfd957fd 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -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 () { if (/Host (.*) \(.*\) appears to be up/) { diff --git a/perl-xCAT/xCAT/PPCenergy.pm b/perl-xCAT/xCAT/PPCenergy.pm index eb5d6abe9..eb8c53723 100644 --- a/perl-xCAT/xCAT/PPCenergy.pm +++ b/perl-xCAT/xCAT/PPCenergy.pm @@ -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 () { #print "$_\n"; diff --git a/perl-xCAT/xCAT/SLP.pm b/perl-xCAT/xCAT/SLP.pm index 3e8c5f438..d84d0a8ac 100755 --- a/perl-xCAT/xCAT/SLP.pm +++ b/perl-xCAT/xCAT/SLP.pm @@ -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)) { diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index e644c375a..8ed823d11 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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". diff --git a/xCAT-client/bin/pping b/xCAT-client/bin/pping index e08755fe5..40af26b2e 100755 --- a/xCAT-client/bin/pping +++ b/xCAT-client/bin/pping @@ -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 () { if (/Host (.*) \(.*\) appears to be up/) { diff --git a/xCAT-server/lib/xcat/plugins/nodestat.pm b/xCAT-server/lib/xcat/plugins/nodestat.pm index 2201d7d2e..e8f04b181 100644 --- a/xCAT-server/lib/xcat/plugins/nodestat.pm +++ b/xCAT-server/lib/xcat/plugins/nodestat.pm @@ -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="";