From 3a96e6881b6b9eba84699a11aeddbe03476f9836 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Thu, 4 Feb 2016 20:24:16 -0500 Subject: [PATCH] Remove unused flag -debug.memprofile-file The option to write out a memory profile to file was removed in a730cff. Declaring flags as local variable does not only result in cleaner, more testable code, but also ensures that the program won't compile anymore when unused flags are left in place. --- node_exporter.go | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/node_exporter.go b/node_exporter.go index c9b9f1e6..ef570f20 100644 --- a/node_exporter.go +++ b/node_exporter.go @@ -25,34 +25,25 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/log" - "github.com/prometheus/node_exporter/collector" ) -const subsystem = "exporter" +const ( + defaultCollectors = "conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname,version,vmstat" +) var ( // Version of node_exporter. Set at build time. Version = "0.0.0.dev" - memProfile = flag.String("debug.memprofile-file", "", "Write memory profile to this file upon receipt of SIGUSR1.") - listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.") - metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") - enabledCollectors = flag.String("collectors.enabled", - filterAvailableCollectors("conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname,version,vmstat"), - "Comma-separated list of collectors to use.") - printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.") - - collectorLabelNames = []string{"collector", "result"} - scrapeDurations = prometheus.NewSummaryVec( prometheus.SummaryOpts{ Namespace: collector.Namespace, - Subsystem: subsystem, + Subsystem: "exporter", Name: "scrape_duration_seconds", Help: "node_exporter: Duration of a scrape job.", }, - collectorLabelNames, + []string{"collector", "result"}, ) ) @@ -107,9 +98,9 @@ func execute(name string, c collector.Collector, ch chan<- prometheus.Metric) { scrapeDurations.WithLabelValues(name, result).Observe(duration.Seconds()) } -func loadCollectors() (map[string]collector.Collector, error) { +func loadCollectors(list string) (map[string]collector.Collector, error) { collectors := map[string]collector.Collector{} - for _, name := range strings.Split(*enabledCollectors, ",") { + for _, name := range strings.Split(list, ",") { fn, ok := collector.Factories[name] if !ok { return nil, fmt.Errorf("collector '%s' not available", name) @@ -124,6 +115,12 @@ func loadCollectors() (map[string]collector.Collector, error) { } func main() { + var ( + listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.") + metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.") + enabledCollectors = flag.String("collectors.enabled", filterAvailableCollectors(defaultCollectors), "Comma-separated list of collectors to use.") + printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.") + ) flag.Parse() if *printCollectors { @@ -138,7 +135,7 @@ func main() { } return } - collectors, err := loadCollectors() + collectors, err := loadCollectors(*enabledCollectors) if err != nil { log.Fatalf("Couldn't load collectors: %s", err) }