Customize logfile representation in webconf with filters

Revision History
Revision 1.0March 2007
Initial document

Table of Contents

Customize logfile representation in webconf with filters

Customize logfile representation in webconf with filters

About logfiles and filters

Beginning with version 3.1 it will be possible to add filters to webconf to customize the representation of logfiles.

LEAF Bering-uClibc uses log files with elementary names like in the following list:

auth.log
cron.log
daemon.log
debug
mail.log
messages
mini_httpd.log
shorewall.log
syslog
ulogd.log
user.log

After a few days they also have the extensions 0, 1.gz, 2.gz and so on due to logrotation.

The webconf-script logfiles.cgi contructs a new subdirectory /var/webconf/lib/filter/ which collects executables that take stdin as input and transforms it in someway to produce output at stdout. In order to be accepted, any file in this directory must be executable and carry a name according to the principle

"elementary name of log file"."arbitrary extension"

The webconf package provides three examples:

daemon.log.show.request-ack
debug.only.REQUEST
messages.non-MARK

There will be entries under "specialized viewing" when logfiles.cgi is summoned to reflect filters like the expamples, but not with such clumsy names. Instead there will be entries like:

show.request-ack for daemon.log, daemon.log.0 ...
only.REQUEST for debug debug.0, debug.1.gz ...
non-MARK for messages, messages.0 ...

This works like the old entry "view" did, but now the text is preprocessed with a filter according to your desires before being sent back to your workstation for viewing in the browser.

The contents of a filter can be built as simple shellscript up to complex expressions - you are just limited by the available text processing capabilities of your LEAF box - see examples below.

Example 1. messages.non-MARK remove the "---MARK---" lines before showing "messages".

!/bin/sh
# Only removes all lines with 'MARK'
grep -v MARK

Example 2. daemon.log.show.request-ack shows only lines of daemon.log where DHCP ack'ed a client request.

!/bin/sh
# Single out DHCPREQUEST and DHCPACK
sed '/DHCP\(REQUEST\)\|\(ACK\)/!d'