cas-admin lib/cas
by Adam Stokes
cas-admin | 37 +++++++++++++++++-------------------
lib/cas/db.py | 59 +++++++++++++++++++++++++++++++++-------------------------
2 files changed, 52 insertions(+), 44 deletions(-)
New commits:
commit ca2d964a91f173a0accb3cdaceec24108f1ef119
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Tue Apr 14 11:18:56 2009 -0400
- implementing first stages of db interaction within cas-admin
- updated database methods
diff --git a/cas-admin b/cas-admin
index 1c53ea7..b2d5f84 100755
--- a/cas-admin
+++ b/cas-admin
@@ -63,26 +63,25 @@ class CasDatabaseHandler(object):
self.casLog.status("(found) %-5d kernel(s)" % (count,))
count = count + 1
# query database for debuginfo rpms
- rpms = self.db.getDebuginfoRPM()
+ rpms = self.db.getAllDebuginfoRPM()
for id, rpm in rpms:
- if not self.rpmExist(rpm):
- # temporary storage path in form of DEBUGS/COUNT
- dst = os.path.join(DEBUGS, str(count))
- rpmTool = RPMBase()
- self.casLog.status("(extracting) %-50s" % (rpm))
- results = rpmTool.extract(rpm, dst)
- # Sort through extracted debug for each type
- # e.g. hugemem, PAE, smp, largesmp
- for item in results:
- vmlinux = item.strip()
- stamper = CoreBase()
- debugKernel = os.path.normpath(vmlinux)
- timestamp = stamper.timestamp(debugKernel)
- # add rpm id, debug, timestamp to database
- self.db.addTimestamp(id, debugKernel, timestamp)
- self.util.save(self.rpmDB, RPMS)
- # Cleanup extracted debugs
- rmtree(dst)
+ # temporary storage path in form of DEBUGS/COUNT
+ dst = os.path.join(DEBUGS, str(count))
+ rpmTool = RPMBase()
+ self.casLog.status("(extracting) %-50s" % (rpm))
+ results = rpmTool.extract(rpm, dst)
+ # Sort through extracted debug for each type
+ # e.g. hugemem, PAE, smp, largesmp
+ for item in results:
+ vmlinux = item.strip()
+ stamper = CoreBase()
+ debugKernel = os.path.normpath(vmlinux)
+ timestamp = stamper.timestamp(debugKernel)
+ # add rpm id, debug, timestamp to database
+ self.db.addTimestamp(id, debugKernel, timestamp)
+ self.util.save(self.rpmDB, RPMS)
+ # Cleanup extracted debugs
+ rmtree(dst)
return
class CasServerHandler(object):
diff --git a/lib/cas/db.py b/lib/cas/db.py
index e9b13e7..b0478a6 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -17,57 +17,66 @@ class CasStorage(object):
self.conn = None
self.cursor = None
- def buildTable(self):
- self.cursor.execute('''create table cas_jobs
- (date text, submitter text, corepath text, debugpath text,
- server text)
-
- create table debuginfo (debug_id integer primary key autoincrement, rpm text)
+ def connect(self):
+ """ execute connection """
+ try:
+ self.conn = sqlite.connect(self.db)
+ self.cursor = self.conn.cursor()
+ except:
+ raise CasStorageException('Cannot connect to database')
+ return
- create table timestamp (timestamp_id integer primary key autoincrement,
- debugpath text, timestamp text, debug_id integer)''')
+ def commit(self):
self.conn.commit()
return
+ def buildTable(self):
+ self.cursor.execute("create table cas_jobs (job_id integer primary key autoincrement, date text, submitter text, corepath text, debug_id integer, server_id integer, iterations integer)")
+ self.cursor.execute("create table debuginfo (debug_id integer primary key autoincrement, rpm text)")
+ self.cursor.execute("create table timestamp (timestamp_id integer primary key autoincrement, debugpath text, timestamp text, debug_id integer)")
+ self.commit()
+ return
+
# DEBUGINFO METHODS
def addDebuginfoRPM(self, debuginfo):
- self.cursor.execute("INSERT into debuginfo('rpm') values(?)", debuginfo)
+ self.cursor.execute("SELECT * from debuginfo where debuginfo=?", debuginfo)
+ if not self.cursor.fetchone():
+ self.cursor.execute("INSERT into debuginfo('rpm') values(?)", debuginfo)
+ self.commit()
return
- def getDebuginfoRPM(self):
+ def getAllDebuginfoRPM(self):
self.cursor.execute("SELECT * FROM debuginfo")
- return self.cursor
+ return self.cursor.fetchall()
# TIMESTAMP METHODS
def addTimestamp(self, id, debug, timestamp):
""" build relation to debuginfo rpm and add debug path, timestamp """
- self.cursor.execute("""INSERT into timestamp('debug_id','debugpath',
+ self.cursor.execute("""INSERT into timestamp ('debug_id','debugpath',
'timestamp') values(?,?,?)""", id, debug, timestamp)
-
- def connect(self):
- """ execute connection """
- try:
- if not os.path.isfile(self.db):
- # build out sql table
- self.buildTable()
- self.conn = sqlite.connect(self.db)
- self.cursor = self.conn.cursor()
- except:
- raise CasStorageException('Cannot connect to database')
+ self.commit()
return
+ # JOB METHODS
def getAllJobs(self):
""" all jobs """
self.cursor.execute("SELECT * FROM cas_jobs")
- return self.cursor
+ return self.cursor.fetchall()
def getJobById(self, id):
""" single job """
self.cursor.execute("SELECT * FROM cas_jobs where id=?", id)
- return self.cursor
+ return self.cursor.fetchone()
def getJobRange(self, days):
""" provides jobs based on creation date from
$days back
"""
pass
+
+ def addJob(self, submitter, corepath, debug_id, server_id):
+ """ add job to db """
+ self.cursor.execute("""INSERT into cas_jobs ('date','submitter',
+ 'corepath', debug_id, server_id, iterations)
+ values (?,?,?,?,?,?)""", date, submitter, corepath, debug_id, server_id, 0)
+ return
15 years
cas.spec
by Adam Stokes
cas.spec | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
New commits:
commit 0922c151c2da7089542664e289109117deb6e7d5
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri Apr 3 12:32:12 2009 -0400
- spec updates to properly require sqlite if rhel/epel
- version bump
diff --git a/cas.spec b/cas.spec
index 55d1bdd..9422a8c 100644
--- a/cas.spec
+++ b/cas.spec
@@ -2,8 +2,8 @@
Name: cas
Summary: Tool to analyze and configure core file environment
-Version: 0.13
-Release: 121%{?dist}
+Version: 0.14
+Release: 1%{?dist}
Source0: https://fedorahosted.org/releases/c/a/cas/%{name}-%{version}.tar.gz
License: GPLv3+
Group: Development/Libraries
@@ -11,7 +11,11 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
BuildArch: noarch
Url: http://fedorahosted.org/cas
BuildRequires: python-devel
-Requires: crash MySQL-python
+%if 0%{?rhel}
+Requires: python-sqlite2 crash
+%else
+Requires: crash
+%endif
%description
CAS provides a user the ability to configure an environment for core analysis
@@ -50,8 +54,9 @@ rm -rf ${RPM_BUILD_ROOT}
%doc LICENSE README PKG-INFO doc/*
%changelog
-* Thu Apr 2 2009 Scott Dodson <sdodson at sdodson dot com >
+* Thu Apr 2 2009 Scott Dodson <sdodson at sdodson dot com > 0.14-1
- Spec file changes to handle the snippets directory
+- Snippets support to replace hardcoding crash input cmds
* Wed Feb 11 2009 Adam Stokes <ajs at redhat dot com> - 0.13-120
- added proper documentation
15 years, 1 month
cas.spec
by Adam Stokes
cas.spec | 11 +++++++++++
1 file changed, 11 insertions(+)
New commits:
commit 34d3b92a9724fe47c5c9551bf6588151d49a7e60
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Fri Apr 3 09:41:05 2009 -0400
- update spec to handle snippets addition (Scott Dodson)
diff --git a/cas.spec b/cas.spec
index 5b53a5a..55d1bdd 100644
--- a/cas.spec
+++ b/cas.spec
@@ -39,9 +39,20 @@ rm -rf ${RPM_BUILD_ROOT}
%{python_sitelib}/*
%{_mandir}/man1/cas.1.gz
%{_mandir}/man1/cas-admin.1.gz
+%dir /var/lib/cas/snippets/
+%defattr(755,root,root)
+%config(noreplace) /var/lib/cas/snippets/log
+%config(noreplace) /var/lib/cas/snippets/memory
+%config(noreplace) /var/lib/cas/snippets/sys
+%config(noreplace) /var/lib/cas/snippets/template
+%config(noreplace) /var/lib/cas/snippets/traceback
+%config(noreplace) /var/lib/cas/snippets/modules
%doc LICENSE README PKG-INFO doc/*
%changelog
+* Thu Apr 2 2009 Scott Dodson <sdodson at sdodson dot com >
+- Spec file changes to handle the snippets directory
+
* Wed Feb 11 2009 Adam Stokes <ajs at redhat dot com> - 0.13-120
- added proper documentation
15 years, 1 month
[PATCH] Update spec file for the snippets changes.
by Scott Dodson
---
cas.spec | 11 +++++++++++
1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/cas.spec b/cas.spec
index e463724..5beb22f 100644
--- a/cas.spec
+++ b/cas.spec
@@ -39,9 +39,20 @@ rm -rf ${RPM_BUILD_ROOT}
%{python_sitelib}/*
%{_mandir}/man1/cas.1.gz
%{_mandir}/man1/cas-admin.1.gz
+%dir /var/lib/cas/snippets/
+%defattr(755,root,root)
+%config(noreplace) /var/lib/cas/snippets/log
+%config(noreplace) /var/lib/cas/snippets/memory
+%config(noreplace) /var/lib/cas/snippets/sys
+%config(noreplace) /var/lib/cas/snippets/template
+%config(noreplace) /var/lib/cas/snippets/traceback
+%config(noreplace) /var/lib/cas/snippets/modules
%doc LICENSE README PKG-INFO doc/*
%changelog
+* Thu Apr 2 2009 Scott Dodson <sdodson at sdodson dot com >
+- Spec file changes to handle the snippets directory
+
* Wed Feb 11 2009 Adam Stokes <ajs at redhat dot com> - 0.13-120
- added proper documentation
--
1.6.0.6
15 years, 1 month
cas lib/cas MANIFEST.in setup.py snippets/log snippets/memory snippets/modules snippets/sys snippets/template snippets/traceback
by Adam Stokes
MANIFEST.in | 1 +
cas | 29 +++++++++++++++++++----------
lib/cas/util.py | 36 ++++++++++++++++--------------------
setup.py | 15 ++++++++++++++-
snippets/log | 2 ++
snippets/memory | 3 +++
snippets/modules | 2 ++
snippets/sys | 3 +++
snippets/template | 9 +++++++++
snippets/traceback | 3 +++
10 files changed, 72 insertions(+), 31 deletions(-)
New commits:
commit 884f0515991bf2df2ca020d45f2343eb0a00d9e5
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Thu Apr 2 20:13:03 2009 -0400
- snippet support, all crash commands are now in /var/lib/snippets (Scott Dodson)
- Fix func timeout in remote calls (Scott Dodson)
diff --git a/MANIFEST.in b/MANIFEST.in
index a035605..508d8fc 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,4 @@ include cas-admin.1.gz
include LICENSE
include README
recursive-include doc *
+recursive-include snippets *
diff --git a/cas b/cas
index 0dac60c..aaef477 100755
--- a/cas
+++ b/cas
@@ -199,7 +199,7 @@ class CasApplication(object):
CRASH_32)
self.casLog.info("Current machine suitable for processing 32 bit core, "\
"running crash.")
- cmd = os.path.join(self.storagePath,"crash")
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
# pull status code to verify crash even ran to completeness
@@ -213,7 +213,7 @@ class CasApplication(object):
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")
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
# DONE: capture any errors returned from crash when processing core.
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
@@ -228,6 +228,8 @@ class CasApplication(object):
# is configured we attempt to process the core at another machine.
try:
import func.overlord.client as fc
+ import func.jobthing as jobthing
+ from time import sleep
self.casLog.info("Crash file built, locating suitable %s system for " \
"processing" % (debugKernelArch,))
if os.path.isfile(SERVERS):
@@ -238,13 +240,20 @@ class CasApplication(object):
casProcessMachine = serverList[debugKernelArch][0]
self.casLog.info("Machine %s found, processing " \
"crash output" % (casProcessMachine,))
- cmd = os.path.join(self.storagePath,"crash")
- client = fc.Overlord(casProcessMachine)
- clientDict = client.command.run(cmd)
- # Only necessary for debugging why running of crash failed.
- sts, out, err = clientDict[clientDict.keys()[0]]
- if sts:
- self.casLog.debug(out.strip())
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
+ client = fc.Overlord(casProcessMachine,async=True)
+ job_id = client.command.run(cmd)
+ while True:
+ status = client.job_status(job_id)
+ (code, results) = status
+ if code == jobthing.JOB_ID_RUNNING:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_PARTIAL:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_FINISHED:
+ print "task complete, results = %s" % results
+ break
+ sleep(5)
else:
self.casLog.info("No servers available for arch and current system not "\
"suitable for processing, please run cas-admin -h " \
@@ -259,7 +268,7 @@ 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,))
- crashOutFile = os.path.join(self.storagePath,"crash.out")
+ crashOutFile = os.path.join(self.storagePath,"modules")
if os.path.isfile(crashOutFile) and self.extractKernelModules:
self.casLog.info("Extracting loaded kernels modules. This will " \
"take several minutes.")
diff --git a/lib/cas/util.py b/lib/cas/util.py
index cc4d834..b3cfe36 100755
--- a/lib/cas/util.py
+++ b/lib/cas/util.py
@@ -134,7 +134,8 @@ class UtilBase(object):
cmd = ["readelf", "-h", debug]
cmd2 = ["grep", "Machine"]
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
- pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE, stderr=PIPE).communicate()
+ pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE,
+ stderr=PIPE).communicate()
machine, sts = pipe2
for k, v in supportArch.iteritems():
if k in machine:
@@ -143,24 +144,19 @@ class UtilBase(object):
def buildCrashFile(self, dst, vmcore, debug, file_in="crash.in",
crash_bin="/usr/bin/crash"):
- """ build crash file with predefined debug
- commands
+ """ build crash and crash.in file with output from the snippets in
+ /var/lib/cas/snippets
"""
- # Optional commands can be placed here, for example,
- # kmem -f, sys -c
- # please note some commands like the ones above take a looong time to
- # run and can possibly timeout the xmlrpc server provided with func
- crashInputCmds = ['bt -a >>', 'sys >>',
- 'log >>', 'mod >>']
- crashOutputPath = os.path.join(dst, "crash.out")
- # test for output file existance
- if os.path.isfile(crashOutputPath):
- os.remove(crashOutputPath)
- # alter list to append the output path of the crash.out file
- # e.g. bt -a >> /cores/processed/123/crash.out\n
- crashInputCmds = [item+crashOutputPath+"\n" for item in crashInputCmds]
- # append the crash exit command since this doesn't give any additional
- # output and doesn't need alteration
+ # TODO: We should provide the environment variables mentioned in the
+ # template snippet, CAS_ARCH, CAS_KERNEL, CAS_SIZE, and whatever else
+ # makse sense so scripts can opt in based on the environmentals
+ dir_listing=[]
+ crashInputCmds=[]
+ for root, dirs, files in os.walk("/var/lib/cas/snippets/"):
+ for name in files:
+ dir_listing.append(os.path.join(root, name))
+ for a in dir_listing:
+ crashInputCmds.append(Popen(a, stdout=PIPE).communicate()[0])
crashInputCmds.append("exit\n")
# Build crash input file
@@ -170,8 +166,8 @@ class UtilBase(object):
crashInputFH.close()
vmcorePath = os.path.join(dst, vmcore)
- crashCmd = "#!/bin/sh\n%s %s %s -s < %s\n" % (crash_bin, vmcorePath,
- debug, crashInputPath)
+ crashCmd = "#!/bin/sh\n%s %s %s $*\n" % (crash_bin, vmcorePath,
+ debug )
crashExe = os.path.join(dst,"crash")
fh = open(crashExe,"w")
fh.write(crashCmd)
diff --git a/setup.py b/setup.py
index 06cffd6..c8ef395 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,11 @@
"""
from distutils.core import setup
+
+libpath = "/var/lib/cas"
+snippetpath = libpath + "/snippets"
+
+
setup(
name = 'cas',
version = '0.13',
@@ -13,6 +18,14 @@ setup(
packages = ['cas',],
scripts = ['cas','cas-admin'],
package_dir = {'': 'lib',},
+
data_files = [ ('/etc', ['cas.conf']),
- ('/usr/share/man/man1', ['cas.1.gz','cas-admin.1.gz']) ]
+ # cas commands we'll ship
+ (snippetpath, ['snippets/sys']),
+ (snippetpath, ['snippets/log']),
+ (snippetpath, ['snippets/memory']),
+ (snippetpath, ['snippets/traceback']),
+ (snippetpath, ['snippets/template']),
+ (snippetpath, ['snippets/modules']),
+ ('/usr/share/man/man1', ['cas.1.gz','cas-admin.1.gz']) ]
)
diff --git a/snippets/log b/snippets/log
new file mode 100644
index 0000000..fd13de5
--- /dev/null
+++ b/snippets/log
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "log >> log"
diff --git a/snippets/memory b/snippets/memory
new file mode 100644
index 0000000..86885b4
--- /dev/null
+++ b/snippets/memory
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "kmem >> memory"
+echo "kmem -f >> memory"
diff --git a/snippets/modules b/snippets/modules
new file mode 100644
index 0000000..cae6c79
--- /dev/null
+++ b/snippets/modules
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "mod >> modules"
diff --git a/snippets/sys b/snippets/sys
new file mode 100644
index 0000000..179d1e7
--- /dev/null
+++ b/snippets/sys
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "sys >> sys"
+echo "sys -c >> sys"
diff --git a/snippets/template b/snippets/template
new file mode 100644
index 0000000..855ccca
--- /dev/null
+++ b/snippets/template
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Environmentals set by CAS
+# CAS_ARCH = Architecture of the given core
+# CAS_KERNEL = uname -r
+#
+#
+# if ( CAS_ARCH eq 'x86_64' )
+# echo "sys -c >> template"
+# fi
diff --git a/snippets/traceback b/snippets/traceback
new file mode 100644
index 0000000..2af2f78
--- /dev/null
+++ b/snippets/traceback
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "bt >> traceback"
+echo "bt -a >> traceback"
15 years, 1 month
[PATCH] Convert the func command that calls crash to an async command
by Scott Dodson
---
cas | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/cas b/cas
index 456a4fb..f910035 100755
--- a/cas
+++ b/cas
@@ -229,6 +229,8 @@ class CasApplication(object):
# is configured we attempt to process the core at another machine.
try:
import func.overlord.client as fc
+ import func.jobthing as jobthing
+ from time import sleep
self.casLog.info("Crash file built, locating suitable %s system for " \
"processing" % (debugKernelArch,))
if os.path.isfile(SERVERS):
@@ -239,12 +241,19 @@ class CasApplication(object):
casProcessMachine = serverList[debugKernelArch][0]
self.casLog.info("Machine %s found, processing crash output" % (casProcessMachine,))
cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
- client = fc.Overlord(casProcessMachine)
- clientDict = client.command.run(cmd)
- # Only necessary for debugging why running of crash failed.
- sts, out, err = clientDict[clientDict.keys()[0]]
- if sts:
- self.casLog.debug(out.strip())
+ client = fc.Overlord(casProcessMachine,async=True)
+ jobif = client.command.run(cmd)
+ while True:
+ status = client.job_status(job_id)
+ (code, results) = status
+ if code == jobthing.JOB_ID_RUNNING:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_PARTIAL:
+ print "task is running..."
+ elif code == jobthing.JOB_ID_FINSHED:
+ print "task complete, results = %s" % results
+ break
+ sleep(5)
else:
self.casLog.info("No servers available for arch and current system not "\
"suitable for processing, please run cas-admin -h " \
--
1.6.0.6
15 years, 1 month
[PATCH] This moves all the crash commands out into /var/lib/cas/snippets.
by Scott Dodson
Place any executable files in /var/lib/cas/snippets. Those executables should
emit the commands to be run from within crash. In the future I'll add support
for a set of environmental variables that will allow the snippets to opt-in
based on the environmentals.
Asside from that there are changes to the basic cas tool to handle this
abstraction and to handle the use of multiple output files. For instance
the portion that finds loaded modules now looks in the outputfile modules
rather than crash.out since there's really not much in crash.out now.
We may want to hook back in some of the output files into the e-mail. I'm not
sure which files are useful or not.
---
MANIFEST.in | 1 +
cas | 8 ++++----
lib/cas/util.py | 36 ++++++++++++++++--------------------
setup.py | 15 ++++++++++++++-
snippets/log | 2 ++
snippets/memory | 3 +++
snippets/modules | 2 ++
snippets/sys | 3 +++
snippets/template | 9 +++++++++
snippets/traceback | 3 +++
10 files changed, 57 insertions(+), 25 deletions(-)
create mode 100755 snippets/log
create mode 100755 snippets/memory
create mode 100755 snippets/modules
create mode 100755 snippets/sys
create mode 100755 snippets/template
create mode 100755 snippets/traceback
diff --git a/MANIFEST.in b/MANIFEST.in
index a035605..508d8fc 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -4,3 +4,4 @@ include cas-admin.1.gz
include LICENSE
include README
recursive-include doc *
+recursive-include snippets *
diff --git a/cas b/cas
index 319ca7b..456a4fb 100755
--- a/cas
+++ b/cas
@@ -200,7 +200,7 @@ class CasApplication(object):
CRASH_32)
self.casLog.info("Current machine suitable for processing 32 bit core, "\
"running crash.")
- cmd = os.path.join(self.storagePath,"crash")
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
# pull status code to verify crash even ran to completeness
@@ -214,7 +214,7 @@ class CasApplication(object):
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")
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
# DONE: capture any errors returned from crash when processing core.
cmdPipe = Popen([cmd], stdout=PIPE, stderr=PIPE)
cmdData = cmdPipe.communicate()
@@ -238,7 +238,7 @@ class CasApplication(object):
# TODO: Verify remote server is reachable
casProcessMachine = serverList[debugKernelArch][0]
self.casLog.info("Machine %s found, processing crash output" % (casProcessMachine,))
- cmd = os.path.join(self.storagePath,"crash")
+ cmd = "cd " + os.path.join(self.storagePath) + " && ./crash -i crash.in > crash.out"
client = fc.Overlord(casProcessMachine)
clientDict = client.command.run(cmd)
# Only necessary for debugging why running of crash failed.
@@ -259,7 +259,7 @@ 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,))
- crashOutFile = os.path.join(self.storagePath,"crash.out")
+ crashOutFile = os.path.join(self.storagePath,"modules")
if os.path.isfile(crashOutFile) and self.extractKernelModules:
self.casLog.info("Extracting loaded kernels modules. This will " \
"take several minutes.")
diff --git a/lib/cas/util.py b/lib/cas/util.py
index cc4d834..b3cfe36 100755
--- a/lib/cas/util.py
+++ b/lib/cas/util.py
@@ -134,7 +134,8 @@ class UtilBase(object):
cmd = ["readelf", "-h", debug]
cmd2 = ["grep", "Machine"]
pipe = Popen(cmd, stdout=PIPE, stderr=PIPE)
- pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE, stderr=PIPE).communicate()
+ pipe2 = Popen(cmd2, stdin=pipe.stdout, stdout=PIPE,
+ stderr=PIPE).communicate()
machine, sts = pipe2
for k, v in supportArch.iteritems():
if k in machine:
@@ -143,24 +144,19 @@ class UtilBase(object):
def buildCrashFile(self, dst, vmcore, debug, file_in="crash.in",
crash_bin="/usr/bin/crash"):
- """ build crash file with predefined debug
- commands
+ """ build crash and crash.in file with output from the snippets in
+ /var/lib/cas/snippets
"""
- # Optional commands can be placed here, for example,
- # kmem -f, sys -c
- # please note some commands like the ones above take a looong time to
- # run and can possibly timeout the xmlrpc server provided with func
- crashInputCmds = ['bt -a >>', 'sys >>',
- 'log >>', 'mod >>']
- crashOutputPath = os.path.join(dst, "crash.out")
- # test for output file existance
- if os.path.isfile(crashOutputPath):
- os.remove(crashOutputPath)
- # alter list to append the output path of the crash.out file
- # e.g. bt -a >> /cores/processed/123/crash.out\n
- crashInputCmds = [item+crashOutputPath+"\n" for item in crashInputCmds]
- # append the crash exit command since this doesn't give any additional
- # output and doesn't need alteration
+ # TODO: We should provide the environment variables mentioned in the
+ # template snippet, CAS_ARCH, CAS_KERNEL, CAS_SIZE, and whatever else
+ # makse sense so scripts can opt in based on the environmentals
+ dir_listing=[]
+ crashInputCmds=[]
+ for root, dirs, files in os.walk("/var/lib/cas/snippets/"):
+ for name in files:
+ dir_listing.append(os.path.join(root, name))
+ for a in dir_listing:
+ crashInputCmds.append(Popen(a, stdout=PIPE).communicate()[0])
crashInputCmds.append("exit\n")
# Build crash input file
@@ -170,8 +166,8 @@ class UtilBase(object):
crashInputFH.close()
vmcorePath = os.path.join(dst, vmcore)
- crashCmd = "#!/bin/sh\n%s %s %s -s < %s\n" % (crash_bin, vmcorePath,
- debug, crashInputPath)
+ crashCmd = "#!/bin/sh\n%s %s %s $*\n" % (crash_bin, vmcorePath,
+ debug )
crashExe = os.path.join(dst,"crash")
fh = open(crashExe,"w")
fh.write(crashCmd)
diff --git a/setup.py b/setup.py
index 06cffd6..c8ef395 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,11 @@
"""
from distutils.core import setup
+
+libpath = "/var/lib/cas"
+snippetpath = libpath + "/snippets"
+
+
setup(
name = 'cas',
version = '0.13',
@@ -13,6 +18,14 @@ setup(
packages = ['cas',],
scripts = ['cas','cas-admin'],
package_dir = {'': 'lib',},
+
data_files = [ ('/etc', ['cas.conf']),
- ('/usr/share/man/man1', ['cas.1.gz','cas-admin.1.gz']) ]
+ # cas commands we'll ship
+ (snippetpath, ['snippets/sys']),
+ (snippetpath, ['snippets/log']),
+ (snippetpath, ['snippets/memory']),
+ (snippetpath, ['snippets/traceback']),
+ (snippetpath, ['snippets/template']),
+ (snippetpath, ['snippets/modules']),
+ ('/usr/share/man/man1', ['cas.1.gz','cas-admin.1.gz']) ]
)
diff --git a/snippets/log b/snippets/log
new file mode 100755
index 0000000..fd13de5
--- /dev/null
+++ b/snippets/log
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "log >> log"
diff --git a/snippets/memory b/snippets/memory
new file mode 100755
index 0000000..86885b4
--- /dev/null
+++ b/snippets/memory
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "kmem >> memory"
+echo "kmem -f >> memory"
diff --git a/snippets/modules b/snippets/modules
new file mode 100755
index 0000000..cae6c79
--- /dev/null
+++ b/snippets/modules
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "mod >> modules"
diff --git a/snippets/sys b/snippets/sys
new file mode 100755
index 0000000..179d1e7
--- /dev/null
+++ b/snippets/sys
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "sys >> sys"
+echo "sys -c >> sys"
diff --git a/snippets/template b/snippets/template
new file mode 100755
index 0000000..855ccca
--- /dev/null
+++ b/snippets/template
@@ -0,0 +1,9 @@
+#!/bin/sh
+# Environmentals set by CAS
+# CAS_ARCH = Architecture of the given core
+# CAS_KERNEL = uname -r
+#
+#
+# if ( CAS_ARCH eq 'x86_64' )
+# echo "sys -c >> template"
+# fi
diff --git a/snippets/traceback b/snippets/traceback
new file mode 100755
index 0000000..2af2f78
--- /dev/null
+++ b/snippets/traceback
@@ -0,0 +1,3 @@
+#!/bin/sh
+echo "bt >> traceback"
+echo "bt -a >> traceback"
--
1.6.0.6
15 years, 1 month
cas-admin lib/cas
by Adam Stokes
cas-admin | 13 +++++--------
lib/cas/db.py | 16 +++++++++++-----
2 files changed, 16 insertions(+), 13 deletions(-)
New commits:
commit 00a3ad6797f889498c798f3e812e41c5dde016dd
Author: Adam Stokes <adam.stokes(a)gmail.com>
Date: Wed Apr 1 14:04:03 2009 -0400
- more db methods
diff --git a/cas-admin b/cas-admin
index e25b778..1c53ea7 100755
--- a/cas-admin
+++ b/cas-admin
@@ -65,15 +65,12 @@ class CasDatabaseHandler(object):
# query database for debuginfo rpms
rpms = self.db.getDebuginfoRPM()
for id, rpm in rpms:
- if not self.rpmExist(x):
- self.rpmDB[x] = []
- count = count + 1
+ if not self.rpmExist(rpm):
# temporary storage path in form of DEBUGS/COUNT
dst = os.path.join(DEBUGS, str(count))
rpmTool = RPMBase()
- self.casLog.status("(extracting) [%d/%d] %-50s" % (count, totalRpms,
- os.path.basename(x)))
- results = rpmTool.extract(x, dst)
+ self.casLog.status("(extracting) %-50s" % (rpm))
+ results = rpmTool.extract(rpm, dst)
# Sort through extracted debug for each type
# e.g. hugemem, PAE, smp, largesmp
for item in results:
@@ -81,8 +78,8 @@ class CasDatabaseHandler(object):
stamper = CoreBase()
debugKernel = os.path.normpath(vmlinux)
timestamp = stamper.timestamp(debugKernel)
- # Build tuple of each debug type
- self.rpmDB[x].append((debugKernel, timestamp))
+ # add rpm id, debug, timestamp to database
+ self.db.addTimestamp(id, debugKernel, timestamp)
self.util.save(self.rpmDB, RPMS)
# Cleanup extracted debugs
rmtree(dst)
diff --git a/lib/cas/db.py b/lib/cas/db.py
index fb0b322..e9b13e7 100644
--- a/lib/cas/db.py
+++ b/lib/cas/db.py
@@ -19,13 +19,13 @@ class CasStorage(object):
def buildTable(self):
self.cursor.execute('''create table cas_jobs
-(date text, submitter text, corepath text, debugpath text,
-server text)
+ (date text, submitter text, corepath text, debugpath text,
+ server text)
-create table debuginfo (debug_id integer primary key autoincrement, rpm text)
+ create table debuginfo (debug_id integer primary key autoincrement, rpm text)
-create table timestamp (timestamp_id integer primary key autoincrement,
-debuginfo integer, debugpath text, timestamp text, debug_id integer)''')
+ create table timestamp (timestamp_id integer primary key autoincrement,
+ debugpath text, timestamp text, debug_id integer)''')
self.conn.commit()
return
@@ -38,6 +38,12 @@ debuginfo integer, debugpath text, timestamp text, debug_id integer)''')
self.cursor.execute("SELECT * FROM debuginfo")
return self.cursor
+ # TIMESTAMP METHODS
+ def addTimestamp(self, id, debug, timestamp):
+ """ build relation to debuginfo rpm and add debug path, timestamp """
+ self.cursor.execute("""INSERT into timestamp('debug_id','debugpath',
+ 'timestamp') values(?,?,?)""", id, debug, timestamp)
+
def connect(self):
""" execute connection """
try:
15 years, 1 month