Skip to content

Commit

Permalink
Comments and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Jimenez committed Feb 18, 2016
1 parent 7170280 commit 8c6a660
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions plugins/inputs/mesos/mesos.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ var defaultMetrics = []string{
"tasks", "messages", "evqueue", "messages", "registrar",
}

var sampleConfig = `
# Timeout, in ms.
timeout = 100
# A list of Mesos masters. e.g. master1:5050, master2:5080, etc.
# The port can be skipped if using the default (5050)
# Default value is localhost:5050.
servers = ["localhost:5050"]
# Metrics groups to be collected.
# Default, all enabled.
metrics_collection = ["resources","master","system","slaves","frameworks","messages","evqueue","registrar"]
`

// SampleConfig returns a sample configuration block
func (m *Mesos) SampleConfig() string {
return sampleConfig
Expand All @@ -37,6 +49,7 @@ func (m *Mesos) Description() string {
return "Telegraf plugin for gathering metrics from N Mesos masters"
}

// Gather() metrics from given list of Mesos Masters
func (m *Mesos) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
var errorChannel chan error
Expand All @@ -60,6 +73,7 @@ func (m *Mesos) Gather(acc telegraf.Accumulator) error {
close(errorChannel)
errorStrings := []string{}

// Gather all errors for returning them at once
for err := range errorChannel {
if err != nil {
errorStrings = append(errorStrings, err.Error())
Expand All @@ -72,6 +86,7 @@ func (m *Mesos) Gather(acc telegraf.Accumulator) error {
return nil
}

// metricsDiff() returns set names for removal
func metricsDiff(w []string) []string {
b := []string{}
s := make(map[string]bool)
Expand All @@ -93,6 +108,7 @@ func metricsDiff(w []string) []string {
return b
}

// masterBlocks serves as kind of metrics registry groupping them in sets
func masterBlocks(g string) []string {
var m map[string][]string

Expand Down Expand Up @@ -233,19 +249,7 @@ func masterBlocks(g string) []string {
return ret
}

var sampleConfig = `
# Timeout, in ms.
timeout = 100
# A list of Mesos masters. e.g. master1:5050, master2:5080, etc.
# The port can be skipped if using the default (5050)
# Default value is localhost:5050.
servers = ["localhost:5050"]
# Metrics groups to be collected.
# Default, all enabled.
metrics_collection = ["resources","master","system","slaves","frameworks","messages","evqueue","registrar"]
`

// removeGroup(), remove unwanted groups
// removeGroup(), remove unwanted sets
func (m *Mesos) removeGroup(j *map[string]interface{}) {
var ok bool

Expand Down

0 comments on commit 8c6a660

Please sign in to comment.