Fix error print in LustreCollector

This commit is contained in:
Thomas Roehl 2022-03-04 11:32:10 +01:00
parent 07af660e50
commit f1d2828e1d

View File

@ -110,15 +110,17 @@ func (m *LustreCollector) Init(config json.RawMessage) error {
"inode_permission": {"lustre_inode_permission": 1}}
// Lustre file system statistics can only be queried by user root
if !m.config.Sudo {
user, err := user.Current()
if err != nil {
cclog.ComponentError(m.name, "Failed to get current user:", err.Error())
return err
}
if user.Uid != "0" {
cclog.ComponentError(m.name, "Lustre file system statistics can only be queried by user root:", err.Error())
cclog.ComponentError(m.name, "Lustre file system statistics can only be queried by user root")
return err
}
}
m.matches = make(map[string]map[string]int)
for lineprefix, names := range defmatches {