cas | 7 ++++--- cas.conf | 14 ++++++++++++-- casprint | 37 +++++++++++++++++++++++-------------- lib/cas/rpmutils.py | 3 +-- version | 2 +- 5 files changed, 41 insertions(+), 22 deletions(-)
New commits: commit 588f80a3f10bdaeb5bd3b220d9ca1c294035d62e Author: Adam Stokes adam@conans.battleaxe Date: Thu Oct 23 19:08:33 2008 -0400
casprint seems to capture all extracted debugs and timestamp.
db tree is sorted in the form of
RPM '-> [ ( debugKernel, timestamp ) ( debugKernel, timestamp ) ]
added support for find's emacs regex for fine tuning kernel-debuginfo searches.
cas is about 85% complete with has the ability to detect timestamps within cores, test for proper corefile and extraction. builds out a crash wrapper for ease of use when loading the necessary files for crash to proceed.
diff --git a/cas b/cas index 007878c..5d5d16f 100755 --- a/cas +++ b/cas @@ -51,10 +51,11 @@ class TimestampHandler(object): rpmDB = self.util.load(RPMS) coreTimestamp = self.tool.timestamp(self.corefile) if coreTimestamp: - dprint(coreTimestamp, DPRINT) for k,v in rpmDB.iteritems(): - if rpmDB[k].timestamp and coreTimestamp in rpmDB[k].timestamp: - return (k, rpmDB[k].debugKernel) + for coreObj in rpmDB[k]: + debugKernel, timestamp = coreObj + if timestamp and coreTimestamp in timestamp: + return (k, debugKernel) else: dprint("Unable to match fingerprint : %s" % (coreTimestamp,), DPRINT) sys.exit(1) diff --git a/cas.conf b/cas.conf index 6de30b4..3d995a5 100644 --- a/cas.conf +++ b/cas.conf @@ -1,19 +1,29 @@ [settings] # Where kernels are stored -# NOTE: this _can_ include symlinked directories, just be careful they are indefinately -# recursive +# NOTE: this _can_ include symlinked directories, just be careful they are +# indefinately recursive kernels=/mnt/kernels + # Database which houses all kernel found in $kernels rpms=/var/db/cas/rpms.db + +# Compose emacs regular expression for determing what +# kernel debug rpms you wish to search for +rpmFilter=.*kernel-debuginfo-[0-9].*.rpm + # Define where to store necessary debug information # NOTE: This is more than likely going to be temporary storage # so you could essentially set this to /tmp if space permitted debugs=/cores/debugs + # debug print on? (True/False) dprint=True + # define work directory workDirectory=/cores/processed + # database to house cas servers servers=/var/db/cas/servers.db + # define processing jobs db jobs=/var/db/cas/jobs.db diff --git a/casprint b/casprint index 4fcff4e..adf568d 100755 --- a/casprint +++ b/casprint @@ -6,7 +6,6 @@ import ConfigParser import optparse import sys
-from cas.db import Core from cas.utilities import Utilities, CoreTool, dprint, sprint from cas.rpmutils import Analyze, Tools from subprocess import Popen, PIPE @@ -20,6 +19,7 @@ config = ConfigParser.ConfigParser() config.read("/etc/cas.conf") KERNELS = config.get("settings","kernels") RPMS = config.get("settings","rpms") +RPMFILTER = config.get("settings","rpmFilter") DEBUGS = config.get("settings","debugs") DPRINT = config.get("settings","dprint")
@@ -27,43 +27,52 @@ class CasDatabaseHandler(object): def __init__(self): self.util = Utilities() if os.path.isfile(RPMS): - self.debugList = self.util.load(RPMS) + self.rpmDB = self.util.load(RPMS) else: - self.debugList = {} + self.rpmDB = {}
def rpmExist(self, rpm): """ checks existence of rpm in db """ - if self.debugList.has_key(rpm): + if self.rpmDB.has_key(rpm): return True return False
def run(self): rpms = [] - cmd = ["find", "-L", KERNELS, "-iname", "kernel-debuginfo*rpm"] + # Uses emacs regex -- see `man find` + cmd = ["find", "-L", KERNELS, "-iregex", RPMFILTER] pipe = Popen(cmd, stdout=PIPE, stderr=PIPE) for line in pipe.stdout: rpms.append(line.strip()) sprint("(found) %-100s" % (os.path.basename(line.strip()),)) totalRpms = len(rpms) count = 0 + """ Build database out in the form of + RPM - [( DebugKernel, Timestamp), + ( DebugKernel2, Timestamp2)] + """ for x in rpms: if not self.rpmExist(x): + self.rpmDB[x] = [] count = count + 1 dst = os.path.join(DEBUGS, str(count)) rpmTool = Tools() - coreObj = Core() sprint("(extracting) [%d/%d] %-100s" % (count, totalRpms, os.path.basename(x))) results = rpmTool.extract(x, dst) + # Sort through extracted debug for each type + # e.g. hugemem, PAE, smp, largesmp for item in results: vmlinux = item.strip() stamper = CoreTool() - coreObj.debugKernel = os.path.normpath(vmlinux) - coreObj.timestamp = stamper.timestamp(coreObj.debugKernel) - self.debugList[x] = coreObj - sprint("(timestamp) %-100s" % (coreObj.debugKernel,)) - rmtree(dst) - self.util.save(self.debugList, RPMS) + debugKernel = os.path.normpath(vmlinux) + timestamp = stamper.timestamp(debugKernel) + # Build tuple of each debug type + self.rpmDB[x].append((debugKernel, timestamp)) + sprint("(timestamp) %-100s" % (debugKernel,)) + self.util.save(self.rpmDB, RPMS) + # Cleanup extracted debugs + rmtree(dst) return
class CasprintApplication(object): @@ -89,10 +98,10 @@ class CasprintApplication(object): util.mkdir(DEBUGS)
if self.opts.buildDB: - print("::: Building CAS DB instance. :::") + print("::: Starting CAS DB instance. :::") dbHandler = CasDatabaseHandler().run() else: - print("Please define -b switch to update the CAS database.") + print("Please define -b switch to initialize/update the CAS database.") raise sys.exit(1)
if __name__=="__main__": diff --git a/lib/cas/rpmutils.py b/lib/cas/rpmutils.py index 44c8f9b..7c6d03e 100644 --- a/lib/cas/rpmutils.py +++ b/lib/cas/rpmutils.py @@ -1,4 +1,3 @@ -# rpm.py # rpm utilities
import rpm @@ -67,7 +66,7 @@ class Tools(object): stdout=PIPE,stderr=PIPE) out, err = p2.communicate() if return_results: - tmp = err.split("\n")[:1] + tmp = err.splitlines()[:-1] for item in tmp: self.filter_results.append(item) return self.filter_results diff --git a/version b/version index d4d75d0..2e9ff79 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.13 65 +0.13 69