cas | 72 ++++++++++++++++++++++++++++++++++++++++++++-------------------
cas.spec | 4 +--
2 files changed, 53 insertions(+), 23 deletions(-)
New commits:
commit 7d155560f42983447893d8dd1d17ae470b33ea89
Author: Adam Stokes <ajs(a)redhat.com>
Date: Wed Jan 7 08:03:48 2009 -0500
- final preparations complete to include into fedora
rhbz#477190
- initial support for module extraction
- initial support for analyzing x86 cores on x86_64
machines
diff --git a/cas b/cas
index 004d9a0..d4bec50 100755
--- a/cas
+++ b/cas
@@ -137,9 +137,12 @@ class CasApplication(object):
help="Unique ID for core")
parser.add_option("-f","--file", dest="filename",
help="Filename")
- parser.add_option("-m","--email", dest="email",
+ parser.add_option("-e","--email", dest="email",
help="Define email for results (must be valid!)",
- action="store",
default="root(a)localhost.localdomain")
+ action="store")
+ parser.add_option("-m","--modules",
dest="kernel_modules",
+ help="Extract associated kernel modules",
+ action="store_true")
self.opts, args = parser.parse_args()
if not self.opts.identifier:
@@ -150,6 +153,7 @@ class CasApplication(object):
self.filename = self.opts.filename
self.identifier = self.opts.identifier
self.email = self.opts.email
+ self.extractKernelModules = self.opts.kernel_modules
self.storagePath = os.path.join(WORKDIRECTORY, self.identifier)
# build logger object to deal with logging per job and keep things
@@ -184,14 +188,27 @@ class CasApplication(object):
currentMachineArch = currentMachineArch.stdout.read().strip()
# Check if we have installed crash 32bit on system
if debugKernelArch == "i686" and CRASH_32 is not None:
- pass
- # TODO: re-write crash output library to take into account
+ # DONE: re-write crash output library to take into account
# 32bit crash on same system.
self.util.buildCrashFile(self.storagePath, corefile, debugKernel,
CRASH_32)
self.casLog.info("Current machine suitable for processing 32 bit core,
"\
"running crash.")
cmd = os.path.join(self.storagePath,"crash")
+ cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
+ cmdData = cmdPipe.communicate()
+ # pull status code to verify crash even ran to completeness
+ sts, out, err = (cmdPipe.returncode, cmdData[0].strip(),
+ cmdData[1].strip())
+ if sts:
+ self.casLog.debug("crash problem: err: %s, out: %s" % (err,
out))
+ elif debugKernelArch == currentMachineArch:
+ import platform
+ # Define current machine hostname, mainly used for email results.
+ casProcessMachine = platform.uname()[1]
+ # The machine is suitable for processing the core through crash.
+ self.casLog.info("Current machine suitable for processing core, running
crash.")
+ cmd = os.path.join(self.storagePath,"crash")
# DONE: capture any errors returned from crash when processing core.
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
@@ -200,7 +217,7 @@ class CasApplication(object):
cmdData[1].strip())
if sts:
self.casLog.debug("crash problem: err: %s, out: %s" % (err,
out))
- if debugKernelArch != currentMachineArch:
+ else:
# The machine running cas isn't capable of processing this core, lets
# attempt with Func. Assuming Func is installed and a server database
# is configured we attempt to process the core at another machine.
@@ -236,23 +253,36 @@ class CasApplication(object):
"and
http://fedorahosted.org/func is not installed/configured
properly.")
self.casLog.info("Finishing job without processing the core, please
find a suitable %s "\
"machine in order to view this core in crash." %
(debugKernelArch,))
- else:
- import platform
- # Define current machine hostname, mainly used for email results.
- casProcessMachine = platform.uname()[1]
- # The machine is suitable for processing the core through crash.
- self.casLog.info("Current machine suitable for processing core, running
crash.")
- cmd = os.path.join(self.storagePath,"crash")
- # DONE: capture any errors returned from crash when processing core.
- cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
- cmdData = cmdPipe.communicate()
- # pull status code to verify crash even ran to completeness
- sts, out, err = (cmdPipe.returncode, cmdData[0].strip(),
- cmdData[1].strip())
- if sts:
- self.casLog.debug("crash problem: err: %s, out: %s" % (err,
out))
crashOutFile = os.path.join(self.storagePath,"crash.out")
- if os.path.isfile(crashOutFile):
+ if os.path.isfile(crashOutFile) and self.extractKernelModules:
+ self.casLog.info("Extracting loaded kernels modules. This will " \
+ "take several minutes.")
+ # Here we extract kernel modules processed from crash.out
+ # this is usually desired during filesystem, storage
+ # analysis of a core.
+ crashOutFH = open(crashOutFile, 'r')
+ crashOutData = crashOutFH.readlines()
+ # search for MODULE NAME SIZE OBJECT FILE line
+ for item in enumerate(crashOutData):
+ idx, txt = item
+ if 'MODULE' in txt:
+ index = idx
+ moduleList = []
+ # we have our index of above, now we obtain
+ # the loaded modules from the list
+ for item in crashOutData[index+1:]:
+ moduleList.append(item.split()[1])
+ # shift through moduleList extracting from
+ # kernel as we go
+ for module in moduleList:
+ # This will extract all modules for each kernel within
+ # the debuginfo.
+ # TODO: Only extract the module for the debug kernel in use.
+ moduleFilter = "*/"+module+".ko*"
+ self.rpmTool.extract(debuginfo, self.storagePath,
+ filter=moduleFilter,
+ return_results=False)
+ if os.path.isfile(crashOutFile) and self.email:
self.casLog.info("Crash output processed, sending email to %s" %
(self.email,))
try:
# Compose email msg of results
diff --git a/cas.spec b/cas.spec
index 41b7542..dfe5cd7 100644
--- a/cas.spec
+++ b/cas.spec
@@ -3,7 +3,7 @@
Name: cas
Summary: Tool to analyze and configure core file environment
Version: 0.13
-Release: 114%{?dist}
+Release: 115%{?dist}
Source0:
https://fedorahosted.org/releases/c/a/cas/%{name}-%{version}.tar.gz
License: GPLv3+
Group: Development/Libraries
@@ -26,7 +26,7 @@ types to core dumps are automatically detected and processed.
%install
rm -rf ${RPM_BUILD_ROOT}
-%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT
+%{__python} setup.py install -O1 --skip-build --root ${RPM_BUILD_ROOT}
%clean
rm -rf ${RPM_BUILD_ROOT}