Return error at Init for skip collectors early

This commit is contained in:
Thomas Roehl 2021-05-14 19:21:16 +02:00
parent 9b59429a93
commit 6b6e28d4c7
9 changed files with 19 additions and 9 deletions

View File

@ -13,9 +13,10 @@ type CpustatCollector struct {
MetricCollector
}
func (m *CpustatCollector) Init() {
func (m *CpustatCollector) Init() error {
m.name = "CpustatCollector"
m.setup()
return nil
}
func ParseStatLine(line string, out map[string]interface{}) {

View File

@ -16,9 +16,11 @@ type InfinibandCollector struct {
MetricCollector
}
func (m *InfinibandCollector) Init() {
func (m *InfinibandCollector) Init() error {
m.name = "InfinibandCollector"
m.setup()
_, err := ioutil.ReadFile(string(LIDFILE))
return err
}
func (m *InfinibandCollector) Read(interval time.Duration) {

View File

@ -71,7 +71,7 @@ func getSocketCpus() map[C.int]int {
return outmap
}
func (m *LikwidCollector) Init() {
func (m *LikwidCollector) Init() error {
m.name = "LikwidCollector"
m.setup()
cpulist := CpuList()
@ -111,6 +111,7 @@ func (m *LikwidCollector) Init() {
}
C.free(unsafe.Pointer(cstr))
}
return nil
}
func (m *LikwidCollector) Read(interval time.Duration) {

View File

@ -13,9 +13,10 @@ type LoadavgCollector struct {
MetricCollector
}
func (m *LoadavgCollector) Init() {
func (m *LoadavgCollector) Init() error {
m.name = "LoadavgCollector"
m.setup()
return nil
}
func (m *LoadavgCollector) Read(interval time.Duration) {

View File

@ -14,9 +14,11 @@ type LustreCollector struct {
MetricCollector
}
func (m *LustreCollector) Init() {
func (m *LustreCollector) Init() error {
m.name = "LustreCollector"
m.setup()
_, err := ioutil.ReadFile(string(LUSTREFILE))
return err
}
func (m *LustreCollector) Read(interval time.Duration) {

View File

@ -15,9 +15,10 @@ type MemstatCollector struct {
MetricCollector
}
func (m *MemstatCollector) Init() {
func (m *MemstatCollector) Init() error {
m.name = "MemstatCollector"
m.setup()
return nil
}
func (m *MemstatCollector) Read(interval time.Duration) {

View File

@ -10,7 +10,7 @@ import (
type MetricGetter interface {
Name() string
Init()
Init() error
Read(time.Duration)
Close()
GetNodeMetric() map[string]interface{}

View File

@ -15,9 +15,10 @@ type NetstatCollector struct {
MetricCollector
}
func (m *NetstatCollector) Init() {
func (m *NetstatCollector) Init() error {
m.name = "NetstatCollector"
m.setup()
return nil
}
func (m *NetstatCollector) Read(interval time.Duration) {

View File

@ -14,9 +14,10 @@ type TopProcsCollector struct {
MetricCollector
}
func (m *TopProcsCollector) Init() {
func (m *TopProcsCollector) Init() error {
m.name = "TopProcsCollector"
m.setup()
return nil
}
func (m *TopProcsCollector) Read(interval time.Duration) {