From ea7c4f4ec7be34715c39c799603a1c572d4304f3 Mon Sep 17 00:00:00 2001 From: Roland Pabel Date: Fri, 17 Oct 2025 09:11:18 +0200 Subject: [PATCH] correctly check for EACCESS when searching for mmpmon with exec.LookPath --- collectors/gpfsMetric.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/collectors/gpfsMetric.go b/collectors/gpfsMetric.go index d98eee5..8950187 100644 --- a/collectors/gpfsMetric.go +++ b/collectors/gpfsMetric.go @@ -11,6 +11,7 @@ import ( "bufio" "bytes" "encoding/json" + "errors" "fmt" "io" "log" @@ -117,11 +118,11 @@ 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 { - // 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) + // if using sudo, the file must be found, but exec.lookPath will give EACCES + if m.config.Sudo && errors.Is(err, syscall.EACCES) { + cclog.ComponentWarn(m.name, fmt.Sprintf("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) + cclog.ComponentError(m.name, fmt.Sprintf("failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err)) return err } }