mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-11-23 20:36:21 +01:00
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.
This commit is contained in:
parent
20ecedd0b4
commit
3a96e6881b
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user