mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2025-10-21 05:15:07 +02:00
correctly check for EACCESS when searching for mmpmon with exec.LookPath
This commit is contained in:
committed by
Thomas Gruber
parent
09cf89a951
commit
ea7c4f4ec7
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user