diff options
author | Matthias Rampke <mr@soundcloud.com> | 2015-05-12 15:04:08 +0000 |
---|---|---|
committer | Matthias Rampke <mr@soundcloud.com> | 2015-05-12 15:04:08 +0000 |
commit | 57a6701dc9bdab243bd610d738730451de3aef9b (patch) | |
tree | 00e3fd595ce00e87ca866ab37b9134555b5cb016 /node_exporter.go | |
parent | b4f40ab13f1218e1d447d4e750565fa5a2421d6a (diff) | |
download | prometheus_node_collector-57a6701dc9bdab243bd610d738730451de3aef9b.tar.bz2 prometheus_node_collector-57a6701dc9bdab243bd610d738730451de3aef9b.tar.xz prometheus_node_collector-57a6701dc9bdab243bd610d738730451de3aef9b.zip |
Sort collector names.
This makes the `-collectors.print` output easier to read.
Diffstat (limited to 'node_exporter.go')
-rw-r--r-- | node_exporter.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/node_exporter.go b/node_exporter.go index 19ac81f..26966e5 100644 --- a/node_exporter.go +++ b/node_exporter.go | |||
@@ -9,6 +9,7 @@ import ( | |||
9 | _ "net/http/pprof" | 9 | _ "net/http/pprof" |
10 | "os" | 10 | "os" |
11 | "os/signal" | 11 | "os/signal" |
12 | "sort" | ||
12 | "strings" | 13 | "strings" |
13 | "sync" | 14 | "sync" |
14 | "syscall" | 15 | "syscall" |
@@ -142,8 +143,13 @@ func main() { | |||
142 | flag.Parse() | 143 | flag.Parse() |
143 | 144 | ||
144 | if *printCollectors { | 145 | if *printCollectors { |
145 | fmt.Printf("Available collectors:\n") | 146 | collectorNames := make(sort.StringSlice, 0, len(collector.Factories)) |
146 | for n, _ := range collector.Factories { | 147 | for n, _ := range collector.Factories { |
148 | collectorNames = append(collectorNames, n) | ||
149 | } | ||
150 | collectorNames.Sort() | ||
151 | fmt.Printf("Available collectors:\n") | ||
152 | for _, n := range collectorNames { | ||
147 | fmt.Printf(" - %s\n", n) | 153 | fmt.Printf(" - %s\n", n) |
148 | } | 154 | } |
149 | return | 155 | return |