mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-10-21 13:25:07 +02:00
with sudo, ignore EPERM for exec.LookPath
This commit is contained in:
committed by
Thomas Gruber
parent
d6499935a4
commit
09cf89a951
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user