summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/logs/logrotate/vyos-atop.tmpl4
-rw-r--r--data/templates/logs/logrotate/vyos-rsyslog.tmpl8
-rw-r--r--interface-definitions/system-logs.xml.in2
-rwxr-xr-xsrc/conf_mode/system-logs.py18
4 files changed, 16 insertions, 16 deletions
diff --git a/data/templates/logs/logrotate/vyos-atop.tmpl b/data/templates/logs/logrotate/vyos-atop.tmpl
index 444d1da36..2d078f379 100644
--- a/data/templates/logs/logrotate/vyos-atop.tmpl
+++ b/data/templates/logs/logrotate/vyos-atop.tmpl
@@ -2,12 +2,12 @@
daily
dateext
dateformat _%Y-%m-%d_%H-%M-%S
- maxsize {{ max_size|default('10') }}M
+ maxsize {{ max_size }}M
missingok
nocompress
nocreate
nomail
- rotate {{ rotate|default('10') }}
+ rotate {{ rotate }}
prerotate
# stop the service
systemctl stop atop.service
diff --git a/data/templates/logs/logrotate/vyos-rsyslog.tmpl b/data/templates/logs/logrotate/vyos-rsyslog.tmpl
index 3af1bfd8e..f2e4d2ab2 100644
--- a/data/templates/logs/logrotate/vyos-rsyslog.tmpl
+++ b/data/templates/logs/logrotate/vyos-rsyslog.tmpl
@@ -3,11 +3,11 @@
missingok
nomail
notifempty
- rotate {{ rotate|default('10') }}
- size {{ max_size|default('1') }}M
+ rotate {{ rotate }}
+ size {{ max_size }}M
postrotate
- # restart rsyslog service
- systemctl restart rsyslog.service
+ # inform rsyslog service about rotation
+ /usr/lib/rsyslog/rsyslog-rotate
endscript
}
diff --git a/interface-definitions/system-logs.xml.in b/interface-definitions/system-logs.xml.in
index dc5751372..8b6c7c399 100644
--- a/interface-definitions/system-logs.xml.in
+++ b/interface-definitions/system-logs.xml.in
@@ -65,7 +65,7 @@
</constraint>
<constraintErrorMessage>The size must be between 1 and 1024 MB</constraintErrorMessage>
</properties>
- <defaultValue>10</defaultValue>
+ <defaultValue>1</defaultValue>
</leafNode>
<leafNode name="rotate">
<properties>
diff --git a/src/conf_mode/system-logs.py b/src/conf_mode/system-logs.py
index a9f2da476..e6296656d 100755
--- a/src/conf_mode/system-logs.py
+++ b/src/conf_mode/system-logs.py
@@ -19,9 +19,11 @@ from sys import exit
from vyos import ConfigError
from vyos import airbag
from vyos.config import Config
+from vyos.configdict import dict_merge
from vyos.logger import syslog
from vyos.template import render
from vyos.util import dict_search
+from vyos.xml import defaults
airbag.enable()
# path to logrotate configs
@@ -36,7 +38,11 @@ def get_config(config=None):
conf = Config()
base = ['system', 'logs']
- logs_config = conf.get_config_dict(base, key_mangling=('-', '_'))
+ default_values = defaults(base)
+ logs_config = conf.get_config_dict(base,
+ key_mangling=('-', '_'),
+ get_first_key=True)
+ logs_config = dict_merge(default_values, logs_config)
return logs_config
@@ -48,19 +54,13 @@ def verify(logs_config):
def generate(logs_config):
# get configuration for logrotate atop
- logrotate_atop = dict_search('logs.logrotate.atop', logs_config)
- # provide an empty dictionary if there is no config
- if not logrotate_atop:
- logrotate_atop = {}
+ logrotate_atop = dict_search('logrotate.atop', logs_config)
# generate new config file for atop
syslog.debug('Adding logrotate config for atop')
render(logrotate_atop_file, 'logs/logrotate/vyos-atop.tmpl', logrotate_atop)
# get configuration for logrotate rsyslog
- logrotate_rsyslog = dict_search('logs.logrotate.messages', logs_config)
- # provide an empty dictionary if there is no config
- if not logrotate_rsyslog:
- logrotate_rsyslog = {}
+ logrotate_rsyslog = dict_search('logrotate.messages', logs_config)
# generate new config file for rsyslog
syslog.debug('Adding logrotate config for rsyslog')
render(logrotate_rsyslog_file, 'logs/logrotate/vyos-rsyslog.tmpl',