diff --git a/README.md b/README.md index dfe96b5..fdf5278 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ Metric timestamp precision will be set according to the polling interval, so it /path/to/ovirtstat --config /path/to/ovirtstat.conf ``` -* Wait for the poll_interval or press enter. You should see lines like those in the Example output below. +* Press enter to force the collectin of metrics. You should see lines like those in the Example output below. # Example output diff --git a/cmd/main.go b/cmd/main.go index bb6559e..e8b6712 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -30,7 +30,7 @@ func main() { "how often to send metrics", ) configFile = flag.String("config", "", "path to the config file for this plugin") - showVersion = flag.Bool("version", false, "show ovirtstat version and exit") + showVersion = flag.Bool("version", false, "display ovirtstat version and exit") err error ) @@ -42,6 +42,23 @@ func main() { } oV := ovirtstat.New() oV.SetVersion(Version) + for _, col := range flag.Args() { + switch col { + case "help": + help() + os.Exit(0) + case "version": + fmt.Println(pluginName, Version) + os.Exit(0) + case "config": + fmt.Println(oV.SampleConfig()) + os.Exit(0) + case "run": + default: + help() + os.Exit(1) + } + } // load config an wait for stdin signal from telegraf to gather data if *configFile != "" { @@ -73,3 +90,12 @@ func main() { } oV.Stop() } + +func help() { + fmt.Println(pluginName + " [--help] [--config ] command") + fmt.Println("COMMANDS:") + fmt.Println(" help Display options and commands and exit") + fmt.Println(" config Display full sample configuration and exit") + fmt.Println(" version Display current version and exit") + fmt.Println(" run Run as telegraf execd input plugin using signal=stdin. This is the default command.") +}