Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to provide additional date patterns #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ syslog-summary (1.15) UNRELEASED

-- David Paleino <d.paleino@gmail.com> #DATE#

* Added ability to provide additional date patterns. By default, regular
expressions are read from file /etc/syslog-summary/dates.rules. Custom
rule file may be specified via --dates=<file> option.

-- Petr Gajdůšek <petr.gajdusek@egston.com> #DATE#

syslog-summary (1.14)

* Added ability to read gzip compressed files, using python-magic or, if
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ install:
mkdir -p $(DESTDIR)/etc/syslog-summary/
install -m 755 syslog-summary $(DESTDIR)/usr/bin/syslog-summary
install -m 644 ignore.rules $(DESTDIR)/etc/syslog-summary/ignore.rules
install -m 644 dates.rules $(DESTDIR)/etc/syslog-summary/dates.rules

uninstall:
[ ! -f $(DESTDIR)/usr/bin/syslog-summary ] || rm -v $(DESTDIR)/usr/bin/syslog-summary
Expand Down
7 changes: 7 additions & 0 deletions dates.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Use this file to define additinal regular expressions for date patterns.
#
# Patterns should match only on beginning of a line, i.e. regular
# expressions should start with caret (^).
#
#^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9][ ]
5 changes: 5 additions & 0 deletions syslog-summary
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def main():
parser.add_option("-i", "--ignore", dest="ignorefile", default="/etc/syslog-summary/ignore.rules",
help="read regular expressions from <file>, and ignore lines in the <logfile> that match them",
metavar="<file>")
parser.add_option("--dates", dest="datesfile", default="/etc/syslog-summary/dates.rules",
help="read additional date patterns as regular expressions from <file>",
metavar="<file>")
parser.add_option("-s", "--state", dest="statefile",
help="read state information from <file> (see the man page)",
metavar="<file>")
Expand All @@ -267,12 +270,14 @@ def main():
parser.error("no logfile specified")

IGNORE_FILENAME = options.ignorefile
DATES_FILENAME = options.datesfile
STATE_FILENAME = options.statefile
REPEAT = options.repeat
QUIET = options.quiet
DEBUG = options.debug

ignore_pats = read_patterns(IGNORE_FILENAME)
datepats.extend(read_patterns(DATES_FILENAME))
states = read_states(STATE_FILENAME)
for filename in args:
summarize(filename, states)
Expand Down
18 changes: 18 additions & 0 deletions syslog-summary.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@
</group>
<replaceable class="option">filename</replaceable>
</arg>
<arg choice="opt">
<group choice="plain">
<arg choice="plain"><option>--dates=</option></arg>
</group>
<replaceable class="option">filename</replaceable>
</arg>
<arg choice="opt">
<group choice="plain">
<arg choice="plain"><option>-d</option></arg>
Expand Down Expand Up @@ -158,6 +164,12 @@
and ignore lines in the logfiles that match them.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--dates=<replaceable>filename</replaceable></option></term>
<listitem>
<para>Read additional date patterns as regular expressions from <replaceable>filename</replaceable>.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-s <replaceable>filename</replaceable></option></term>
<term><option>--state=<replaceable>filename</replaceable></option></term>
Expand Down Expand Up @@ -203,6 +215,12 @@
<para>Default ignore.rules file with default regular expressions.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><filename>/etc/syslog-summary/dates.rules</filename></term>
<listitem>
<para>Default dates.rules file with regular expressions for additional date patterns.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="diagnostics">
Expand Down