From ddf438dac00d32a77ae4a5e9a2b724e666bca3da Mon Sep 17 00:00:00 2001 From: JP Date: Wed, 12 Aug 2015 15:17:50 -0500 Subject: [PATCH] add missing import and Tag marshalling --- cmd/telegraf/telegraf.go | 6 ++++++ config.go | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index d6fdd965b..f01ab947c 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -9,6 +9,7 @@ import ( "strings" "github.com/influxdb/telegraf" + _ "github.com/influxdb/telegraf/outputs/all" _ "github.com/influxdb/telegraf/plugins/all" ) @@ -63,6 +64,10 @@ func main() { if err != nil { log.Fatal(err) } + if len(outputs) == 0 { + log.Printf("Error: no ouputs found, did you provide a config file?") + os.Exit(1) + } plugins, err := ag.LoadPlugins(*fPLuginsFilter) if err != nil { @@ -111,6 +116,7 @@ func main() { log.Printf("Agent Config: Interval:%s, Debug:%#v, Hostname:%#v\n", ag.Interval, ag.Debug, ag.Hostname) } + log.Printf("Tags enabled: %v", config.ListTags) if *fPidfile != "" { f, err := os.Create(*fPidfile) diff --git a/config.go b/config.go index db49dfa2f..cba6a9489 100644 --- a/config.go +++ b/config.go @@ -273,6 +273,7 @@ func LoadConfig(path string) (*Config, error) { } c := &Config{ + Tags: make(map[string]string), plugins: make(map[string]*ast.Table), outputs: make(map[string]*ast.Table), } @@ -286,6 +287,10 @@ func LoadConfig(path string) (*Config, error) { switch name { case "agent": c.agent = subtbl + case "tags": + if err := toml.UnmarshalTable(subtbl, c.Tags); err != nil { + return nil, errInvalidConfig + } case "outputs": for outputName, outputVal := range subtbl.Fields { outputSubtbl, ok := outputVal.(*ast.Table)