From 945ab070b72ebd9f5ccfe0052ed138a93b83b297 Mon Sep 17 00:00:00 2001 From: zsdc Date: Mon, 13 Dec 2021 20:05:25 +0200 Subject: logs: T3774: Added new CLI item Added the ability to control the `/var/log/messages` rotation. Renamed the option `maxsize` to `max-size`. --- src/conf_mode/system-logs.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/conf_mode') diff --git a/src/conf_mode/system-logs.py b/src/conf_mode/system-logs.py index 7b5af240f..a9f2da476 100755 --- a/src/conf_mode/system-logs.py +++ b/src/conf_mode/system-logs.py @@ -24,8 +24,9 @@ from vyos.template import render from vyos.util import dict_search airbag.enable() -# path to logrotate config for atop +# path to logrotate configs logrotate_atop_file = '/etc/logrotate.d/vyos-atop' +logrotate_rsyslog_file = '/etc/logrotate.d/vyos-rsyslog' def get_config(config=None): @@ -35,7 +36,7 @@ def get_config(config=None): conf = Config() base = ['system', 'logs'] - logs_config = conf.get_config_dict(base) + logs_config = conf.get_config_dict(base, key_mangling=('-', '_')) return logs_config @@ -55,6 +56,16 @@ def generate(logs_config): 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 = {} + # generate new config file for rsyslog + syslog.debug('Adding logrotate config for rsyslog') + render(logrotate_rsyslog_file, 'logs/logrotate/vyos-rsyslog.tmpl', + logrotate_rsyslog) + def apply(logs_config): # No further actions needed -- cgit v1.2.3