From c35ab808931f130d17f22222d3b74c1b1bed91e8 Mon Sep 17 00:00:00 2001 From: Ali Alrahahleh Date: Tue, 24 May 2016 15:53:46 -0700 Subject: [PATCH] reformat --- plugins/inputs/graylog/graylog.go | 24 ++++++++++++------------ plugins/inputs/httpjson/httpjson.go | 14 ++++++-------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/plugins/inputs/graylog/graylog.go b/plugins/inputs/graylog/graylog.go index c886528c3..479f5229b 100644 --- a/plugins/inputs/graylog/graylog.go +++ b/plugins/inputs/graylog/graylog.go @@ -1,18 +1,18 @@ package graylog import ( + "bytes" + "encoding/json" "errors" "fmt" - "strconv" - "bytes" - "regexp" "io/ioutil" "net/http" "net/url" + "regexp" + "strconv" "strings" "sync" "time" - "encoding/json" "github.com/influxdata/telegraf" "github.com/influxdata/telegraf/internal" @@ -21,11 +21,11 @@ import ( ) type GrayLog struct { - Name string - Servers []string - TagKeys []string - Metrics []string - Headers map[string]string + Name string + Servers []string + TagKeys []string + Metrics []string + Headers map[string]string // Path to CA file SSLCA string `toml:"ssl_ca"` @@ -55,7 +55,7 @@ type HTTPClient interface { } type Messagebody struct { - Metrics []string `json:"metrics"` + Metrics []string `json:"metrics"` } type RealHTTPClient struct { @@ -222,10 +222,10 @@ func (h *GrayLog) gatherServer( for k, v := range metric.Fields() { re, _ := regexp.Compile(`metrics_([0-9]+)`) match := re.FindAllStringSubmatch(k, -1) - if(match != nil) { + if match != nil { i, _ := strconv.Atoi(match[0][1]) fields[name_list[i]] = v - } + } } fields["response_time"] = responseTime acc.AddFields(metric.Name(), fields, metric.Tags()) diff --git a/plugins/inputs/httpjson/httpjson.go b/plugins/inputs/httpjson/httpjson.go index 00487cd3e..744563b3f 100644 --- a/plugins/inputs/httpjson/httpjson.go +++ b/plugins/inputs/httpjson/httpjson.go @@ -244,15 +244,13 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) { } } - // Create + send request - body := data.Encode() - body_attr := data.Get('__body') - if body_attr != "" { - list := strings.Split(data.Encode(), '=') - body = list[1] - } + body_attr := data.Get("__body") + http_body := data.Encode() + if body_attr != "" { + http_body = body_attr + } req, err := http.NewRequest(h.Method, requestURL.String(), - strings.NewReader(body)) + strings.NewReader(http_body)) if err != nil { return "", -1, err }