summaryrefslogtreecommitdiff
path: root/data/templates/rsyslog
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-05-09 19:24:55 +0200
committerGitHub <noreply@github.com>2023-05-09 19:24:55 +0200
commit73ec6fd55d1881e9ca0439a993e9bda8e06d1448 (patch)
tree257f198d0ece25c420e0841cc5a4cd3135b0d85d /data/templates/rsyslog
parent3543aecf8463d5d6328ac669c12c482ed4e1ccba (diff)
parent46d2bcdb0b500b4d1b9d973ab5b9ca3c6cf44e51 (diff)
downloadvyos-1x-73ec6fd55d1881e9ca0439a993e9bda8e06d1448.tar.gz
vyos-1x-73ec6fd55d1881e9ca0439a993e9bda8e06d1448.zip
Merge pull request #1985 from c-po/t2778-syslog
syslog: T2778: T2769: refactoring and VRF support
Diffstat (limited to 'data/templates/rsyslog')
-rw-r--r--data/templates/rsyslog/logrotate.j216
-rw-r--r--data/templates/rsyslog/override.conf.j211
-rw-r--r--data/templates/rsyslog/rsyslog.conf59
-rw-r--r--data/templates/rsyslog/rsyslog.conf.j271
4 files changed, 98 insertions, 59 deletions
diff --git a/data/templates/rsyslog/logrotate.j2 b/data/templates/rsyslog/logrotate.j2
new file mode 100644
index 000000000..89d1a8a50
--- /dev/null
+++ b/data/templates/rsyslog/logrotate.j2
@@ -0,0 +1,16 @@
+### Autogenerated by system-syslog.py ###
+{% if file is vyos_defined %}
+{% for file_name, file_options in file.items() %}
+/var/log/user/{{ file_name }} {
+ missingok
+ notifempty
+ create
+ rotate {{ file_options.archive.file }}
+ size={{ file_options.archive.size | int // 1024 }}k
+ postrotate
+ invoke-rc.d rsyslog rotate > /dev/null
+ endscript
+}
+
+{% endfor %}
+{% endif %}
diff --git a/data/templates/rsyslog/override.conf.j2 b/data/templates/rsyslog/override.conf.j2
new file mode 100644
index 000000000..5f6a87edf
--- /dev/null
+++ b/data/templates/rsyslog/override.conf.j2
@@ -0,0 +1,11 @@
+{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is vyos_defined else '' %}
+[Unit]
+StartLimitIntervalSec=0
+
+[Service]
+ExecStart=
+ExecStart={{ vrf_command }}/usr/sbin/rsyslogd -n -iNONE
+Restart=always
+RestartPreventExitStatus=
+RestartSec=10
+RuntimeDirectoryPreserve=yes
diff --git a/data/templates/rsyslog/rsyslog.conf b/data/templates/rsyslog/rsyslog.conf
deleted file mode 100644
index ab60fc0f0..000000000
--- a/data/templates/rsyslog/rsyslog.conf
+++ /dev/null
@@ -1,59 +0,0 @@
-# /etc/rsyslog.conf Configuration file for rsyslog.
-#
-
-#################
-#### MODULES ####
-#################
-
-$ModLoad imuxsock # provides support for local system logging
-$ModLoad imklog # provides kernel logging support (previously done by rklogd)
-#$ModLoad immark # provides --MARK-- message capability
-
-$OmitLocalLogging off
-$SystemLogSocketName /run/systemd/journal/syslog
-
-$KLogPath /proc/kmsg
-
-# provides UDP syslog reception
-#$ModLoad imudp
-#$UDPServerRun 514
-
-# provides TCP syslog reception
-#$ModLoad imtcp
-#$InputTCPServerRun 514
-
-###########################
-#### GLOBAL DIRECTIVES ####
-###########################
-
-#
-# Use traditional timestamp format.
-# To enable high precision timestamps, comment out the following line.
-#
-$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
-
-# Filter duplicated messages
-$RepeatedMsgReduction on
-
-#
-# Set the default permissions for all log files.
-#
-$FileOwner root
-$FileGroup adm
-$FileCreateMode 0640
-$DirCreateMode 0755
-$Umask 0022
-
-
-#
-# Include all config files in /etc/rsyslog.d/
-#
-$IncludeConfig /etc/rsyslog.d/*.conf
-
-###############
-#### RULES ####
-###############
-# Emergencies are sent to everybody logged in.
-
-*.emerg :omusrmsg:*
-
diff --git a/data/templates/rsyslog/rsyslog.conf.j2 b/data/templates/rsyslog/rsyslog.conf.j2
new file mode 100644
index 000000000..0460ae5f0
--- /dev/null
+++ b/data/templates/rsyslog/rsyslog.conf.j2
@@ -0,0 +1,71 @@
+### Autogenerated by system-syslog.py ###
+
+{% if global.marker is vyos_defined %}
+$ModLoad immark
+{% if global.marker.interval is vyos_defined %}
+$MarkMessagePeriod {{ global.marker.interval }}
+{% endif %}
+{% endif %}
+{% if global.preserve_fqdn is vyos_defined %}
+$PreserveFQDN on
+{% endif %}
+
+# We always log to /var/log/messages
+$outchannel global,/var/log/messages,262144,/usr/sbin/logrotate {{ logrotate }}
+{% if global.facility is vyos_defined %}
+{% set tmp = [] %}
+{% for facility, facility_options in global.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omfile:$global
+{% endif %}
+
+{% if file is vyos_defined %}
+# File based configuration section
+{% for file_name, file_options in file.items() %}
+$outchannel {{ file_name }},/var/log/user/{{ file_name }},{{ file_options.archive.size }},/usr/sbin/logrotate {{ logrotate }}
+{% set tmp = [] %}
+{% for facility, facility_options in file_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omfile:${{ file }}
+{% endfor %}
+{% endif %}
+
+{% if console.facility is vyos_defined %}
+# Console logging
+{% set tmp = [] %}
+{% for facility, facility_options in console.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} /dev/console
+{% endif %}
+
+{% if host is vyos_defined %}
+# Remote logging
+{% for host_name, host_options in host.items() %}
+{% set tmp = [] %}
+{% for facility, facility_options in host_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{% if host_options.protocol is vyos_defined('tcp') %}
+{% if host_options.oct_count is vyos_defined %}
+{{ tmp | join(';') }} @@(o){{ host_name | bracketize_ipv6 }}:{{ host_options.port }};RSYSLOG_SyslogProtocol23Format
+{% else %}
+{{ tmp | join(';') }} @@{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}
+{% endif %}
+{% else %}
+{{ tmp | join(';') }} @{{ host_name | bracketize_ipv6 }}:{{ host_options.port }}{{ ';RSYSLOG_SyslogProtocol23Format' if host_options.format.octet_counted is vyos_defined }}
+{% endif %}
+{% endfor %}
+{% endif %}
+
+{% if user is defined and user is not none %}
+# Log to user terminal
+{% for username, user_options in user.items() %}
+{% for facility, facility_options in user_options.facility.items() %}
+{% set _ = tmp.append(facility.replace('all', '*') + '.' + facility_options.level) %}
+{% endfor %}
+{{ tmp | join(';') }} :omusrmsg:{{ username }}
+{% endfor %}
+{% endif %}