summaryrefslogtreecommitdiff
path: root/data/templates/rsyslog
diff options
context:
space:
mode:
Diffstat (limited to 'data/templates/rsyslog')
-rw-r--r--data/templates/rsyslog/logrotate.j216
-rw-r--r--data/templates/rsyslog/rsyslog.conf59
-rw-r--r--data/templates/rsyslog/rsyslog.conf.j271
3 files changed, 87 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/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 %}