aboutsummaryrefslogtreecommitdiff
path: root/node_exporter.go
diff options
context:
space:
mode:
authorTobias Schmidt <ts@soundcloud.com>2016-02-04 20:24:16 -0500
committerTobias Schmidt <ts@soundcloud.com>2016-02-04 20:24:16 -0500
commit3a96e6881b6b9eba84699a11aeddbe03476f9836 (patch)
treecbd4d509653c91764122120aa4907030d07e19b3 /node_exporter.go
parent20ecedd0b4c983bd7b88f97cd7a21461988a6c12 (diff)
downloadprometheus_node_collector-3a96e6881b6b9eba84699a11aeddbe03476f9836.tar.bz2
prometheus_node_collector-3a96e6881b6b9eba84699a11aeddbe03476f9836.tar.xz
prometheus_node_collector-3a96e6881b6b9eba84699a11aeddbe03476f9836.zip
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.
Diffstat (limited to 'node_exporter.go')
-rw-r--r--node_exporter.go31
1 files changed, 14 insertions, 17 deletions
diff --git a/node_exporter.go b/node_exporter.go
index c9b9f1e..ef570f2 100644
--- a/node_exporter.go
+++ b/node_exporter.go
@@ -25,34 +25,25 @@ import (
25 25
26 "github.com/prometheus/client_golang/prometheus" 26 "github.com/prometheus/client_golang/prometheus"
27 "github.com/prometheus/common/log" 27 "github.com/prometheus/common/log"
28
29 "github.com/prometheus/node_exporter/collector" 28 "github.com/prometheus/node_exporter/collector"
30) 29)
31 30
32const subsystem = "exporter" 31const (
32 defaultCollectors = "conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname,version,vmstat"
33)
33 34
34var ( 35var (
35 // Version of node_exporter. Set at build time. 36 // Version of node_exporter. Set at build time.
36 Version = "0.0.0.dev" 37 Version = "0.0.0.dev"
37 38
38 memProfile = flag.String("debug.memprofile-file", "", "Write memory profile to this file upon receipt of SIGUSR1.")
39 listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.")
40 metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
41 enabledCollectors = flag.String("collectors.enabled",
42 filterAvailableCollectors("conntrack,diskstats,entropy,filefd,filesystem,loadavg,mdadm,meminfo,netdev,netstat,sockstat,stat,textfile,time,uname,version,vmstat"),
43 "Comma-separated list of collectors to use.")
44 printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.")
45
46 collectorLabelNames = []string{"collector", "result"}
47
48 scrapeDurations = prometheus.NewSummaryVec( 39 scrapeDurations = prometheus.NewSummaryVec(
49 prometheus.SummaryOpts{ 40 prometheus.SummaryOpts{
50 Namespace: collector.Namespace, 41 Namespace: collector.Namespace,
51 Subsystem: subsystem, 42 Subsystem: "exporter",
52 Name: "scrape_duration_seconds", 43 Name: "scrape_duration_seconds",
53 Help: "node_exporter: Duration of a scrape job.", 44 Help: "node_exporter: Duration of a scrape job.",
54 }, 45 },
55 collectorLabelNames, 46 []string{"collector", "result"},
56 ) 47 )
57) 48)
58 49
@@ -107,9 +98,9 @@ func execute(name string, c collector.Collector, ch chan<- prometheus.Metric) {
107 scrapeDurations.WithLabelValues(name, result).Observe(duration.Seconds()) 98 scrapeDurations.WithLabelValues(name, result).Observe(duration.Seconds())
108} 99}
109 100
110func loadCollectors() (map[string]collector.Collector, error) { 101func loadCollectors(list string) (map[string]collector.Collector, error) {
111 collectors := map[string]collector.Collector{} 102 collectors := map[string]collector.Collector{}
112 for _, name := range strings.Split(*enabledCollectors, ",") { 103 for _, name := range strings.Split(list, ",") {
113 fn, ok := collector.Factories[name] 104 fn, ok := collector.Factories[name]
114 if !ok { 105 if !ok {
115 return nil, fmt.Errorf("collector '%s' not available", name) 106 return nil, fmt.Errorf("collector '%s' not available", name)
@@ -124,6 +115,12 @@ func loadCollectors() (map[string]collector.Collector, error) {
124} 115}
125 116
126func main() { 117func main() {
118 var (
119 listenAddress = flag.String("web.listen-address", ":9100", "Address on which to expose metrics and web interface.")
120 metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
121 enabledCollectors = flag.String("collectors.enabled", filterAvailableCollectors(defaultCollectors), "Comma-separated list of collectors to use.")
122 printCollectors = flag.Bool("collectors.print", false, "If true, print available collectors and exit.")
123 )
127 flag.Parse() 124 flag.Parse()
128 125
129 if *printCollectors { 126 if *printCollectors {
@@ -138,7 +135,7 @@ func main() {
138 } 135 }
139 return 136 return
140 } 137 }
141 collectors, err := loadCollectors() 138 collectors, err := loadCollectors(*enabledCollectors)
142 if err != nil { 139 if err != nil {
143 log.Fatalf("Couldn't load collectors: %s", err) 140 log.Fatalf("Couldn't load collectors: %s", err)
144 } 141 }