Skip to content

Commit

Permalink
Redirect help output from stderr to stdout
Browse files Browse the repository at this point in the history
Send output to stdout so that Nagios XI (and presumably similar
systems) can poll plugins from this project for their help
output and display within the admin web UI.

refs GH-555
  • Loading branch information
atc0005 committed Dec 17, 2021
1 parent 77ca3b5 commit a3b17cb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,12 @@ type Config struct {
// Usage is a custom override for the default Help text provided by the flag
// package. Here we prepend some additional metadata to the existing output.
var Usage = func() {

// Override default of stderr as destination for help output. This allows
// Nagios XI and similar monitoring systems to call plugins with the
// `--help` flag and have it display within the Admin web UI.
flag.CommandLine.SetOutput(os.Stdout)

fmt.Fprintln(flag.CommandLine.Output(), "\n"+Version()+"\n")
fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
flag.PrintDefaults()
Expand Down

0 comments on commit a3b17cb

Please sign in to comment.