Пример #1
0
// NewConfig returns an instance of Config with reasonable defaults.
func NewConfig() *Config {
	c := &Config{
		Hostname: "localhost",
	}

	c.HTTP = httpd.NewConfig()
	c.Replay = replay.NewConfig()
	c.Task = task_store.NewConfig()
	c.InfluxDB = influxdb.NewConfig()
	c.Logging = logging.NewConfig()

	c.Collectd = collectd.NewConfig()
	c.OpenTSDB = opentsdb.NewConfig()
	c.SMTP = smtp.NewConfig()
	c.OpsGenie = opsgenie.NewConfig()
	c.VictorOps = victorops.NewConfig()
	c.PagerDuty = pagerduty.NewConfig()
	c.Sensu = sensu.NewConfig()
	c.Slack = slack.NewConfig()
	c.HipChat = hipchat.NewConfig()
	c.Alerta = alerta.NewConfig()
	c.Reporting = reporting.NewConfig()
	c.Stats = stats.NewConfig()
	c.UDF = udf.NewConfig()
	c.Deadman = deadman.NewConfig()
	c.Talk = talk.NewConfig()

	return c
}
Пример #2
0
// Once the config has been created and decoded, you can call this method
// to initialize ARRAY attributes.
// All ARRAY attributes have to be init after toml decode
// See: https://github.com/BurntSushi/toml/pull/68
func (c *Config) PostInit() {
	if len(c.InfluxDB) == 0 {
		i := influxdb.NewConfig()
		c.InfluxDB = []influxdb.Config{i}
		c.InfluxDB[0].Name = "default"
		c.InfluxDB[0].URLs = []string{"http://localhost:8086"}
	} else if len(c.InfluxDB) == 1 && c.InfluxDB[0].Name == "" {
		c.InfluxDB[0].Name = "default"
	}
	// Set default Values
	for i, influx := range c.InfluxDB {
		influx.SetDefaultValues()
		c.InfluxDB[i] = influx
	}
}