mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-10-21 21:35:06 +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"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cclog "github.com/ClusterCockpit/cc-lib/ccLogger"
|
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
|
// Check if mmpmon is in executable search path
|
||||||
p, err := exec.LookPath(m.config.Mmpmon)
|
p, err := exec.LookPath(m.config.Mmpmon)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.ComponentError(m.name, "failed to find mmpmon binary '%s': %v", m.config.Mmpmon, err)
|
// if using sudo, the file must only be found, but exec.lookPath will give EPERM
|
||||||
return err
|
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
|
m.config.Mmpmon = p
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user