summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2018-11-14 16:24:27 -0800
committerhagbard <vyosdev@derith.de>2018-11-14 16:24:27 -0800
commit439d86aa55c7eed9619391ecec04bc1fbd5f9323 (patch)
tree7e3e055a59f703403f2295c0aa18cb77821ee201
parent93c9199589cca87321f1f0577d16099dbe78842b (diff)
downloadvyos-1x-439d86aa55c7eed9619391ecec04bc1fbd5f9323.tar.gz
vyos-1x-439d86aa55c7eed9619391ecec04bc1fbd5f9323.zip
Fixes: T940 adding immark to syslog options
-rw-r--r--interface-definitions/syslog.xml15
-rwxr-xr-xsrc/conf_mode/syslog.py20
2 files changed, 29 insertions, 6 deletions
diff --git a/interface-definitions/syslog.xml b/interface-definitions/syslog.xml
index aafa91b55..a1479128c 100644
--- a/interface-definitions/syslog.xml
+++ b/interface-definitions/syslog.xml
@@ -520,6 +520,21 @@
</leafNode>
</children>
</tagNode>
+ <node name="marker">
+ <properties>
+ <help>mark messages sent to syslog</help>
+ </properties>
+ <children>
+ <leafNode name="interval">
+ <properties>
+ <help>time interval how often a mark message is being sent in seconds (default: 1200)</help>
+ <constraint>
+ <validator name="numeric" argument="--positive"/>
+ </constraint>
+ </properties>
+ </leafNode>
+ </children>
+ </node>
</children>
</node>
<tagNode name="file">
diff --git a/src/conf_mode/syslog.py b/src/conf_mode/syslog.py
index f652cf3d0..f8f8d9457 100755
--- a/src/conf_mode/syslog.py
+++ b/src/conf_mode/syslog.py
@@ -30,6 +30,12 @@ from vyos import ConfigError
configs = '''
## generated by syslog.py ##
## file based logging
+{% if files['global']['marker'] %}
+$ModLoad immark
+{% if files['global']['marker-interval'] %}
+$MarkMessagePeriod {{files['global']['marker-interval']}}
+{% endif %}
+{% endif %}
{% for file in files %}
$outchannel {{file}},{{files[file]['log-file']}},{{files[file]['max-size']}},{{files[file]['action-on-max-size']}}
{{files[file]['selectors']}} :omfile:${{file}}
@@ -80,10 +86,10 @@ def get_config():
c.set_level('system syslog')
config_data = {
- 'files' : {},
+ 'files' : {},
'console' : {},
- 'hosts' : {},
- 'user' : {}
+ 'hosts' : {},
+ 'user' : {}
}
#####
@@ -102,13 +108,16 @@ def get_config():
}
)
+ if c.exists('global marker'):
+ config_data['files']['global']['marker'] = True
+ if c.exists('global marker interval'):
+ config_data['files']['global']['marker-interval'] = c.return_value('global marker interval')
if c.exists('global facility'):
config_data['files']['global']['selectors'] = generate_selectors(c, 'global facility')
if c.exists('global archive size'):
config_data['files']['global']['max-size'] = int(c.return_value('global archive size'))* 1024
if c.exists('global archive files'):
config_data['files']['global']['max-files'] = c.return_value('global archive files')
-
###
# set system syslog file
###
@@ -217,14 +226,12 @@ def generate_selectors(c, config_node):
def generate(c):
tmpl = jinja2.Template(configs, trim_blocks=True)
config_text = tmpl.render(c)
- #print (config_text)
with open('/etc/rsyslog.d/vyos-rsyslog.conf', 'w') as f:
f.write(config_text)
## eventually write for each file its own logrotate file, since size is defined it shouldn't matter
tmpl = jinja2.Template(logrotate_configs, trim_blocks=True)
config_text = tmpl.render(c)
- #print (config_text)
with open('/etc/logrotate.d/vyos-rsyslog', 'w') as f:
f.write(config_text)
@@ -247,6 +254,7 @@ def verify(c):
fac = ['*','auth','authpriv','cron','daemon','kern','lpr','mail','mark','news','protocols','security',\
'syslog','user','uucp','local0','local1','local2','local3','local4','local5','local6','local7']
lvl = ['emerg','alert','crit','err','warning','notice','info','debug','*']
+
for conf in c:
if c[conf]:
for item in c[conf]: