From 3f4e1af2225da92b417f7249bfd9709efdb2f378 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Wed, 11 Apr 2018 16:44:55 -0700 Subject: [PATCH] Add --console and --service to usage message in Windows (#3993) --- cmd/telegraf/telegraf.go | 42 --------------------------- cmd/telegraf/usage.go | 45 +++++++++++++++++++++++++++++ cmd/telegraf/usage_windows.go | 54 +++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 42 deletions(-) create mode 100644 cmd/telegraf/usage.go create mode 100644 cmd/telegraf/usage_windows.go diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index c02dce88b..c38d88c3f 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -73,48 +73,6 @@ func init() { } } -const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics. - -Usage: - - telegraf [commands|flags] - -The commands & flags are: - - config print out full sample configuration to stdout - version print the version to stdout - - --config configuration file to load - --test gather metrics once, print them to stdout, and exit - --config-directory directory containing additional *.conf files - --input-filter filter the input plugins to enable, separator is : - --output-filter filter the output plugins to enable, separator is : - --usage print usage for a plugin, ie, 'telegraf --usage mysql' - --debug print metrics as they're generated to stdout - --pprof-addr pprof address to listen on, format: localhost:6060 or :6060 - --quiet run in quiet mode - -Examples: - - # generate a telegraf config file: - telegraf config > telegraf.conf - - # generate config with only cpu input & influxdb output plugins defined - telegraf --input-filter cpu --output-filter influxdb config - - # run a single telegraf collection, outputing metrics to stdout - telegraf --config telegraf.conf --test - - # run telegraf with all plugins defined in config file - telegraf --config telegraf.conf - - # run telegraf, enabling the cpu & memory input, and influxdb output plugins - telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb - - # run telegraf with pprof - telegraf --config telegraf.conf --pprof-addr localhost:6060 -` - var stop chan struct{} func reloadLoop( diff --git a/cmd/telegraf/usage.go b/cmd/telegraf/usage.go new file mode 100644 index 000000000..2d36ede94 --- /dev/null +++ b/cmd/telegraf/usage.go @@ -0,0 +1,45 @@ +// +build !windows + +package main + +const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics. + +Usage: + + telegraf [commands|flags] + +The commands & flags are: + + config print out full sample configuration to stdout + version print the version to stdout + + --config configuration file to load + --test gather metrics once, print them to stdout, and exit + --config-directory directory containing additional *.conf files + --input-filter filter the input plugins to enable, separator is : + --output-filter filter the output plugins to enable, separator is : + --usage print usage for a plugin, ie, 'telegraf --usage mysql' + --debug print metrics as they're generated to stdout + --pprof-addr pprof address to listen on, format: localhost:6060 or :6060 + --quiet run in quiet mode + +Examples: + + # generate a telegraf config file: + telegraf config > telegraf.conf + + # generate config with only cpu input & influxdb output plugins defined + telegraf --input-filter cpu --output-filter influxdb config + + # run a single telegraf collection, outputing metrics to stdout + telegraf --config telegraf.conf --test + + # run telegraf with all plugins defined in config file + telegraf --config telegraf.conf + + # run telegraf, enabling the cpu & memory input, and influxdb output plugins + telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb + + # run telegraf with pprof + telegraf --config telegraf.conf --pprof-addr localhost:6060 +` diff --git a/cmd/telegraf/usage_windows.go b/cmd/telegraf/usage_windows.go new file mode 100644 index 000000000..b09435b9a --- /dev/null +++ b/cmd/telegraf/usage_windows.go @@ -0,0 +1,54 @@ +// +build windows + +package main + +const usage = `Telegraf, The plugin-driven server agent for collecting and reporting metrics. + +Usage: + + telegraf [commands|flags] + +The commands & flags are: + + config print out full sample configuration to stdout + version print the version to stdout + + --config configuration file to load + --test gather metrics once, print them to stdout, and exit + --config-directory directory containing additional *.conf files + --input-filter filter the input plugins to enable, separator is : + --output-filter filter the output plugins to enable, separator is : + --usage print usage for a plugin, ie, 'telegraf --usage mysql' + --debug print metrics as they're generated to stdout + --pprof-addr pprof address to listen on, format: localhost:6060 or :6060 + --quiet run in quiet mode + + --console run as console application + --service operate on service, one of: install, uninstall, start, stop + +Examples: + + # generate a telegraf config file: + telegraf config > telegraf.conf + + # generate config with only cpu input & influxdb output plugins defined + telegraf --input-filter cpu --output-filter influxdb config + + # run a single telegraf collection, outputing metrics to stdout + telegraf --config telegraf.conf --test + + # run telegraf with all plugins defined in config file + telegraf --config telegraf.conf + + # run telegraf, enabling the cpu & memory input, and influxdb output plugins + telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb + + # run telegraf with pprof + telegraf --config telegraf.conf --pprof-addr localhost:6060 + + # run telegraf without service controller + telegraf --console install --config "C:\Program Files\Telegraf\telegraf.conf" + + # install telegraf service + telegraf --service install --config "C:\Program Files\Telegraf\telegraf.conf" +`