Skip to content
/ sntzr Public

SNTZR utility - A small tool to help clean up log files.

License

Notifications You must be signed in to change notification settings

kieras/sntzr

Repository files navigation

SNTZR

A small tool to help clean up log files.

Installation

Run:

pipx install git+https://github.com/kieras/sntzr.git

Usage

Run:

sntzr --help

Sample configuration file:

---
global_regex:
  'gr://machine_name': '[A-Z0-9-]+'
  'gr://ipv4': '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
  'gr://host': '(?:[0-9A-Za-z][0-9A-Za-z-]{0,62})(?:\.(?:[0-9A-Za-z][0-9A-Za-z-]{0,62}))*'

patterns:
  - 'data': 'xml'
    'field': 'MachineName'
    'pattern': 'gr://machine_name'
    'replace': 'machine_name'
    'activated': true
  - 'data': 'xml'
    'field': 'IPAddress'
    'pattern': 'gr://ipv4'
    'replace': 'ipv4'
    'activated': true
  - 'data': 'raw'
    'field': '-'
    'pattern': 'gr://ipv4'
    'replace': 'ipv4'
    'activated': true
  - 'data': 'raw'
    'field': '-'
    'pattern': 'NCR'
    'replace': 'ALOHA'
    'activated': false
  - 'pattern': 'gr://host'
    'replace': 'www.acme.com'

include_patterns: [./patterns/sep.yaml]

Detailed info about each configuratio file field:

global_regex:

You should define the regex and choose a proper name so that it can be reused by patterns. The sytax is:

  'gr://<name_of_pattern>': '<regex>'

patterns:

  - 'data': 'xml'
    'field': 'Name'
    'pattern': 'gr://<pattern_reference>'
    'replace': '<replacer_function_name>'
    'activated': true

You should define 5 fields here.

  • data: It holds the type of data it is going to be looked for. The value might be: 'xml', 'kv', 'raw'.
  • field: It holds the name of the field. Ex: if the 'data': 'xml' the field might be 'Name' so we have the full representation for that: <Name>value</Name>
  • pattern: It holds the regex itself, a reference to a global_regex or a raw value.
  • replace: It holds the function name used to replace the pattern found or this raw value will be used instead.
  • activated: If you want to use this pattern, set to true, false otherwise.
  • obs: You may ommit the data, field and activated fields which are not mandatory. In this case, default values will be used: 'raw', '-', 'true' respectively.

include_patterns:

You should define an array here containing multiple .yaml files only made of patterns. This will extend all patterns you may have(or not on the sntzr.yaml file) plus all the ones you specify inside the array.

include_patterns: [./patterns/custom_1.yaml, ./patterns/custom_2.yaml]

Install from local directory

Clone the repo and execute the command:

pipx install -e --force .

About

SNTZR utility - A small tool to help clean up log files.

Resources

License

Stars

Watchers

Forks

Languages