Remove flush_scope logic

This commit is contained in:
Vladimir Sagan 2016-06-23 11:11:44 +03:00 committed by Cameron Sparr
parent b0484d8a0c
commit 9c2ca805da
2 changed files with 3 additions and 25 deletions

View File

@ -41,7 +41,6 @@ All measurements have the following tags:
```
# [[inputs.cgroup]]
# flush_scope = 10 # optional (the fields will be divided into parts of 10 items)
# paths = [
# "/cgroup/memory", # root cgroup
# "/cgroup/memory/child1", # container cgroup

View File

@ -18,9 +18,8 @@ import (
const metricName = "cgroup"
type CGroup struct {
Paths []string `toml:"paths"`
Files []string `toml:"fields"`
FlushScope int `toml:"flush_scope"`
Paths []string `toml:"paths"`
Files []string `toml:"fields"`
}
var sampleConfig = `
@ -83,31 +82,11 @@ func (g *CGroup) gatherDir(dir string, acc telegraf.Accumulator) error {
tags := map[string]string{"path": dir}
if g.FlushScope <= 0 {
acc.AddFields(metricName, fields, tags)
return nil
}
writeWithBatches(acc, fields, tags, g.FlushScope)
acc.AddFields(metricName, fields, tags)
return nil
}
func writeWithBatches(acc telegraf.Accumulator, fields map[string]interface{}, tags map[string]string, scope int) {
for len(fields) > 0 {
batch := make(map[string]interface{})
for k, v := range fields {
batch[k] = v
delete(fields, k)
if len(batch) == scope || len(fields) == 0 {
break
}
}
acc.AddFields(metricName, batch, tags)
}
}
// ======================================================================
type pathInfo struct {