Browse Source

Merge pull request #30 from prometheus/make-config-optional

Make config optional
pull/32/head
juliusv 10 years ago
parent
commit
e4abdece01
  1. 12
      node_exporter.go

12
node_exporter.go

@ -22,7 +22,7 @@ import (
const subsystem = "exporter" const subsystem = "exporter"
var ( var (
configFile = flag.String("config", "node_exporter.conf", "Path to config file.") configFile = flag.String("config", "", "Path to config file.")
memProfile = flag.String("memprofile", "", "Write memory profile to this file.") memProfile = flag.String("memprofile", "", "Write memory profile to this file.")
listeningAddress = flag.String("listen", ":8080", "Address to listen on.") listeningAddress = flag.String("listen", ":8080", "Address to listen on.")
enabledCollectors = flag.String("enabledCollectors", "attributes,diskstats,filesystem,loadavg,meminfo,stat,time,netdev,netstat", "Comma-separated list of collectors to use.") enabledCollectors = flag.String("enabledCollectors", "attributes,diskstats,filesystem,loadavg,meminfo,stat,time,netdev,netstat", "Comma-separated list of collectors to use.")
@ -112,9 +112,13 @@ func getConfig(file string) (*collector.Config, error) {
func loadCollectors(file string) (map[string]collector.Collector, error) { func loadCollectors(file string) (map[string]collector.Collector, error) {
collectors := map[string]collector.Collector{} collectors := map[string]collector.Collector{}
config, err := getConfig(file) config := &collector.Config{}
if err != nil { if file != "" {
return nil, fmt.Errorf("couldn't read config %s: %s", file, err) var err error
config, err = getConfig(file)
if err != nil {
return nil, fmt.Errorf("couldn't read config %s: %s", file, err)
}
} }
for _, name := range strings.Split(*enabledCollectors, ",") { for _, name := range strings.Split(*enabledCollectors, ",") {
fn, ok := collector.Factories[name] fn, ok := collector.Factories[name]

Loading…
Cancel
Save