diff options
author | zsdc <taras@vyos.io> | 2021-12-13 20:05:25 +0200 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2021-12-13 21:45:47 +0200 |
commit | 945ab070b72ebd9f5ccfe0052ed138a93b83b297 (patch) | |
tree | 9e3c40eba1190f9e8edff9fb9c1219b18cc91fc0 /src/conf_mode/system-logs.py | |
parent | a22ba14999a38217155a7a999f61e855d813cc41 (diff) | |
download | vyos-1x-945ab070b72ebd9f5ccfe0052ed138a93b83b297.tar.gz vyos-1x-945ab070b72ebd9f5ccfe0052ed138a93b83b297.zip |
logs: T3774: Added new CLI item
Added the ability to control the `/var/log/messages` rotation.
Renamed the option `maxsize` to `max-size`.
Diffstat (limited to 'src/conf_mode/system-logs.py')
-rwxr-xr-x | src/conf_mode/system-logs.py | 15 |
1 files changed, 13 insertions, 2 deletions
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 |