From 10945e7feefad8bd962f8419be01d5a8dfbfebf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Wed, 22 Jul 2026 19:50:30 -0300 Subject: [PATCH] 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> --- xCAT-server/lib/xcat/plugins/nodestat.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/nodestat.pm b/xCAT-server/lib/xcat/plugins/nodestat.pm index 201b59673..65f476022 100644 --- a/xCAT-server/lib/xcat/plugins/nodestat.pm +++ b/xCAT-server/lib/xcat/plugins/nodestat.pm @@ -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 = $_;