diff --git a/ClusterController/QstatParser.py b/ClusterController/QstatParser.py index 7b29212..b95c623 100644 --- a/ClusterController/QstatParser.py +++ b/ClusterController/QstatParser.py @@ -28,6 +28,21 @@ class QstatParser: else: assert False, 'unhandled job state flag :"' + c + '"' return jobState + def parseQueueMachineState( self, strQueueMachineStatus ): + queueMachineState = 0 + for i in range(0, len(strQueueMachineStatus) ): + c = strQueueMachineStatus[i] + if c == 'd': + queueMachineState += QueueMachineStateFlags.DISABLED + elif c == 'a': + queueMachineState += QueueMachineStateFlags.ALARM + elif c == 'u': + queueMachineState += QueueMachineStateFlags.UNKNOWN + elif c == 'E': + queueMachineState += QueueMachineStateFlags.ERROR + else: + assert False, 'unhandled queue machine state flag :"' + c + '"' + return queueMachineState def parseQstatOutput( self, qstatOutput ): jobsState = JobsState() f = StringIO.StringIO(qstatOutput) @@ -45,7 +60,7 @@ class QstatParser: jobRegularExp = re.compile( '^[ ]*(?P[^ ]+)[ ]+[0-9.]+[ ]+(?P[^ ]+)[ ]+(?P[^ ]+)[ ]+(?P[^ ]+)[ ]+(?P[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9])[ ]+(?P[0-9]+)[ ]+(?P[^\n]*)[\s]*$' ) # example of machine line : # allintel.q@simpatix34.univ-ren BIP 0/6/8 6.00 darwin-x86 - machineRegularExp = re.compile( '^(?P[^@]+)@(?P[^.]+)[^ ]+[ ]+(?P[^ ]+)[ ]+(?P[^/]+)/(?P[^/]+)/(?P[^ ]+)[ ]+(?P[^ ]+)[?]*' ) + machineRegularExp = re.compile( '^(?P[^@]+)@(?P[^.]+)[^ ]+[ ]+(?P[^ ]+)[ ]+(?P[^/]+)/(?P[^/]+)/(?P[^ ]+)[ ]+(?P[^ ]+)[\s]+(?P[^ ]+)[\s]+(?P[^\s]*)' ) pendingJobsHeaderRegularExp = re.compile( '^ - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS - PENDING JOBS[?]*' ) while( len(line) > 0 ): # print line @@ -137,7 +152,8 @@ class QstatParser: if strCpuLoad != '-NA-': queueMachine.setCpuLoad( float(strCpuLoad) ) - + strQueueMachineState = matchObj.group('queueMachineStatus') + queueMachine.setState( self.parseQueueMachineState( strQueueMachineState ) ) #log('QstatParser::parseQstatOutput : queueName = "'+matchObj.group('queueName')+'"') #log('QstatParser::parseQstatOutput : machineName = "'+matchObj.group('machineName')+'"') currentQueueMachine = queueMachine diff --git a/ClusterController/QueueMachine.py b/ClusterController/QueueMachine.py index 72ac86e..d281131 100644 --- a/ClusterController/QueueMachine.py +++ b/ClusterController/QueueMachine.py @@ -1,4 +1,10 @@ +class QueueMachineStateFlags: # + DISABLED=1 # the queue machine is disabled + ALARM=2 # the queue machine is in alarm state (see man qstat) + UNKNOWN=4 # the queue machine is in unknown state because sge_execd cannot be contected (see man qstat) + ERROR=8 # the queue is in error state + class QueueMachine: """ a QueueMachine instance represents a given SGE queue on a given machine (eg allintel.q@simpatix10) @@ -36,4 +42,14 @@ class QueueMachine: def getCpuLoad( self ): assert( self.m_fCpuLoad != None ) return self.m_fCpuLoad - + def setState( self, state ): + self.m_stateFlags = state + def isDisabled( self ): + return self.m_stateFlags & QueueMachineStateFlags.DISABLED + def isInErrorState( self ): + return self.m_stateFlags & QueueMachineStateFlags.ERROR + """ + def getStateAsString( self ): + assert( self.m_strState != None ) + return self.m_strState + """ \ No newline at end of file