From 3249030257e1382d02ed899de9c2752a66fd3a26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=85=89=E6=9D=83?= Date: Sun, 6 Mar 2016 20:08:51 +0800 Subject: [PATCH] add flags '-input-list' and '-output-list' for telegraf command --- cmd/telegraf/telegraf.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index ec8e6315a..b07f0d303 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -13,6 +13,7 @@ import ( "github.com/influxdata/telegraf/internal/config" "github.com/influxdata/telegraf/plugins/inputs" _ "github.com/influxdata/telegraf/plugins/inputs/all" + "github.com/influxdata/telegraf/plugins/outputs" _ "github.com/influxdata/telegraf/plugins/outputs/all" ) @@ -30,12 +31,13 @@ var fSampleConfig = flag.Bool("sample-config", false, var fPidfile = flag.String("pidfile", "", "file to write our pid to") var fInputFilters = flag.String("input-filter", "", "filter the inputs to enable, separator is :") +var fInpuList = flag.Bool("input-list", false, "print all the plugins inputs") var fOutputFilters = flag.String("output-filter", "", "filter the outputs to enable, separator is :") +var fOutputList = flag.Bool("output-list", false, + "print all the available outputs") var fUsage = flag.String("usage", "", "print usage for a plugin, ie, 'telegraf -usage mysql'") -var fUsageList = flag.Bool("usage-list", false, "print all the plugins inputs") - var fInputFiltersLegacy = flag.String("filter", "", "filter the inputs to enable, separator is :") var fOutputFiltersLegacy = flag.String("outputfilter", "", @@ -60,9 +62,10 @@ The flags are: -sample-config print out full sample configuration to stdout -config-directory directory containing additional *.conf files -input-filter filter the input plugins to enable, separator is : + -input-list print all the plugins inputs -output-filter filter the output plugins to enable, separator is : + -output-list print all the available outputs -usage print usage for a plugin, ie, 'telegraf -usage mysql' - -usage-list print all the plugins input -debug print metrics as they're generated to stdout -quiet run in quiet mode -version print the version to stdout @@ -117,6 +120,13 @@ func main() { outputFilters = strings.Split(":"+outputFilter+":", ":") } + if *fOutputList { + fmt.Println("The outputs available:") + for k, _ := range outputs.Outputs { + fmt.Printf(" %s\n", k) + } + } + if *fVersion { v := fmt.Sprintf("Telegraf - Version %s", Version) fmt.Println(v) @@ -137,8 +147,8 @@ func main() { return } - if *fUsageList { - fmt.Println("The plugin inputs avaiable:") + if *fInpuList { + fmt.Println("The plugin inputs available:") for k, _ := range inputs.Inputs { fmt.Printf(" %s\n", k) }