From cbb91fb3328d5b50d47073108db5f90536ae915b Mon Sep 17 00:00:00 2001 From: Brian Brazil Date: Wed, 4 Jun 2014 14:09:33 +0100 Subject: [PATCH] Add option to print out available collectors. Fix typo. --- node_exporter.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/node_exporter.go b/node_exporter.go index a75699f3..357927e8 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "flag" + "fmt" "io/ioutil" "log" "net/http" @@ -24,7 +25,8 @@ var ( configFile = flag.String("config", "node_exporter.conf", "config file.") memProfile = flag.String("memprofile", "", "write memory profile to this file") listeningAddress = flag.String("listen", ":8080", "address to listen on") - enabledCollectors = flag.String("enabledCollectors", "attributes,diskstats,loadavg,meminfo,netdev", "comma seperated list of collectors to use") + enabledCollectors = flag.String("enabledCollectors", "attributes,diskstats,loadavg,meminfo,netdev", "comma-seperated list of collectors to use") + printCollectors = flag.Bool("printCollectors", false, "If true, print available collectors and exit") interval = flag.Duration("interval", 60*time.Second, "refresh interval") scrapeDurations = prometheus.NewDefaultHistogram() metricsUpdated = prometheus.NewGauge() @@ -32,6 +34,13 @@ var ( func main() { flag.Parse() + if *printCollectors { + fmt.Printf("Available collectors:\n") + for n, _ := range collector.Factories { + fmt.Printf(" - %s\n", n) + } + return + } registry := prometheus.NewRegistry() collectors, err := loadCollectors(*configFile, registry) if err != nil {