|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Test_Rsyslog
|
|
Packit Service |
a2ae7a |
Provides unit tests and examples for the <Rsyslog> lens.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Test_Rsyslog =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Variable: conf *)
|
|
Packit Service |
a2ae7a |
let conf = "# rsyslog v5 configuration file
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
|
|
Packit Service |
a2ae7a |
$ModLoad imklog # provides kernel logging support (previously done by rklogd)
|
|
Packit Service |
a2ae7a |
module(load=\"immark\" markmessageperiod=\"60\" fakeoption=\"bar\") #provides --MARK-- message capability
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
timezone(id=\"CET\" offset=\"+01:00\")
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
$UDPServerRun 514
|
|
Packit Service |
a2ae7a |
$InputTCPServerRun 514
|
|
Packit Service |
a2ae7a |
$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
|
|
Packit Service |
a2ae7a |
$ActionFileEnableSync on
|
|
Packit Service |
a2ae7a |
$IncludeConfig /etc/rsyslog.d/*.conf
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
*.info;mail.none;authpriv.none;cron.none /var/log/messages
|
|
Packit Service |
a2ae7a |
authpriv.* /var/log/secure
|
|
Packit Service |
a2ae7a |
*.emerg *
|
|
Packit Service |
a2ae7a |
*.* @2.7.4.1
|
|
Packit Service |
a2ae7a |
*.* @@2.7.4.1
|
|
Packit Service |
a2ae7a |
*.emerg :omusrmsg:*
|
|
Packit Service |
a2ae7a |
*.emerg :omusrmsg:foo,bar
|
|
Packit Service |
a2ae7a |
*.emerg | /dev/xconsole
|
|
Packit Service |
a2ae7a |
"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Test: Rsyslog.lns *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get conf =
|
|
Packit Service |
a2ae7a |
{ "#comment" = "rsyslog v5 configuration file" }
|
|
Packit Service |
a2ae7a |
{ }
|
|
Packit Service |
a2ae7a |
{ "$ModLoad" = "imuxsock"
|
|
Packit Service |
a2ae7a |
{ "#comment" = "provides support for local system logging (e.g. via logger command)" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "$ModLoad" = "imklog"
|
|
Packit Service |
a2ae7a |
{ "#comment" = "provides kernel logging support (previously done by rklogd)" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "module"
|
|
Packit Service |
a2ae7a |
{ "load" = "immark" }
|
|
Packit Service |
a2ae7a |
{ "markmessageperiod" = "60" }
|
|
Packit Service |
a2ae7a |
{ "fakeoption" = "bar" }
|
|
Packit Service |
a2ae7a |
{ "#comment" = "provides --MARK-- message capability" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ }
|
|
Packit Service |
a2ae7a |
{ "timezone"
|
|
Packit Service |
a2ae7a |
{ "id" = "CET" }
|
|
Packit Service |
a2ae7a |
{ "offset" = "+01:00" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ }
|
|
Packit Service |
a2ae7a |
{ "$UDPServerRun" = "514" }
|
|
Packit Service |
a2ae7a |
{ "$InputTCPServerRun" = "514" }
|
|
Packit Service |
a2ae7a |
{ "$ActionFileDefaultTemplate" = "RSYSLOG_TraditionalFileFormat" }
|
|
Packit Service |
a2ae7a |
{ "$ActionFileEnableSync" = "on" }
|
|
Packit Service |
a2ae7a |
{ "$IncludeConfig" = "/etc/rsyslog.d/*.conf" }
|
|
Packit Service |
a2ae7a |
{ }
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "info" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "mail" }
|
|
Packit Service |
a2ae7a |
{ "level" = "none" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "authpriv" }
|
|
Packit Service |
a2ae7a |
{ "level" = "none" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "cron" }
|
|
Packit Service |
a2ae7a |
{ "level" = "none" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "file" = "/var/log/messages" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "authpriv" }
|
|
Packit Service |
a2ae7a |
{ "level" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "file" = "/var/log/secure" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "emerg" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "user" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "protocol" = "@" }
|
|
Packit Service |
a2ae7a |
{ "hostname" = "2.7.4.1" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "protocol" = "@@" }
|
|
Packit Service |
a2ae7a |
{ "hostname" = "2.7.4.1" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "emerg" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "omusrmsg" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "emerg" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "omusrmsg" = "foo" }
|
|
Packit Service |
a2ae7a |
{ "omusrmsg" = "bar" } }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "emerg" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "pipe" = "/dev/xconsole" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Parse complex $template lines, RHBZ#1083016 *)
|
|
Packit Service |
a2ae7a |
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" =
|
|
Packit Service |
a2ae7a |
{ "$template" = "SpiceTmpl,\"%TIMESTAMP%.%TIMESTAMP:::date-subseconds% %syslogtag% %syslogseverity-text%:%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\\n\"" }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Parse property-based filters, RHBZ#1083016 *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get ":programname, startswith, \"spice-vdagent\" /var/log/spice-vdagent.log;SpiceTmpl\n" =
|
|
Packit Service |
a2ae7a |
{ "filter"
|
|
Packit Service |
a2ae7a |
{ "property" = "programname" }
|
|
Packit Service |
a2ae7a |
{ "operation" = "startswith" }
|
|
Packit Service |
a2ae7a |
{ "value" = "spice-vdagent" }
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "file" = "/var/log/spice-vdagent.log" }
|
|
Packit Service |
a2ae7a |
{ "template" = "SpiceTmpl" } } }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get ":msg, !contains, \"error\" /var/log/noterror.log\n" =
|
|
Packit Service |
a2ae7a |
{ "filter"
|
|
Packit Service |
a2ae7a |
{ "property" = "msg" }
|
|
Packit Service |
a2ae7a |
{ "operation" = "!contains" }
|
|
Packit Service |
a2ae7a |
{ "value" = "error" }
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "file" = "/var/log/noterror.log" } } }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get ":msg,!contains,\"garbage\" ~\n" =
|
|
Packit Service |
a2ae7a |
{ "filter"
|
|
Packit Service |
a2ae7a |
{ "property" = "msg" }
|
|
Packit Service |
a2ae7a |
{ "operation" = "!contains" }
|
|
Packit Service |
a2ae7a |
{ "value" = "garbage" }
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "discard" } } }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns put "" after
|
|
Packit Service |
a2ae7a |
set "/module[1]/load" "imuxsock"
|
|
Packit Service |
a2ae7a |
= "module(load=\"imuxsock\")\n"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns put "" after
|
|
Packit Service |
a2ae7a |
set "/module[1]/load" "imuxsock" ;
|
|
Packit Service |
a2ae7a |
set "/module[1]/SysSock.RateLimit.Interval" "0"
|
|
Packit Service |
a2ae7a |
= "module(load=\"imuxsock\" SysSock.RateLimit.Interval=\"0\")\n"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns put "" after
|
|
Packit Service |
a2ae7a |
set "/module[1]/load" "imuxsock" ;
|
|
Packit Service |
a2ae7a |
set "/module[1]/SysSock.RateLimit.Interval" "0" ;
|
|
Packit Service |
a2ae7a |
set "/module[1]/SysSock.RateLimit.Burst" "1"
|
|
Packit Service |
a2ae7a |
= "module(load=\"imuxsock\" SysSock.RateLimit.Interval=\"0\" SysSock.RateLimit.Burst=\"1\")\n"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* On Fedora 26, there are comments in module statements *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "module(load=\"imuxsock\" # provides support for local system logging (e.g. via logger command)
|
|
Packit Service |
a2ae7a |
SysSock.Use=\"off\") # Turn off message reception via local log socket;
|
|
Packit Service |
a2ae7a |
# local messages are retrieved through imjournal now.\n" =
|
|
Packit Service |
a2ae7a |
{ "module"
|
|
Packit Service |
a2ae7a |
{ "load" = "imuxsock" }
|
|
Packit Service |
a2ae7a |
{ "SysSock.Use" = "off" }
|
|
Packit Service |
a2ae7a |
{ "#comment" = "Turn off message reception via local log socket;" } }
|
|
Packit Service |
a2ae7a |
{ "#comment" = "local messages are retrieved through imjournal now." }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* rsyslog doesn't use bsd-like #! or #+/- specifications *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "#!prog\n" = { "#comment" = "!prog" }
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "#+host\n" = { "#comment" = "+host" }
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "#-host\n" = { "#comment" = "-host" }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Added in rsyslog 8.33 *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "include(file=\"/etc/rsyslog.d/*.conf\" mode=\"optional\")\n" =
|
|
Packit Service |
a2ae7a |
{ "include"
|
|
Packit Service |
a2ae7a |
{ "file" = "/etc/rsyslog.d/*.conf" }
|
|
Packit Service |
a2ae7a |
{ "mode" = "optional" } }
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Dynamic file name template *)
|
|
Packit Service |
a2ae7a |
test Rsyslog.lns get "*.* ?DynamicFile\n" =
|
|
Packit Service |
a2ae7a |
{ "entry"
|
|
Packit Service |
a2ae7a |
{ "selector"
|
|
Packit Service |
a2ae7a |
{ "facility" = "*" }
|
|
Packit Service |
a2ae7a |
{ "level" = "*" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
{ "action"
|
|
Packit Service |
a2ae7a |
{ "dynamic" = "DynamicFile" }
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
a2ae7a |
}
|
|
Packit Service |
59f964 |
|
|
Packit Service |
59f964 |
(* Multiple actions in filters and selectors *)
|
|
Packit Service |
59f964 |
test Rsyslog.lns get ":msg, startswith, \"iptables:\" -/var/log/iptables.log
|
|
Packit Service |
59f964 |
& ~
|
|
Packit Service |
59f964 |
# Save boot messages also to boot.log
|
|
Packit Service |
59f964 |
local7.* /var/log/boot.log
|
|
Packit Service |
59f964 |
local3.err /var/log/nfsen/nfsenlog
|
|
Packit Service |
59f964 |
& /var/log/also.log
|
|
Packit Service |
59f964 |
\n" =
|
|
Packit Service |
59f964 |
{ "filter"
|
|
Packit Service |
59f964 |
{ "property" = "msg" }
|
|
Packit Service |
59f964 |
{ "operation" = "startswith" }
|
|
Packit Service |
59f964 |
{ "value" = "iptables:" }
|
|
Packit Service |
59f964 |
{ "action"
|
|
Packit Service |
59f964 |
{ "no_sync" }
|
|
Packit Service |
59f964 |
{ "file" = "/var/log/iptables.log" } }
|
|
Packit Service |
59f964 |
{ "action"
|
|
Packit Service |
59f964 |
{ "discard" } }
|
|
Packit Service |
59f964 |
}
|
|
Packit Service |
59f964 |
{ "#comment" = "Save boot messages also to boot.log" }
|
|
Packit Service |
59f964 |
{ "entry"
|
|
Packit Service |
59f964 |
{ "selector"
|
|
Packit Service |
59f964 |
{ "facility" = "local7" }
|
|
Packit Service |
59f964 |
{ "level" = "*" } }
|
|
Packit Service |
59f964 |
{ "action"
|
|
Packit Service |
59f964 |
{ "file" = "/var/log/boot.log" } }
|
|
Packit Service |
59f964 |
}
|
|
Packit Service |
59f964 |
{ "entry"
|
|
Packit Service |
59f964 |
{ "selector"
|
|
Packit Service |
59f964 |
{ "facility" = "local3" }
|
|
Packit Service |
59f964 |
{ "level" = "err" } }
|
|
Packit Service |
59f964 |
{ "action"
|
|
Packit Service |
59f964 |
{ "file" = "/var/log/nfsen/nfsenlog" } }
|
|
Packit Service |
59f964 |
{ "action"
|
|
Packit Service |
59f964 |
{ "file" = "/var/log/also.log" } } }
|
|
Packit Service |
59f964 |
{ }
|
|
Packit Service |
59f964 |
|