diff options
author | Clark Williams <williams@redhat.com> | 2010-07-08 15:27:53 -0500 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-07-08 15:27:53 -0500 |
commit | ee614b857c241ca3a2ac6ede1f9dc3c9821ea25a (patch) | |
tree | 101f891786c659db179e03118eb1de035236d8b2 | |
parent | 08dab7d82036c69052322ca8ea40223169a4c908 (diff) | |
download | rteval-ee614b857c241ca3a2ac6ede1f9dc3c9821ea25a.tar.gz rteval-ee614b857c241ca3a2ac6ede1f9dc3c9821ea25a.tar.xz rteval-ee614b857c241ca3a2ac6ede1f9dc3c9821ea25a.zip |
add logging for loads
Added an option (-L/--logging) to rteval that will turn on
logging of load output to a file in the report directory.
Signed-off-by: Clark Williams <williams@redhat.com>
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | rteval/hackbench.py | 11 | ||||
-rw-r--r-- | rteval/kcompile.py | 18 | ||||
-rw-r--r-- | rteval/load.py | 5 | ||||
-rw-r--r-- | rteval/rteval.py | 15 |
5 files changed, 40 insertions, 11 deletions
@@ -39,7 +39,7 @@ LOADS := $(KLOAD) $(BLOAD) runit: [ -d ./run ] || mkdir run - python rteval/rteval.py -D -v --workdir=./run --loaddir=./loadsource --duration=$(D) -f ./rteval/rteval.conf -i ./rteval + python rteval/rteval.py -D -L -v --workdir=./run --loaddir=./loadsource --duration=$(D) -f ./rteval/rteval.conf -i ./rteval sysreport: python rteval/rteval.py -D -v --workdir=./run --loaddir=./loadsource --duration=$(D) -i ./rteval --sysreport diff --git a/rteval/hackbench.py b/rteval/hackbench.py index dd60abb..968e027 100644 --- a/rteval/hackbench.py +++ b/rteval/hackbench.py @@ -59,10 +59,15 @@ class Hackbench(load.Load): def runload(self): self.args = ['hackbench', '-g', str(self.jobs)] null = os.open("/dev/null", os.O_RDWR) + if self.logging: + out = self.open_logfile("hackbench.stdout") + err = self.open_logfile("hackbench.stderr") + else: + out = err = null self.debug("starting loop (jobs: %d)" % self.jobs) while not self.stopevent.isSet(): - p = subprocess.Popen(self.args, stdin=null, stdout=null) + p = subprocess.Popen(self.args, stdin=out, stdout=err) time.sleep(1.0) if p.poll() != None: p.wait() @@ -73,7 +78,9 @@ class Hackbench(load.Load): p.wait() self.debug("returning from runload()") os.close(null) - + if self.logging: + os.close(out) + os.close(err) def genxml(self, x): x.taggedvalue('command_line', ' '.join(self.args), {'name':'hackbench'}) diff --git a/rteval/kcompile.py b/rteval/kcompile.py index b363c57..ad7c038 100644 --- a/rteval/kcompile.py +++ b/rteval/kcompile.py @@ -86,10 +86,12 @@ class Kcompile(load.Load): def build(self): self.debug("setting up all module config file in %s" % self.mydir) null = os.open("/dev/null", os.O_RDWR) + out = self.open_logfile("kcompile-build.stdout") + err = self.open_logfile("kcompile-build.stderr") # clean up from potential previous run try: ret = subprocess.call(["make", "-C", self.mydir, "distclean", "allmodconfig"], - stdin=null, stdout=null, stderr=null) + stdin=null, stdout=out, stderr=err) if ret: raise RuntimeError, "kcompile setup failed: %d" % ret except KeyboardInterrupt, m: @@ -98,9 +100,16 @@ class Kcompile(load.Load): self.debug("ready to run") self.ready = True os.close(null) + os.close(out) + os.close(err) def runload(self): null = os.open("/dev/null", os.O_RDWR) + if self.logging: + out = self.open_logfile("kcompile.stdout") + err = self.open_logfile("kcompile.stderr") + else: + out = err = null mult=1 if self.params.has_key('jobspercore'): mult = int(self.params.jobspercore) @@ -110,19 +119,22 @@ class Kcompile(load.Load): "-j%d" % njobs, "clean", "bzImage", "modules"] p = subprocess.Popen(self.args, - stdin=null,stdout=null,stderr=null) + stdin=null,stdout=out,stderr=err) while not self.stopevent.isSet(): time.sleep(1.0) if p.poll() != None: p.wait() self.debug("restarting compile job") p = subprocess.Popen(self.args, - stdin=null,stdout=null,stderr=null) + stdin=null,stdout=out,stderr=err) self.debug("stopping") if p.poll() == None: os.kill(p.pid, SIGTERM) p.wait() os.close(null) + if self.logging: + os.close(out) + os.close(err) def genxml(self, x): x.taggedvalue('command_line', ' '.join(self.args), {'name':'kcompile'}) diff --git a/rteval/load.py b/rteval/load.py index 48b9335..41901c2 100644 --- a/rteval/load.py +++ b/rteval/load.py @@ -38,6 +38,8 @@ class Load(threading.Thread): self.num_cpus = params.setdefault('numcores', 1) self.debugging = params.setdefault('debugging', False) self.source = params.setdefault('source', None) + self.reportdir = params.setdefault('reportdir', os.getcwd()) + self.logging = params.setdefault('logging', False) self.params = params self.ready = False self.mydir = None @@ -88,3 +90,6 @@ class Load(threading.Thread): def genxml(self, x): pass + + def open_logfile(self, name): + return os.open(os.path.join(self.reportdir, "logs", name), os.O_CREAT|os.O_WRONLY) diff --git a/rteval/rteval.py b/rteval/rteval.py index 229ce44..41ca650 100644 --- a/rteval/rteval.py +++ b/rteval/rteval.py @@ -91,6 +91,7 @@ class RtEval(object): 'xmlrpc' : None, 'xslt_report': '/usr/share/rteval/rteval_text.xsl', 'report_interval': '600', + 'logging' : False, }, 'loads' : { 'kcompile' : 'module', @@ -378,6 +379,9 @@ class RtEval(object): parser.add_option("-a", "--annotate", dest="annotate", type="string", default=None, help="Add a little annotation which is stored in the report") + parser.add_option("-L", "--logging", dest="logging", + action='store_true', default=False, + help='log the output of the loads in the report directory') (self.cmd_options, self.cmd_arguments) = parser.parse_args(args = cmdargs) if self.cmd_options.duration: @@ -628,6 +632,7 @@ class RtEval(object): t.strftime('rteval-%Y%m%d-'+str(i))) if not os.path.isdir(self.reportdir): os.mkdir(self.reportdir) + os.mkdir(os.path.join(self.reportdir, "logs")) return self.reportdir def get_dmesg(self): @@ -683,6 +688,7 @@ class RtEval(object): 'verbose': self.config.verbose, 'debugging': self.config.debugging, 'numcores':self.numcores, + 'logging':self.config.logging, } for m in self.load_modules: @@ -759,9 +765,7 @@ class RtEval(object): print "stopping run at %s" % time.asctime() # wait for cyclictest to finish calculating stats self.cyclictest.finished.wait() - end = datetime.now() - duration = end - start - self.genxml(duration, accum, samples) + self.genxml(datetime.now() - start, accum, samples) self.report() if self.config.sysreport: self.run_sysreport() @@ -887,11 +891,12 @@ class RtEval(object): reportdir: %s verbose: %s debugging: %s + logging: %s duration: %f sysreport: %s inifile: %s''' % (self.workdir, self.config.srcdir, self.reportdir, self.config.verbose, - self.config.debugging, self.config.duration, self.config.sysreport, - self.inifile)) + self.config.debugging, self.config.logging, self.config.duration, + self.config.sysreport, self.inifile)) if not os.path.isdir(self.workdir): raise RuntimeError, "work directory %d does not exist" % self.workdir |