Example #1
0
func Load(tsdbChan chan<- *tsdb.Point) {
	var (
		filePath  = flag.String("f", "/etc/collect-statse/config", "configuration file")
		debugMode = flag.Bool("v", false, "verbose mode")
		testMode  = flag.Bool("t", false, "configuration test")
	)
	flag.Parse()
	log.SetFlags(0)
	if flag.NArg() != 0 {
		flag.Usage()
		os.Exit(1)
	}
	if *debugMode {
		w := os.Stderr
		xconfig.Debug = log.New(w, "debug: config: ", 0)
		statse.Debug = log.New(w, "debug: statse: ", 0)
		forwarder.Debug = log.New(w, "debug: forwarder: ", 0)
		filter.Debug = log.New(w, "debug: forwarder/filter: ", 0)
		aggregator.Debug = log.New(w, "debug: aggregator: ", 0)
	}
	config := new(Config)
	xconfig.Load(config, *filePath, "collect-statse?host={{.Hostname}}")
	if *testMode {
		config.Dump(os.Stdout)
		os.Exit(0)
	}
	Loaded = config
	aggregator.Init(tsdbChan)
	log.Printf("start pid=%d", os.Getpid())
}
Example #2
0
func load(path string) *Config {
	if flag.DebugMode {
		config.Debug = log.New(os.Stderr, "debug: config: ", 0)
	}
	cfg := new(Config)
	config.Load(cfg, path, "tsp-poller?host={{.Hostname}}")
	if flag.TestMode {
		cfg.Dump(os.Stdout)
		os.Exit(0)
	}
	go func() {
		dummy := new(Config)
		config.Next(dummy)
		restartCause <- "config updated"
	}()
	return cfg
}