Skip to content

Commit

Permalink
Merge pull request dstat-real#3 from fikovnik/master
Browse files Browse the repository at this point in the history
Fixed error message in case Condor is not running at the host where dstat is being executed
  • Loading branch information
dagwieers committed Jul 20, 2011
2 parents 9e44523 + 8641ffb commit 480eb40
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions plugins/dstat_condor_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,33 @@ def check(self):

if not os.access(self.condor_status_cmd, os.X_OK):
raise Exception, 'Needs %s in the path' % self.condor_status_cmd
cmd_test(self.condor_status_cmd)
return True
else:
try:
p = os.popen(self.condor_status_cmd+' 2>&1 /dev/null')
ret = p.close()
if ret:
raise Exception, 'Cannot interface with Condor - condor_q returned != 0?'
except IOError:
raise Exception, 'Unable to execute %s' % self.condor_status_cmd
return True

def extract(self):
last_line = None
for last_line in cmd_readlines(self.condor_status_cmd):
pass

m = CONDOR_Q_STAT_PATTER.match(last_line)
if m == None:
raise Exception, 'Invalid output from %s. Got: %s' % (cmd, last_line)

stats = [int(s.strip()) for s in m.groups()]
for i,j in enumerate(self.vars):
self.val[j] = stats[i]
try:
for repeats in range(3):
for last_line in cmd_readlines(self.condor_status_cmd):
pass

m = CONDOR_Q_STAT_PATTER.match(last_line)
if m == None:
raise Exception, 'Invalid output from %s. Got: %s' % (cmd, last_line)

stats = [int(s.strip()) for s in m.groups()]
for i,j in enumerate(self.vars):
self.val[j] = stats[i]
except Exception:
for name in self.vars:
self.val[name] = -1

# vim:ts=4:sw=4:et

0 comments on commit 480eb40

Please sign in to comment.