go fmt run over jolokia.go

This commit is contained in:
saiello 2015-10-29 14:48:39 +01:00 committed by Cameron Sparr
parent 40d8aeecb0
commit 62270a3697
1 changed files with 71 additions and 78 deletions

View File

@ -13,7 +13,6 @@ import (
"github.com/influxdb/telegraf/plugins"
)
type Server struct {
Name string
Host string
@ -28,14 +27,12 @@ type Metric struct {
}
type Jolokia struct {
Context string
Servers []Server
Metrics []Metric
Tags map[string]string
}
func (j *Jolokia) SampleConfig() string {
return `[jolokia]
context = "/jolokia/read"
@ -70,8 +67,6 @@ func (j *Jolokia) Description() string {
return "Read JMX metrics through Jolokia"
}
func getAttr(requestUrl *url.URL) (map[string]interface{}, error) {
//make request
resp, err := http.Get(requestUrl.String())
@ -110,7 +105,7 @@ func (m *Metric) shouldPass(field string) bool {
if m.Pass != nil {
for _, pass := range m.Pass{
for _, pass := range m.Pass {
if strings.HasPrefix(field, pass) {
return true
}
@ -121,7 +116,7 @@ func (m *Metric) shouldPass(field string) bool {
if m.Drop != nil {
for _, drop := range m.Drop{
for _, drop := range m.Drop {
if strings.HasPrefix(field, drop) {
return false
}
@ -135,7 +130,7 @@ func (m *Metric) shouldPass(field string) bool {
func (m *Metric) filterFields(fields map[string]interface{}) map[string]interface{} {
for field, _ := range fields{
for field, _ := range fields {
if !m.shouldPass(field) {
delete(fields, field)
}
@ -144,7 +139,6 @@ func (m *Metric) filterFields(fields map[string]interface{}) map[string]interfac
return fields
}
func (j *Jolokia) Gather(acc plugins.Accumulator) error {
context := j.Context //"/jolokia/read"
@ -152,11 +146,10 @@ func (j *Jolokia) Gather(acc plugins.Accumulator) error {
metrics := j.Metrics
tags := j.Tags
if tags == nil{
if tags == nil {
tags = map[string]string{}
}
for _, server := range servers {
for _, metric := range metrics {
@ -182,7 +175,7 @@ func (j *Jolokia) Gather(acc plugins.Accumulator) error {
case interface{}:
acc.Add(measurement, values.(interface{}), tags)
}
}else{
} else {
fmt.Printf("Missing key 'value' in '%s' output response\n", requestUrl.String())
}
}