3 Provides unit tests and examples for the <Rsyslog> lens.
9 let conf = "# rsyslog v5 configuration file
11 $ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
12 $ModLoad imklog # provides kernel logging support (previously done by rklogd)
13 module(load=\"immark\" markmessageperiod=\"60\" fakeoption=\"bar\") #provides --MARK-- message capability
15 timezone(id=\"CET\" offset=\"+01:00\")
18 $InputTCPServerRun 514
19 $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
20 $ActionFileEnableSync on
21 $IncludeConfig /etc/rsyslog.d/*.conf
23 *.info;mail.none;authpriv.none;cron.none /var/log/messages
24 authpriv.* /var/log/secure
29 *.emerg :omusrmsg:foo,bar
30 *.emerg | /dev/xconsole
33 (* Test: Rsyslog.lns *)
34 test Rsyslog.lns get conf =
35 { "#comment" = "rsyslog v5 configuration file" }
37 { "$ModLoad" = "imuxsock"
38 { "#comment" = "provides support for local system logging (e.g. via logger command)" }
40 { "$ModLoad" = "imklog"
41 { "#comment" = "provides kernel logging support (previously done by rklogd)" }
45 { "markmessageperiod" = "60" }
46 { "fakeoption" = "bar" }
47 { "#comment" = "provides --MARK-- message capability" }
52 { "offset" = "+01:00" }
55 { "$UDPServerRun" = "514" }
56 { "$InputTCPServerRun" = "514" }
57 { "$ActionFileDefaultTemplate" = "RSYSLOG_TraditionalFileFormat" }
58 { "$ActionFileEnableSync" = "on" }
59 { "$IncludeConfig" = "/etc/rsyslog.d/*.conf" }
67 { "facility" = "mail" }
71 { "facility" = "authpriv" }
75 { "facility" = "cron" }
79 { "file" = "/var/log/messages" }
84 { "facility" = "authpriv" }
88 { "file" = "/var/log/secure" }
107 { "hostname" = "2.7.4.1" }
116 { "protocol" = "@@" }
117 { "hostname" = "2.7.4.1" }
123 { "level" = "emerg" }
132 { "level" = "emerg" }
135 { "omusrmsg" = "foo" }
136 { "omusrmsg" = "bar" } }
141 { "level" = "emerg" }
144 { "pipe" = "/dev/xconsole" }
148 (* Parse complex $template lines, RHBZ#1083016 *)
149 test Rsyslog.lns get "$template SpiceTmpl,\"%TIMESTAMP%.%TIMESTAMP:::date-subseconds% %syslogtag% %syslogseverity-text%:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\\n\"\n" =
150 { "$template" = "SpiceTmpl,\"%TIMESTAMP%.%TIMESTAMP:::date-subseconds% %syslogtag% %syslogseverity-text%:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\\n\"" }
152 (* Parse property-based filters, RHBZ#1083016 *)
153 test Rsyslog.lns get ":programname, startswith, \"spice-vdagent\" /var/log/spice-vdagent.log;SpiceTmpl\n" =
155 { "property" = "programname" }
156 { "operation" = "startswith" }
157 { "value" = "spice-vdagent" }
159 { "file" = "/var/log/spice-vdagent.log" }
160 { "template" = "SpiceTmpl" } } }
162 test Rsyslog.lns get ":msg, !contains, \"error\" /var/log/noterror.log\n" =
164 { "property" = "msg" }
165 { "operation" = "!contains" }
166 { "value" = "error" }
168 { "file" = "/var/log/noterror.log" } } }
170 test Rsyslog.lns get ":msg,!contains,\"garbage\" ~\n" =
172 { "property" = "msg" }
173 { "operation" = "!contains" }
174 { "value" = "garbage" }
178 test Rsyslog.lns put "" after
179 set "/module[1]/load" "imuxsock"
180 = "module(load=\"imuxsock\")\n"
182 test Rsyslog.lns put "" after
183 set "/module[1]/load" "imuxsock" ;
184 set "/module[1]/SysSock.RateLimit.Interval" "0"
185 = "module(load=\"imuxsock\" SysSock.RateLimit.Interval=\"0\")\n"
187 test Rsyslog.lns put "" after
188 set "/module[1]/load" "imuxsock" ;
189 set "/module[1]/SysSock.RateLimit.Interval" "0" ;
190 set "/module[1]/SysSock.RateLimit.Burst" "1"
191 = "module(load=\"imuxsock\" SysSock.RateLimit.Interval=\"0\" SysSock.RateLimit.Burst=\"1\")\n"