~ubuntu-branches/ubuntu/wily/juju-core/wily

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/log/syslog/testing/syslogconf.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-28 16:53:15 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20140228165315-g8n1ds0jrtekhxq6
Tags: 1.17.4-0ubuntu1
* New upstream point release (LP: #1261628):
  - https://launchpad.net/juju-core/trunk/1.17.4
  - d/control: Prefer juju-mongodb over mongodb-server for juju-local
    package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
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
22
22
 
23
 
$ModLoad imudp
24
 
$UDPServerRun {{port}}
 
23
$ModLoad imtcp
 
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}}
25
31
 
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"
29
35
 
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}}
32
38
& ~
33
39
$FileCreateMode 0640
34
40
`
35
41
 
 
42
type templateArgs struct {
 
43
        MachineTag  string
 
44
        Namespace   string
 
45
        BootstrapIP string
 
46
        Port        int
 
47
        Offset      int
 
48
}
 
49
 
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
40
54
        }
41
 
        t := template.New("")
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))
 
56
        var conf bytes.Buffer
 
57
        err := t.Execute(&conf, templateArgs{
 
58
                MachineTag: machineTag,
 
59
                Namespace:  namespace,
 
60
                Offset:     len("juju-") + len(namespace) + 1,
 
61
                Port:       port,
47
62
        })
48
 
        t = template.Must(t.Parse(expectedAccumulateSyslogConfTemplate))
49
 
        var conf bytes.Buffer
50
 
        err := t.Execute(&conf, nil)
51
63
        c.Assert(err, gc.IsNil)
52
64
        return conf.String()
53
65
}
55
67
var expectedForwardSyslogConfTemplate = `
56
68
$ModLoad imfile
57
69
 
 
70
# Enable reliable forwarding.
 
71
$ActionQueueType LinkedList
 
72
$ActionQueueFileName {{.MachineTag}}{{.Namespace}}
 
73
$ActionResumeRetryCount -1
 
74
$ActionQueueSaveOnShutdown on
 
75
 
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
64
82
 
 
83
$DefaultNetstreamDriver gtls
 
84
$DefaultNetstreamDriverCAFile /var/log/juju/ca-cert.pem
 
85
$ActionSendStreamDriverAuthMode anon
 
86
$ActionSendStreamDriverMode 1 # run driver in TLS-only mode
 
87
 
65
88
$template LongTagForwardFormat,"<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% %syslogtag%%msg:::sp-if-no-1st-sp%%msg%"
66
89
 
67
 
:syslogtag, startswith, "juju{{namespace}}-" @server:{{port}};LongTagForwardFormat
 
90
:syslogtag, startswith, "juju{{.Namespace}}-" @@{{.BootstrapIP}}:{{.Port}};LongTagForwardFormat
68
91
& ~
69
92
`
70
93
 
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
75
98
        }
76
 
        t := template.New("")
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,
 
105
                Port:        port,
81
106
        })
82
 
        t = template.Must(t.Parse(expectedForwardSyslogConfTemplate))
83
 
        var conf bytes.Buffer
84
 
        err := t.Execute(&conf, nil)
85
107
        c.Assert(err, gc.IsNil)
86
108
        return conf.String()
87
109
}