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.
pull/203/head
Tobias Schmidt 9 years ago
parent 20ecedd0b4
commit 3a96e6881b

@ -25,34 +25,25 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/log" "github.com/prometheus/common/log"
"github.com/prometheus/node_exporter/collector" "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 ( var (
// Version of node_exporter. Set at build time. // Version of node_exporter. Set at build time.
Version = "0.0.0.dev" 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( scrapeDurations = prometheus.NewSummaryVec(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
Namespace: collector.Namespace, Namespace: collector.Namespace,
Subsystem: subsystem, Subsystem: "exporter",
Name: "scrape_duration_seconds", Name: "scrape_duration_seconds",
Help: "node_exporter: Duration of a scrape job.", 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()) 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{} collectors := map[string]collector.Collector{}
for _, name := range strings.Split(*enabledCollectors, ",") { for _, name := range strings.Split(list, ",") {
fn, ok := collector.Factories[name] fn, ok := collector.Factories[name]
if !ok { if !ok {
return nil, fmt.Errorf("collector '%s' not available", name) return nil, fmt.Errorf("collector '%s' not available", name)
@ -124,6 +115,12 @@ func loadCollectors() (map[string]collector.Collector, error) {
} }
func main() { 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() flag.Parse()
if *printCollectors { if *printCollectors {
@ -138,7 +135,7 @@ func main() {
} }
return return
} }
collectors, err := loadCollectors() collectors, err := loadCollectors(*enabledCollectors)
if err != nil { if err != nil {
log.Fatalf("Couldn't load collectors: %s", err) log.Fatalf("Couldn't load collectors: %s", err)
} }

Loading…
Cancel
Save