Print webhook plugin after service plugin.

This commit is contained in:
Cyril Duez 2016-05-27 12:19:43 +02:00
parent 0380ea2e70
commit 9e8dfcae17
1 changed files with 32 additions and 8 deletions

View File

@ -246,6 +246,13 @@ var serviceInputHeader = `
###############################################################################
`
var webhookInputHeader = `
###############################################################################
# WEBHOOK INPUT PLUGINS #
###############################################################################
`
// PrintSampleConfig prints the sample config
func PrintSampleConfig(inputFilters []string, outputFilters []string) {
fmt.Printf(header)
@ -292,11 +299,16 @@ func printFilteredInputs(inputFilters []string, commented bool) {
}
sort.Strings(pnames)
// cache service inputs to print them at the end
servInputs := make(map[string]telegraf.ServiceInput)
// cache service inputs to print them after inputs
servInputs := make(map[string]telegraf.Input)
// for alphabetical looping:
servInputNames := []string{}
// cache service inputs to print them after at the end
webhookInputs := make(map[string]telegraf.Input)
// for alphabetical looping:
webhookInputNames := []string{}
// Print Inputs
for _, pname := range pnames {
creator := inputs.Inputs[pname]
@ -307,19 +319,31 @@ func printFilteredInputs(inputFilters []string, commented bool) {
servInputs[pname] = p
servInputNames = append(servInputNames, pname)
continue
case telegraf.WebhookInput:
webhookInputs[pname] = p
webhookInputNames = append(webhookInputNames, pname)
continue
}
printConfig(pname, input, "inputs", commented)
}
// Print Service Inputs
if len(servInputs) == 0 {
// Print service input
printOtherInputs(serviceInputHeader, servInputs, servInputNames, commented)
// Print webhook input
printOtherInputs(webhookInputHeader, webhookInputs, webhookInputNames, commented)
}
func printOtherInputs(header string, inputs map[string]telegraf.Input, names []string, commented bool) {
if len(names) == 0 {
return
}
sort.Strings(servInputNames)
fmt.Printf(serviceInputHeader)
for _, name := range servInputNames {
printConfig(name, servInputs[name], "inputs", commented)
sort.Strings(names)
fmt.Printf(header)
for _, name := range names {
printConfig(name, inputs[name], "inputs", commented)
}
}