mirror of
https://github.com/ClusterCockpit/cc-metric-collector.git
synced 2024-12-25 23:19:06 +01:00
Avoid labels in collector manager loop
This commit is contained in:
parent
c193b80083
commit
09b7538479
@ -104,29 +104,33 @@ func (cm *collectorManager) Start() {
|
|||||||
cm.wg.Add(1)
|
cm.wg.Add(1)
|
||||||
tick := make(chan time.Time)
|
tick := make(chan time.Time)
|
||||||
cm.ticker.AddChannel(tick)
|
cm.ticker.AddChannel(tick)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
// Collector manager is done
|
||||||
|
done := func() {
|
||||||
|
// close all metric collectors
|
||||||
|
for _, c := range cm.collectors {
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
|
cm.wg.Done()
|
||||||
|
cclog.ComponentDebug("CollectorManager", "DONE")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for done signal or timer event
|
||||||
for {
|
for {
|
||||||
CollectorManagerLoop:
|
|
||||||
select {
|
select {
|
||||||
case <-cm.done:
|
case <-cm.done:
|
||||||
for _, c := range cm.collectors {
|
done()
|
||||||
c.Close()
|
return
|
||||||
}
|
|
||||||
cm.wg.Done()
|
|
||||||
cclog.ComponentDebug("CollectorManager", "DONE")
|
|
||||||
break CollectorManagerLoop
|
|
||||||
case t := <-tick:
|
case t := <-tick:
|
||||||
for _, c := range cm.collectors {
|
for _, c := range cm.collectors {
|
||||||
CollectorManagerInputLoop:
|
// Wait for done signal or execute the collector
|
||||||
select {
|
select {
|
||||||
case <-cm.done:
|
case <-cm.done:
|
||||||
for _, c := range cm.collectors {
|
done()
|
||||||
c.Close()
|
return
|
||||||
}
|
|
||||||
cm.wg.Done()
|
|
||||||
cclog.ComponentDebug("CollectorManager", "DONE")
|
|
||||||
break CollectorManagerInputLoop
|
|
||||||
default:
|
default:
|
||||||
|
// Read metrics from collector c
|
||||||
cclog.ComponentDebug("CollectorManager", c.Name(), t)
|
cclog.ComponentDebug("CollectorManager", c.Name(), t)
|
||||||
c.Read(cm.duration, cm.output)
|
c.Read(cm.duration, cm.output)
|
||||||
}
|
}
|
||||||
@ -134,6 +138,8 @@ func (cm *collectorManager) Start() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// Collector manager is started
|
||||||
cclog.ComponentDebug("CollectorManager", "STARTED")
|
cclog.ComponentDebug("CollectorManager", "STARTED")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
lp "github.com/ClusterCockpit/cc-metric-collector/internal/ccMetric"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,7 +94,7 @@ func (m *MemstatCollector) Read(interval time.Duration, output chan lp.CCMetric)
|
|||||||
|
|
||||||
for match, name := range m.matches {
|
for match, name := range m.matches {
|
||||||
if _, exists := m.stats[match]; !exists {
|
if _, exists := m.stats[match]; !exists {
|
||||||
err = errors.New(fmt.Sprintf("Parse error for %s : %s", match, name))
|
err = fmt.Errorf("Parse error for %s : %s", match, name)
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user