16
16
$InputFilePersistStateInterval 50
17
17
$InputFilePollInterval 5
18
$InputFileName /var/log/juju/{{machine}}.log
19
$InputFileTag juju{{namespace}}-{{machine}}:
20
$InputFileStateFile {{machine}}{{namespace}}
18
$InputFileName /var/log/juju{{.Namespace}}/{{.MachineTag}}.log
19
$InputFileTag juju{{.Namespace}}-{{.MachineTag}}:
20
$InputFileStateFile {{.MachineTag}}{{.Namespace}}
21
21
$InputRunFileMonitor
24
$UDPServerRun {{port}}
24
$DefaultNetstreamDriver gtls
25
$DefaultNetstreamDriverCAFile /var/log/juju{{.Namespace}}/ca-cert.pem
26
$DefaultNetstreamDriverCertFile /var/log/juju{{.Namespace}}/rsyslog-cert.pem
27
$DefaultNetstreamDriverKeyFile /var/log/juju{{.Namespace}}/rsyslog-key.pem
28
$InputTCPServerStreamDriverAuthMode anon
29
$InputTCPServerStreamDriverMode 1 # run driver in TLS-only mode
30
$InputTCPServerRun {{.Port}}
26
32
# Messages received from remote rsyslog machines have messages prefixed with a space,
27
33
# so add one in for local messages too if needed.
28
$template JujuLogFormat{{namespace}},"%syslogtag:{{offset}}:$%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
34
$template JujuLogFormat{{.Namespace}},"%syslogtag:{{.Offset}}:$%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"
30
36
$FileCreateMode 0644
31
:syslogtag, startswith, "juju{{namespace}}-" /var/log/juju{{namespace}}/all-machines.log;JujuLogFormat{{namespace}}
37
:syslogtag, startswith, "juju{{.Namespace}}-" /var/log/juju{{.Namespace}}/all-machines.log;JujuLogFormat{{.Namespace}}
33
39
$FileCreateMode 0640
42
type templateArgs struct {
36
50
// ExpectedAccumulateSyslogConf returns the expected content for a rsyslog file on a state server.
37
51
func ExpectedAccumulateSyslogConf(c *gc.C, machineTag, namespace string, port int) string {
38
52
if namespace != "" {
39
53
namespace = "-" + namespace
42
t.Funcs(template.FuncMap{
43
"machine": func() string { return machineTag },
44
"namespace": func() string { return namespace },
45
"port": func() int { return port },
46
"offset": func() int { return 6 + len(namespace) },
55
t := template.Must(template.New("").Parse(expectedAccumulateSyslogConfTemplate))
57
err := t.Execute(&conf, templateArgs{
58
MachineTag: machineTag,
60
Offset: len("juju-") + len(namespace) + 1,
48
t = template.Must(t.Parse(expectedAccumulateSyslogConfTemplate))
50
err := t.Execute(&conf, nil)
51
63
c.Assert(err, gc.IsNil)
52
64
return conf.String()
55
67
var expectedForwardSyslogConfTemplate = `
70
# Enable reliable forwarding.
71
$ActionQueueType LinkedList
72
$ActionQueueFileName {{.MachineTag}}{{.Namespace}}
73
$ActionResumeRetryCount -1
74
$ActionQueueSaveOnShutdown on
58
76
$InputFilePersistStateInterval 50
59
77
$InputFilePollInterval 5
60
$InputFileName /var/log/juju/{{machine}}.log
61
$InputFileTag juju{{namespace}}-{{machine}}:
62
$InputFileStateFile {{machine}}{{namespace}}
78
$InputFileName /var/log/juju/{{.MachineTag}}.log
79
$InputFileTag juju{{.Namespace}}-{{.MachineTag}}:
80
$InputFileStateFile {{.MachineTag}}{{.Namespace}}
63
81
$InputRunFileMonitor
83
$DefaultNetstreamDriver gtls
84
$DefaultNetstreamDriverCAFile /var/log/juju/ca-cert.pem
85
$ActionSendStreamDriverAuthMode anon
86
$ActionSendStreamDriverMode 1 # run driver in TLS-only mode
65
88
$template LongTagForwardFormat,"<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%"
67
:syslogtag, startswith, "juju{{namespace}}-" @server:{{port}};LongTagForwardFormat
90
:syslogtag, startswith, "juju{{.Namespace}}-" @@{{.BootstrapIP}}:{{.Port}};LongTagForwardFormat
71
94
// ExpectedForwardSyslogConf returns the expected content for a rsyslog file on a host machine.
72
func ExpectedForwardSyslogConf(c *gc.C, machineTag, namespace string, port int) string {
95
func ExpectedForwardSyslogConf(c *gc.C, machineTag, namespace, bootstrapIP string, port int) string {
73
96
if namespace != "" {
74
97
namespace = "-" + namespace
77
t.Funcs(template.FuncMap{
78
"machine": func() string { return machineTag },
79
"namespace": func() string { return namespace },
80
"port": func() int { return port },
99
t := template.Must(template.New("").Parse(expectedForwardSyslogConfTemplate))
100
var conf bytes.Buffer
101
err := t.Execute(&conf, templateArgs{
102
MachineTag: machineTag,
103
Namespace: namespace,
104
BootstrapIP: bootstrapIP,
82
t = template.Must(t.Parse(expectedForwardSyslogConfTemplate))
84
err := t.Execute(&conf, nil)
85
107
c.Assert(err, gc.IsNil)
86
108
return conf.String()