agent: Adding SyslogFacility configuration

pull/210/head
Armon Dadgar 2014-06-11 10:18:19 -07:00
parent 93f4eb0a0f
commit 82c27cb902
3 changed files with 15 additions and 1 deletions

View File

@ -167,6 +167,10 @@ type Config struct {
// on linux and OSX. Other platforms will generate an error. // on linux and OSX. Other platforms will generate an error.
EnableSyslog bool `mapstructure:"enable_syslog"` EnableSyslog bool `mapstructure:"enable_syslog"`
// SyslogFacility is used to control where the syslog messages go
// By default, goes to LOCAL0
SyslogFacility string `mapstructure:"syslog_facility"`
// RejoinAfterLeave controls our interaction with the cluster after leave. // RejoinAfterLeave controls our interaction with the cluster after leave.
// When set to false (default), a leave causes Consul to not rejoin // When set to false (default), a leave causes Consul to not rejoin
// the cluster until an explicit join is received. If this is set to // the cluster until an explicit join is received. If this is set to
@ -228,6 +232,7 @@ func DefaultConfig() *Config {
DNSConfig: DNSConfig{ DNSConfig: DNSConfig{
MaxStale: 5 * time.Second, MaxStale: 5 * time.Second,
}, },
SyslogFacility: "LOCAL0",
Protocol: consul.ProtocolVersionMax, Protocol: consul.ProtocolVersionMax,
CheckUpdateInterval: 5 * time.Minute, CheckUpdateInterval: 5 * time.Minute,
AEInterval: time.Minute, AEInterval: time.Minute,
@ -556,6 +561,9 @@ func MergeConfig(a, b *Config) *Config {
if b.CheckUpdateIntervalRaw != "" || b.CheckUpdateInterval != 0 { if b.CheckUpdateIntervalRaw != "" || b.CheckUpdateInterval != 0 {
result.CheckUpdateInterval = b.CheckUpdateInterval result.CheckUpdateInterval = b.CheckUpdateInterval
} }
if b.SyslogFacility != "" {
result.SyslogFacility = b.SyslogFacility
}
// Copy the start join addresses // Copy the start join addresses
result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin)) result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin))

View File

@ -270,7 +270,7 @@ func TestDecodeConfig(t *testing.T) {
} }
// Syslog // Syslog
input = `{"enable_syslog": true}` input = `{"enable_syslog": true, "syslog_facility": "LOCAL4"}`
config, err = DecodeConfig(bytes.NewReader([]byte(input))) config, err = DecodeConfig(bytes.NewReader([]byte(input)))
if err != nil { if err != nil {
t.Fatalf("err: %s", err) t.Fatalf("err: %s", err)
@ -279,6 +279,9 @@ func TestDecodeConfig(t *testing.T) {
if !config.EnableSyslog { if !config.EnableSyslog {
t.Fatalf("bad: %#v", config) t.Fatalf("bad: %#v", config)
} }
if config.SyslogFacility != "LOCAL4" {
t.Fatalf("bad: %#v", config)
}
// Rejoin // Rejoin
input = `{"rejoin_after_leave": true}` input = `{"rejoin_after_leave": true}`

View File

@ -257,6 +257,9 @@ definitions support being updated during a reload.
Consul will stream various telemetry information to that instance for aggregation. Consul will stream various telemetry information to that instance for aggregation.
This can be used to capture various runtime information. This can be used to capture various runtime information.
* `syslog_facility` - When `enable_syslog` is provided, this controls which
facility messages are sent to. By default, `LOCAL0` will be used.
* `verify_incoming` - If set to True, Consul requires that all incoming * `verify_incoming` - If set to True, Consul requires that all incoming
connections make use of TLS, and that the client provides a certificate signed connections make use of TLS, and that the client provides a certificate signed
by the Certificate Authority from the `ca_file`. By default, this is false, and by the Certificate Authority from the `ca_file`. By default, this is false, and