rename parsers, better journald integration
[logparse.git] / logparse / config.py
index 8d1b21eb2065e1fe5bcedbb073c7c37bb3ebf9a0..00143fd059a0291cc31ec92467ebc1df6c54ae5c 100644 (file)
@@ -1,14 +1,15 @@
-#
-#   config.py
-#
-#   Default config values and basic wrapper for ConfigParser. New config options
-#   should be added to the dictionary below, along with appropriate defaults.
-#
-#   Runtime configuration is done through /etc/logparse/logparse.conf (default)
-#   or the path specified in the "--config" argument. The file uses the INI
-#   syntax, with general options being declared in the [logparse] section and
-#   parser-specific options declared in their own sections.
-#
+"""
+This modules contains default config values and basic wrapper for ConfigParser.
+New config options should be added to the dictionary below, along with 
+appropriate defaults. Runtime configuration is done through the config file at
+/etc/logparse/logparse.conf (default) or the path specified in the "--config"
+argument. The file uses the INI syntax, with general options being declared in
+the [logparse] section and parser-specific options declared in their own
+sections.
+
+This module provides the following methods:
+    - `loadconf()`: set up ConfigParser and process config file
+"""
 
 from configparser import ConfigParser
 from pkg_resources import Requirement, resource_filename
@@ -33,7 +34,10 @@ defaults = {
             'quiet': False,
             'hostname-path': '/etc/hostname',
             'parsers': '',
-            'ignore-parsers': ''
+            'ignore-parsers': '',
+            'period': '1 week',
+            'datetime-format': "%%b %%d %%H:%%M:%%S",
+            'journald': True
         },
         'html': {
             'header':  '/etc/logparse/header.html',
@@ -50,6 +54,7 @@ defaults = {
             'cron': '/var/log/cron.log',
             'cpuinfo': '/proc/cpuinfo',
             'meminfo': '/proc/meminfo',
+            'uptime': '/proc/uptime',
             'sys': '/var/log/syslog',
             'smbd': '/var/log/samba',
             'zfs': '/var/log/zpool.log',
@@ -58,6 +63,15 @@ defaults = {
             'httpd-access': '/var/log/apache2/access.log',
             'httpd-error': '/var/log/apache2/error.log'
         },
+        'cron': {
+            'summary': False,
+            'list-users': True,
+            'period': '',
+            'datetime-format': '',
+            'truncate-commands': True,
+            'users': '.*',
+            'commands': '.*'
+        },
         'mail': {
             'to': '',
             'from': '',
@@ -71,31 +85,54 @@ defaults = {
             'timeout': 10,
             'port': 7634,
             'show-model': False, 
+            'period': ''
         },
         'sshd': {
-            'sshd-resolve-domains': ''
+            'sshd-resolve-domains': '',
+            'period': ''
         },
         'smbd': {
-            'smbd-resolve-domains': ''
+            'shares': '^((?!IPC\$).)*$',
+            'users': '.*',
+            'smbd-resolve-domains': '',
+            'period': ''
         },
         'httpd': {
-            'httpd-resolve-domains': ''
+            'httpd-resolve-domains': '',
+            'datetime-format': "%%d/%%b/%%Y:%%H:%%M:%%S %%z",
+            'period': '',
+            'clients': '.*',
+            'files': '.*',
+            'referrers': '.*',
+            'access-format': "%%h %%l %%u %%t \"%%r\" %%>s %%O \"%%{Referer}i\" \"%%{User-Agent}i\""
         },
         'du': {
             'paths': ['/', '/etc', '/home'],
             'force-write': False
+        },
+        'ufw': {
+            'ufw-resolve-domains': '',
+            'period': ''
+        },
+        'sudo': {
+            'journald': '',
+            'datetime-format': '',
+            'period': '',
+            'list-users': True,
+            'summary': True,
+            'truncate-commands': True,
+            'init-users': '.*',
+            'superusers': '.*',
+            'commands': '.*',
+            'directories': '.*'
+
+        },
+        'systemd': {
+            'period': '',
+            'show-all': True
         }
 }
 
-def locate(filename):
-    """
-    DEPRECATED: draft method for what is now parsers/load_parsers.py. Kept here
-    for historical purposes.
-    """
-    logger.debug("Searching for {0}".format(filename))
-    loc = resource_filename(Requirement.parse(__package__), filename)
-    logger.debug("Found {0}".format(loc))
-    return loc
 
 def loadconf(configpaths):
     """
@@ -109,7 +146,8 @@ def loadconf(configpaths):
     prefs.read_dict(defaults)
     try:
         success = prefs.read(configpaths)
-        logger.debug("Loaded {0} config file(s): {1}".format(str(len(success)), str(success)))
+        logger.debug("Loaded {0} config file(s): {1}".format(
+                str(len(success)), str(success)))
     except Exception as e:
         logger.warning("Error processing config: " + str(e))
     return prefs