Skip to content

Commit

Permalink
cmd/scollector: scollector.* metrics disabled properly with DisableSelf
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Peterson committed Jun 26, 2015
1 parent 3cb999d commit 065aaa8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmd/scollector/collectors/interval.go
Expand Up @@ -33,6 +33,8 @@ func (c *IntervalCollector) Init() {
}
}

var DisableSelf bool

func (c *IntervalCollector) Run(dpchan chan<- *opentsdb.DataPoint) {
if c.Enable != nil {
go func() {
Expand All @@ -45,7 +47,7 @@ func (c *IntervalCollector) Run(dpchan chan<- *opentsdb.DataPoint) {
}
}()
}
tags := opentsdb.TagSet{"collector": c.Name(), "os": runtime.GOOS}

for {
interval := c.Interval
if interval == 0 {
Expand All @@ -61,8 +63,11 @@ func (c *IntervalCollector) Run(dpchan chan<- *opentsdb.DataPoint) {
slog.Errorf("%v: %v", c.Name(), err)
result = 1
}
Add(&md, "scollector.collector.duration", timeFinish.Seconds(), tags, metadata.Gauge, metadata.Second, "Duration in seconds for each collector run.")
Add(&md, "scollector.collector.error", result, tags, metadata.Gauge, metadata.Ok, "Status of collector run. 1=Error, 0=Success.")
if !DisableSelf {
tags := opentsdb.TagSet{"collector": c.Name(), "os": runtime.GOOS}
Add(&md, "scollector.collector.duration", timeFinish.Seconds(), tags, metadata.Gauge, metadata.Second, "Duration in seconds for each collector run.")
Add(&md, "scollector.collector.error", result, tags, metadata.Gauge, metadata.Ok, "Status of collector run. 1=Error, 0=Success.")
}
for _, dp := range md {
dpchan <- dp
}
Expand Down
1 change: 1 addition & 0 deletions cmd/scollector/main.go
Expand Up @@ -238,6 +238,7 @@ func main() {
collect.Debug = *flagDebug
util.Debug = *flagDebug
collect.DisableDefaultCollectors = conf.DisableSelf
collectors.DisableSelf = conf.DisableSelf
c := collectors.Search(conf.Filter)
if len(c) == 0 {
slog.Fatalf("Filter %v matches no collectors.", conf.Filter)
Expand Down

0 comments on commit 065aaa8

Please sign in to comment.