From 57a6701dc9bdab243bd610d738730451de3aef9b Mon Sep 17 00:00:00 2001 From: Matthias Rampke Date: Tue, 12 May 2015 15:04:08 +0000 Subject: [PATCH] Sort collector names. This makes the `-collectors.print` output easier to read. --- node_exporter.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/node_exporter.go b/node_exporter.go index 19ac81fe..26966e54 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -9,6 +9,7 @@ import ( _ "net/http/pprof" "os" "os/signal" + "sort" "strings" "sync" "syscall" @@ -142,8 +143,13 @@ func main() { flag.Parse() if *printCollectors { - fmt.Printf("Available collectors:\n") + collectorNames := make(sort.StringSlice, 0, len(collector.Factories)) for n, _ := range collector.Factories { + collectorNames = append(collectorNames, n) + } + collectorNames.Sort() + fmt.Printf("Available collectors:\n") + for _, n := range collectorNames { fmt.Printf(" - %s\n", n) } return