From 09cf89a9518bb56e247bd2d443b00dcc0ff848ad Mon Sep 17 00:00:00 2001 From: Roland Pabel Date: Thu, 16 Oct 2025 15:03:26 +0200 Subject: [PATCH] with sudo, ignore EPERM for exec.LookPath --- collectors/gpfsMetric.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/collectors/gpfsMetric.go b/collectors/gpfsMetric.go index 6bfc62c..d98eee5 100644 --- a/collectors/gpfsMetric.go +++ b/collectors/gpfsMetric.go @@ -18,6 +18,7 @@ import ( "os/user" "strconv" "strings" + "syscall" "time" cclog "github.com/ClusterCockpit/cc-lib/ccLogger" @@ -116,8 +117,13 @@ func (m *GpfsCollector) Init(config json.RawMessage) error { // Check if mmpmon is in executable search path p, err := exec.LookPath(m.config.Mmpmon) if err != nil { - cclog.ComponentError(m.name, "failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err) - return err + // if using sudo, the file must only be found, but exec.lookPath will give EPERM + if m.config.Sudo && err == syscall.EPERM { + cclog.ComponentWarn(m.name, "got error looking for mmpmon binary '%s': %v . This is expected when using sudo, continuing.", m.config.Mmpmon, err) + } else { + cclog.ComponentError(m.name, "failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err) + return err + } } m.config.Mmpmon = p