feat(inputs.lustre2): Skip brw_stats in case of insufficient permissions (#15045)

This commit is contained in:
Luke Yeager 2024-03-27 04:43:35 -05:00 committed by GitHub
parent aa030b569a
commit 3d45e32b54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 3 deletions

View File

@ -9,6 +9,7 @@ package lustre2
import ( import (
_ "embed" _ "embed"
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -30,9 +31,10 @@ type tags struct {
// Lustre proc files can change between versions, so we want to future-proof // Lustre proc files can change between versions, so we want to future-proof
// by letting people choose what to look at. // by letting people choose what to look at.
type Lustre2 struct { type Lustre2 struct {
MgsProcfiles []string `toml:"mgs_procfiles"` MgsProcfiles []string `toml:"mgs_procfiles"`
OstProcfiles []string `toml:"ost_procfiles"` OstProcfiles []string `toml:"ost_procfiles"`
MdsProcfiles []string `toml:"mds_procfiles"` MdsProcfiles []string `toml:"mds_procfiles"`
Log telegraf.Logger `toml:"-"`
// used by the testsuite to generate mock sysfs and procfs files // used by the testsuite to generate mock sysfs and procfs files
rootdir string rootdir string
@ -526,6 +528,10 @@ func (l *Lustre2) getLustreProcBrwStats(fileglob string, wantedFields []*mapping
wholeFile, err := os.ReadFile(file) wholeFile, err := os.ReadFile(file)
if err != nil { if err != nil {
if errors.Is(err, os.ErrPermission) {
l.Log.Debugf("%s", err)
continue
}
return fmt.Errorf("failed to read file %s: %w", file, err) return fmt.Errorf("failed to read file %s: %w", file, err)
} }
lines := strings.Split(string(wholeFile), "\n") lines := strings.Split(string(wholeFile), "\n")