|
1 | 1 | ### Autogenerated by system_syslog.py ###
|
2 | 2 |
|
3 |
| -{% if global.marker is vyos_defined %} |
4 |
| -$ModLoad immark |
5 |
| -{% if global.marker.interval is vyos_defined %} |
6 |
| -$MarkMessagePeriod {{ global.marker.interval }} |
7 |
| -{% endif %} |
8 |
| -{% endif %} |
9 |
| -{% if global.preserve_fqdn is vyos_defined %} |
10 |
| -$PreserveFQDN on |
11 |
| -{% endif %} |
| 3 | +#### MODULES #### |
| 4 | +# Load input modules for local logging and kernel logging |
12 | 5 |
|
13 |
| -{% if global.local_host_name is vyos_defined %} |
14 |
| -$LocalHostName {{ global.local_host_name }} |
15 |
| -{% endif %} |
| 6 | +# Old-style log file format with low-precision timestamps |
| 7 | +# A modern-style logfile format with high-precision timestamps and timezone info |
| 8 | +# RSYSLOG_FileFormat |
| 9 | +module(load="builtin:omfile" Template="RSYSLOG_TraditionalFileFormat") |
| 10 | +module(load="imuxsock") # provides support for local system logging |
| 11 | +module(load="imklog") # provides kernel logging support |
16 | 12 |
|
17 |
| -# We always log to /var/log/messages |
18 |
| -$outchannel global,/var/log/messages,262144,/usr/sbin/logrotate {{ logrotate }} |
19 |
| -{% if global.facility is vyos_defined %} |
20 |
| -{% set tmp = [] %} |
21 |
| -{% for facility, facility_options in global.facility.items() %} |
22 |
| -{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level.replace('all', '*')) %} |
23 |
| -{% endfor %} |
24 |
| -{{ tmp | join(';') }} :omfile:$global |
| 13 | +# Import logs from journald |
| 14 | +module( |
| 15 | + load="imjournal" |
| 16 | + StateFile="/var/spool/rsyslog/imjournal.state" # Persistent state file to track the journal cursor |
| 17 | + Ratelimit.Interval="0" # Disable rate limiting (set to "0" for no limit) |
| 18 | + RateLimit.Burst="0" |
| 19 | +) |
| 20 | + |
| 21 | +########################### |
| 22 | +#### GLOBAL DIRECTIVES #### |
| 23 | +########################### |
| 24 | +# Log specific programs to auth.log, then stop further processing |
| 25 | +if ( |
| 26 | + $programname == "CRON" or |
| 27 | + $programname == "sudo" or |
| 28 | + $programname == "su" |
| 29 | +) then { |
| 30 | + action(type="omfile" file="/var/log/auth.log") |
| 31 | + stop |
| 32 | +} |
| 33 | + |
| 34 | +global(workDirectory="/var/spool/rsyslog") |
| 35 | + |
| 36 | +############### |
| 37 | +#### RULES #### |
| 38 | +############### |
| 39 | + |
| 40 | +# Send emergency messages to all logged-in users |
| 41 | +*.emerg action(type="omusrmsg" users="*") |
| 42 | + |
| 43 | +{% if marker is vyos_defined %} |
| 44 | +# Load the immark module for periodic --MARK-- message capability |
| 45 | +module(load="immark" interval="{{ marker.interval }}") |
| 46 | +{% endif %} |
| 47 | +{% if preserve_fqdn is vyos_defined %} |
| 48 | +# Preserve the fully qualified domain name (FQDN) in log messages |
| 49 | +global(preserveFQDN="on") |
| 50 | +{% if preserve_fqdn.host_name is vyos_defined and preserve_fqdn.domain_name is vyos_defined %} |
| 51 | +# Set the local hostname for log messages |
| 52 | +global(localHostname="{{ preserve_fqdn.host_name }}.{{ preserve_fqdn.domain_name }}") |
| 53 | +{% endif %} |
25 | 54 | {% endif %}
|
26 | 55 |
|
27 |
| -{% if file is vyos_defined %} |
28 |
| -# File based configuration section |
29 |
| -{% for file_name, file_options in file.items() %} |
30 |
| -{% set tmp = [] %} |
31 |
| -$outchannel {{ file_name }},/var/log/user/{{ file_name }},{{ file_options.archive.size }},/usr/sbin/logrotate {{ logrotate }} |
32 |
| -{% if file_options.facility is vyos_defined %} |
33 |
| -{% for facility, facility_options in file_options.facility.items() %} |
34 |
| -{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level.replace('all', '*')) %} |
35 |
| -{% endfor %} |
36 |
| -{% endif %} |
37 |
| -{{ tmp | join(';') }} :omfile:${{ file }} |
38 |
| -{% endfor %} |
| 56 | +#### GLOBAL LOGGING #### |
| 57 | +{% if local.facility is vyos_defined %} |
| 58 | +{% set tmp = [] %} |
| 59 | +{% if local.facility is vyos_defined %} |
| 60 | +{% for facility, facility_options in local.facility.items() %} |
| 61 | +{% set _ = tmp.append(facility.replace('all', '*') ~ "." ~ facility_options.level.replace('all', 'debug')) %} |
| 62 | +{% endfor %} |
| 63 | +if prifilt("{{ tmp | join(',') }}") then { |
| 64 | + action( |
| 65 | + type="omfile" |
| 66 | + file="/var/log/messages" |
| 67 | + rotation.sizeLimit="524288" # 512Kib - maximum filesize before rotation |
| 68 | + rotation.sizeLimitCommand="/usr/sbin/logrotate {{ logrotate }}" |
| 69 | + ) |
| 70 | +} |
| 71 | +{% endif %} |
39 | 72 | {% endif %}
|
40 | 73 |
|
| 74 | +#### CONSOLE LOGGING #### |
41 | 75 | {% if console.facility is vyos_defined %}
|
42 |
| -# Console logging |
43 | 76 | {% set tmp = [] %}
|
44 |
| -{% for facility, facility_options in console.facility.items() %} |
45 |
| -{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level.replace('all', '*')) %} |
46 |
| -{% endfor %} |
47 |
| -{{ tmp | join(';') }} /dev/console |
| 77 | +{% if console.facility is vyos_defined %} |
| 78 | +{% for facility, facility_options in console.facility.items() %} |
| 79 | +{% set _ = tmp.append(facility.replace('all', '*') ~ "." ~ facility_options.level.replace('all', 'debug')) %} |
| 80 | +{% endfor %} |
| 81 | +if prifilt("{{ tmp | join(',') }}") then { |
| 82 | + action(type="omfile" file="/dev/console") |
| 83 | +} |
| 84 | +{% endif %} |
48 | 85 | {% endif %}
|
49 | 86 |
|
50 |
| -{% if host is vyos_defined %} |
51 |
| -# Remote logging |
52 |
| -{% for host_name, host_options in host.items() %} |
| 87 | +#### REMOTE LOGGING #### |
| 88 | +{% if remote is vyos_defined %} |
| 89 | +{% for remote_name, remote_options in remote.items() %} |
53 | 90 | {% set tmp = [] %}
|
54 |
| -{% if host_options.facility is vyos_defined %} |
55 |
| -{% for facility, facility_options in host_options.facility.items() %} |
56 |
| -{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level.replace('all', '*')) %} |
| 91 | +{% if remote_options.facility is vyos_defined %} |
| 92 | +{% for facility, facility_options in remote_options.facility.items() %} |
| 93 | +{% set _ = tmp.append(facility.replace('all', '*') ~ "." ~ facility_options.level.replace('all', 'debug')) %} |
57 | 94 | {% endfor %}
|
58 |
| -{% endif %} |
59 |
| -{% if host_options.protocol is vyos_defined('tcp') %} |
60 |
| -{{ tmp | join(';') }} @@{{ '(o)' if host_options.format.octet_counted is vyos_defined }}{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}{{ ';RSYSLOG_SyslogProtocol23Format' if host_options.format.include_timezone is vyos_defined }} |
61 |
| -{% else %} |
62 |
| -{{ tmp | join(';') }} @{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}{{ ';RSYSLOG_SyslogProtocol23Format' if host_options.format.include_timezone is vyos_defined }} |
| 95 | +{% set _ = tmp.sort() %} |
| 96 | +# Remote syslog to {{ remote_name }} |
| 97 | +if prifilt("{{ tmp | join(',') }}") then { |
| 98 | + action( |
| 99 | + type="omfwd" |
| 100 | + # Remote syslog server where we send our logs to |
| 101 | + target="{{ remote_name | bracketize_ipv6 }}" |
| 102 | + # Port on the remote syslog server |
| 103 | + port="{{ remote_options.port }}" |
| 104 | + protocol="{{ remote_options.protocol }}" |
| 105 | +{% if remote_options.format.include_timezone is vyos_defined %} |
| 106 | + template="SyslogProtocol23Format" |
| 107 | +{% endif %} |
| 108 | + TCP_Framing="{{ 'octed-counted' if remote_options.format.octet_counted is vyos_defined else 'traditional' }}" |
| 109 | +{% if remote_options.source_address is vyos_defined %} |
| 110 | + Address="{{ remote_options.source_address }}" |
| 111 | +{% endif %} |
| 112 | +{% if remote_options.vrf is vyos_defined %} |
| 113 | + Device="{{ remote_options.vrf }}" |
| 114 | +{% endif %} |
| 115 | + ) |
| 116 | +} |
63 | 117 | {% endif %}
|
64 | 118 | {% endfor %}
|
65 | 119 | {% endif %}
|
66 | 120 |
|
67 |
| -{% if user is defined and user is not none %} |
68 |
| -# Log to user terminal |
69 |
| -{% for username, user_options in user.items() %} |
70 |
| -{% set tmp = [] %} |
71 |
| -{% if user_options.facility is vyos_defined %} |
72 |
| -{% for facility, facility_options in user_options.facility.items() %} |
73 |
| -{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level.replace('all', '*')) %} |
74 |
| -{% endfor %} |
75 |
| -{% endif %} |
76 |
| -{{ tmp | join(';') }} :omusrmsg:{{ username }} |
77 |
| -{% endfor %} |
78 |
| -{% endif %} |
| 121 | +# Include all configuration files in /etc/rsyslog.d/ |
| 122 | +include(file="/etc/rsyslog.d/*.conf") |
0 commit comments