2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-07-31 18:19:40 +00:00

fix(nodestat): report a clear error when fping is missing

nodestat -f runs fping to reach the nodes; if the fping package is not
installed the pipe yielded no output and nodestat silently returned an empty
result. Check that an fping binary exists before running it and emit an
explicit "must install fping" error otherwise.

Recovered from the unmerged lenovobuild branch (original f0c88182), reworked
to test for the binary directly: the original inferred fping's presence from
whether the pipe produced output, which false-positived (reporting fping
missing) when fping was present but every node was unresolvable -- caught in
lab validation.

Co-authored-by: Jarrod Johnson <10814490+jjohnson42@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-07-22 19:50:30 -03:00
parent cf44f51463
commit 10945e7fee
+12 -1
View File
@@ -796,7 +796,18 @@ sub process_request_port {
if (@nodes > 0) {
my $node;
my $fping;
open($fping, "fping " . join(' ', @nodes) . " 2> /dev/null|") or die("Can't start fping: $!");
my $fpingcmd;
for my $fp (qw(/usr/sbin/fping /usr/bin/fping /sbin/fping /bin/fping /usr/local/sbin/fping /usr/local/bin/fping)) {
if (-x $fp) { $fpingcmd = $fp; last; }
}
unless ($fpingcmd) {
my $rsp = {};
$rsp->{error}->[0] =
"Unable to find fping on system, must install fping package to use nodestat -f";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return $status;
}
open($fping, "$fpingcmd " . join(' ', @nodes) . " 2> /dev/null|") or die("Can't start fping: $!");
while (<$fping>) {
my %rsp;
my $node = $_;