Hello, I attach a patch for epylog that adds a yum processing module. I am sending it here because I guess it is too early to submit it to Konstantin for epylog (as yum can't officially syslog it's events yet) but this way anyone interested can take a look. It expects messages in /var/log/yum.log format. It will create a section with optional subsections for various events (Updated, installed,...). Then it lists in a table: rpm, version, how many events and how many hosts (if different from how many events - e.g. if for testing same rpm was installed & removed multiple times on the same host). E.g. (plain text only, so please excuse the loss of formatting): ----------------------------- Yum Erased lftp 2.6.10-1.i386 4(1) yum 2.0.4-2.JP.0.noarch 1 Installed kernel 2.4.22-1.2138.nptl.i686 1 lftp 2.6.10-1.i386 2(1) Updated lftp 2.6.10-1.i386 1 ---------------------------- or --------------------------- Yum lftp 2.6.10-1.i386 Erased 4(1) yum 2.0.4-2.JP.0.noarch Erased 1 kernel 2.4.22-1.2138.nptl.i686 Installed 1 lftp 2.6.10-1.i386 Installed 2(1) lftp 2.6.10-1.i386 Updated 1 ----------------- Josko P. -------------- next part -------------- diff -urN epylog-0.9.6-original/doc/testcase/yum.testcase epylog-0.9.6/doc/testcase/yum.testcase --- epylog-0.9.6-original/doc/testcase/yum.testcase 1969-12-31 19:00:00.000000000 -0500 +++ epylog-0.9.6/doc/testcase/yum.testcase 2004-01-09 15:10:12.000000000 -0500 @@ -0,0 +1,9 @@ +Jan 5 22:51:25 localhost yum: Installed: kernel 2.4.22-1.2138.nptl.i686 +Jan 5 23:06:26 localhost yum: Erased: lftp 2.6.10-1.i386 +Jan 5 23:13:04 localhost yum: Updated: lftp 2.6.10-1.i386 +Jan 8 16:12:40 localhost yum: Erased: yum 2.0.4-2.noarch +Jan 8 16:30:35 localhost yum: Erased: lftp 2.6.10-1.i386 +Jan 8 16:31:25 localhost yum: Installed: lftp 2.6.10-1.i386 +Jan 8 16:40:14 localhost yum: Erased: lftp 2.6.10-1.i386 +Jan 8 16:40:39 localhost yum: Installed: lftp 2.6.10-1.i386 +Jan 8 16:41:09 localhost yum: Erased: lftp 2.6.10-1.i386 diff -urN epylog-0.9.6-original/etc/modules.d/Makefile.in epylog-0.9.6/etc/modules.d/Makefile.in --- epylog-0.9.6-original/etc/modules.d/Makefile.in 2003-05-01 23:42:40.000000000 -0400 +++ epylog-0.9.6/etc/modules.d/Makefile.in 2004-01-09 15:07:25.000000000 -0500 @@ -31,7 +31,7 @@ LYNX_BIN = @LYNX_BIN@ INSTALLDIRS = $(pkgconfdir)/modules.d -MCONFS = mail packets weeder logins notices spamd +MCONFS = mail packets weeder logins notices spamd yum all: for MCONF in $(MCONFS); do \ diff -urN epylog-0.9.6-original/etc/modules.d/yum.conf.in epylog-0.9.6/etc/modules.d/yum.conf.in --- epylog-0.9.6-original/etc/modules.d/yum.conf.in 1969-12-31 19:00:00.000000000 -0500 +++ epylog-0.9.6/etc/modules.d/yum.conf.in 2004-01-09 15:07:07.000000000 -0500 @@ -0,0 +1,18 @@ +[module] +desc = Yum +exec = %%MODULES_DIR%%/yum_mod.py +files = /var/log/messages[.#] +enabled = yes +internal = yes +outhtml = yes +priority = 7 + +[conf] +## +# ident string to expect, should be yum always +# +yum_ident = yum +## +# group by actions or stick them all in the same table? +# +group_actions = 1 diff -urN epylog-0.9.6-original/modules/Makefile.in epylog-0.9.6/modules/Makefile.in --- epylog-0.9.6-original/modules/Makefile.in 2003-05-01 23:42:41.000000000 -0400 +++ epylog-0.9.6/modules/Makefile.in 2004-01-09 15:08:52.000000000 -0500 @@ -32,7 +32,7 @@ LYNX_BIN = @LYNX_BIN@ INSTALLDIRS = $(MODULES_DIR) -EPYMODS = mail_mod notices_mod spamd_mod logins_mod packets_mod weeder_mod +EPYMODS = mail_mod notices_mod spamd_mod logins_mod packets_mod weeder_mod yum_mod all: $(COMPILEDIR_SCRIPT) . diff -urN epylog-0.9.6-original/modules/yum_mod.py epylog-0.9.6/modules/yum_mod.py --- epylog-0.9.6-original/modules/yum_mod.py 1969-12-31 19:00:00.000000000 -0500 +++ epylog-0.9.6/modules/yum_mod.py 2004-01-09 15:08:12.000000000 -0500 @@ -0,0 +1,113 @@ +#!/usr/bin/python -tt +""" +Scan for yum log messages. +""" +## +# Copyright (C) 2003 by Josko Plazonic +# Copyright (C) 2003 by Duke University +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# +# @Author Josko Plazonic <plazonic@xxxxxxxxxxxxxxxxxx> +# @Author Konstantin Riabitsev <icon@xxxxxxxxxxxx> +# @version $Date: 2003/04/18 04:28:26 $ +# + +import sys +import re + +## +# This is for testing purposes, so you can invoke this from the +# modules directory. See also the testing notes at the end of the +# file. +# +sys.path.insert(0, '../py/') +from epylog import InternalModule, Result + +class yum_mod(InternalModule): + def __init__(self, opts, logger): + InternalModule.__init__(self) + self.logger = logger + rc = re.compile + self.regex_map = { + rc('%s: ' % opts.get('yum_ident', 'yum')): self.yum + } + + self.group_actions = int(opts.get('group_actions', '1')) + + self.yum_re = rc('\s+(.*?):\s+(\S+)\s+(\S+).*') + + # formatting, note that we can have a variable number of columns, depends on section and user choice + self.sub_title = '<tr><th colspan="%s" align="left"><h3><font color="blue">%s</font></h3></th></tr>\n' + self.report_wrap = '<table border="0" width="100%%" rules="cols" cellpadding="2">%s</table>\n' + self.report_line_wrap = '<tr%s>%s</tr>\n' + self.report_line_cell = '<td valign="top">%s</td>' + self.flip = ' bgcolor="#dddddd"' + + + ## + # Line-matching routines + # + def yum(self, linemap): + sys, msg, mult = self.get_smm(linemap) + try: + action, name, version = self.yum_re.search(msg).groups() + except: + self.logger.put(0, 'Odd yum line: %s' % msg) + return None + return {(action, name, version, sys): mult} + + def finalize(self, rs): + report = '' + flipper = '' + all_actions = rs.get_distinct(()) + if self.group_actions: + report_columns = 3 + report_data = "name, version, total" + else: + report_columns = 4 + report_data = "name, version, action, total" + report_line = report_columns*self.report_line_cell + for action in all_actions: + if self.group_actions: + report += self.sub_title % (report_columns, action) + flipper = '' + # we do it this way because I want to know how many total events + # as well as how many machines (as an event could happen multiple + # times on the same machine, e.g. due to testing) + for name in rs.get_distinct((action,)): + total = 0 + unique = 0 + for version in rs.get_distinct((action,name,)): + for sys in rs.get_distinct((action,name,version,)): + unique+= 1 + total += rs[(action,name,version,sys)] + if flipper: flipper = '' + else: flipper = self.flip + if total != unique: + total = "%d(%d)" %(total, unique) + report += self.report_line_wrap % (flipper, eval("'" + report_line + "' % (" + report_data + ")")) + report = self.report_wrap % report + return report + +## +# This is useful when testing your module out. +# Invoke without command-line parameters to learn about the proper +# invocation. +# +if __name__ == '__main__': + from epylog.helpers import ModuleTest + ModuleTest(yum_mod, sys.argv)