From 006d8752c9084516df3aee0b3db3c62ed3621185 Mon Sep 17 00:00:00 2001 From: Guillaume Raffy Date: Tue, 29 May 2012 16:31:01 +0000 Subject: [PATCH] =?UTF-8?q?la=20page=20cluster=20status=20affiche=20d?= =?UTF-8?q?=C3=A9sormais=20les=20=C3=A9tats=20disabled=20et=20error=20des?= =?UTF-8?q?=20queues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ClusterController/QstatParser.py | 20 ++++++++++++++++++-- ClusterController/QueueMachine.py | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) 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