// SetConfigDefaults - XXX func (n *Nginx) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("nginx") if err != nil { log.WithFields(log.Fields{"plugin": "nginx", "error": err.Error()}).Error("Can't read config file") } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{"plugin": "nginx", "error": decodeError.Error()}).Error("Can't decode config file") } n.Config = config return nil }
// SetConfigDefaults - XXX func (s *Statsd) SetConfigDefaults() error { // Config already set. For example - in the test suite if len(s.Config.Address) > 0 { return nil } configFile, err := plugins.UmarshalPluginConfig("statsd") if err != nil { log.WithFields(log.Fields{ "plugin": "statsd", "error": err.Error()}).Error("Can't read config file") return err } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{ "plugin": "statsd", "error": decodeError.Error()}).Error("Can't decode config file") return decodeError } // Config file is empty, set defaults if len(config.Address) == 0 { config.Address = ":8125" config.AllowedPendingMessages = 10000 config.DeleteTimings = true } // Set default if config.AllowedPendingMessages == 0 { config.AllowedPendingMessages = 10000 } config.DeleteTimings = true s.Config = config return nil }
// SetConfigDefaults - XXX func (p *PostgreSQL) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("postgresql") if err != nil { log.WithFields(log.Fields{"plugin": "postgresql", "error": err.Error()}).Error("Can't read config file") } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{"plugin": "postgresql", "error": decodeError.Error()}).Error("Can't decode config file") } u, _ := url.Parse(config.Host) config.DB = strings.Trim(u.Path, "/") p.Config = config return nil }
// SetConfigDefaults - XXX func (h *Haproxy) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("haproxy") if err != nil { log.WithFields(log.Fields{"plugin": "haproxy", "error": err.Error()}).Error("Can't read config file") } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{"plugin": "haproxy", "error": decodeError.Error()}).Error("Can't decode config file") } if len(config.Host) == 0 { config.Host = "http://127.0.0.1:1936" } h.Config = config return nil }
// SetConfigDefaults - XXX func (r *Redis) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("redis") if err != nil { log.WithFields(log.Fields{"plugin": "redis", "error": err.Error()}).Error("Can't read config file") } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{"plugin": "redis", "error": decodeError.Error()}).Error("Can't decode config file") } if len(config.Host) == 0 { config.Host = "127.0.0.1:6379" } r.Config = config return nil }
// SetConfigDefaults - XXX func (a *Apache) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("apache") if err != nil { log.WithFields(log.Fields{"plugin": "apache", "error": err.Error()}).Error("Can't read config file") } var config Config decodeError := mapstructure.Decode(configFile, &config) if decodeError != nil { log.WithFields(log.Fields{"plugin": "apache", "error": decodeError.Error()}).Error("Can't decode config file") } if len(config.StatusURL) == 0 { config.StatusURL = "http://127.0.0.1/server-status?auto" } a.Config = config return nil }
// SetConfigDefaults - XXX func (t *Telegraf) SetConfigDefaults() error { configFile, err := plugins.UmarshalPluginConfig("telegraf") if err != nil { log.WithFields(log.Fields{"plugin": "telegraf", "error": err.Error()}).Error("Can't read config file") return err } var config Config e := mapstructure.Decode(configFile, &config) if e != nil { log.WithFields(log.Fields{"plugin": "telegraf", "error": e.Error()}).Error("Can't decode config file") return e } t.Config = config return nil }