Univention Bugzilla – Attachment 5121 Details for
Bug 30751
Logfile test case (99check_log_files)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
99check_log_files
99check_log_files (text/plain), 1.64 KB, created by
Stefan Gohmann
on 2013-03-11 22:01 CET
(
hide
)
Description:
99check_log_files
Filename:
MIME Type:
Creator:
Stefan Gohmann
Created:
2013-03-11 22:01 CET
Size:
1.64 KB
patch
obsolete
>#!/usr/share/ucs-test/runner python2.6 >## desc: Check log files for errors and warnings >## tags: [basic] >## exposure: safe ># -*- coding: utf-8 -*. >import re >import gzip >import check_log_files_definitions as definitions >import sys >import os > >logs = [ > "/var/log/univention/updater.log", > "/var/log/univention/installation.log.gz", > "/var/log/univention/updater.log.gz" > ] >retVal = 100 > >def checkLine(line, definition, result, msg): > """Check a single 'line' against patterns from 'definition' and add message 'msg' to list 'result' if pattern in in wanted.""" > for pattern in definition.ignore: > if pattern.match(line): > return result > > for pattern in definition.wanted: > if pattern.match(line): > result.append(msg) > return result > > return result > >def checkFile(filename): > """Check file 'filename' for issues, returning 2-tuple (warnings, errors).""" > errors = [] > warnings = [] > counter = 0 > basename = os.path.basename(filename).replace(".gz", "") > > if not os.path.isfile(filename): > return (errors, warnings) > > if filename.endswith('.gz'): > fh = gzip.open(filename, "rb") > else: > fh = open(filename, "r") > for line in fh: > counter += 1 > line = line.strip() > msg = "%s:%s %s" % (basename, counter, line) > errors = checkLine(line, definitions.errors, errors, msg) > warnings = checkLine(line, definitions.warnings, warnings, msg) > fh.close() > > return (errors, warnings) > >for filename in logs: > err, warn = checkFile(filename) > if err: > print "Errors in %s" % filename > for line in err: > print " E:%s" % (line,) > retVal = 110 > if warn: > print "Warnings in %s" % filename > for line in warn: > print " W:%s" % (line,) > >sys.exit(retVal) ># vim:set ft=python:
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
Attachments on
bug 30751
: 5121 |
6084