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,14 +110,16 @@ func (m *LustreCollector) Init(config json.RawMessage) error {
"inode_permission": {"lustre_inode_permission": 1}} "inode_permission": {"lustre_inode_permission": 1}}
// Lustre file system statistics can only be queried by user root // Lustre file system statistics can only be queried by user root
user, err := user.Current() if !m.config.Sudo {
if err != nil { user, err := user.Current()
cclog.ComponentError(m.name, "Failed to get current user:", err.Error()) if err != nil {
return err 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()) if user.Uid != "0" {
return err 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) m.matches = make(map[string]map[string]int)