RsyslogConf - file /etc/rsyslog.conf

The rsyslog configuration files can include statements with two different line based formats along with snippets of ‘RainerScript’ that can span multiple lines.

See http://www.rsyslog.com/doc/master/configuration/basic_structure.html#statement-types

Due to high parsing complexity, this parser presents a simple line-based view of the file that meets the needs of the current rules.

Example

>>> content = '''
... :fromhost-ip, regex, "10.0.0.[0-9]" /tmp/my_syslog.log
... $ModLoad imtcp
... $InputTCPServerRun 10514"
... '''.strip()
>>> from insights.tests import context_wrap
>>> rsl = RsyslogConf(context_wrap(content))
>>> len(rsl)
3
>>> len(list(rsl))
3
>>> any('imtcp' in n for n in rsl)
True
class insights.parsers.rsyslog_conf.RsyslogConf(context)[source]

Bases: insights.core.Parser

Parses /etc/rsyslog.conf info simple lines.

Skips lines that begin with hash (“#”) or are only whitespace.

data

List of lines in the file that don’t start with ‘#’ and aren’t whitespace.

Type

list

config_items

Configuration items opportunistically found in the configuration file, with their values as given.

Type

dict

config_val(item, default=None)[source]

Return the given configuration item, or the default if not defined.

Parameters
  • item (str) -- The configuration item name

  • default -- The default if the item is not found (defaults to None)

Returns

The related value in the config_items dictionary.

parse_content(content)[source]

This method must be implemented by classes based on this class.