Repository navigation
Expand file tree
/
Copy pathqueue.py
More file actions
executable file
·67 lines (53 loc) · 1.84 KB
/
Copy pathqueue.py
File metadata and controls
executable file
·67 lines (53 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python
# show interesting things about a queue
import scheduler
import sys
import xml.etree.ElementTree as et
def getRunningJobs( s ):
# return running jobs as array of hashes
pass
def getRunningSummary( s ):
# return summary statistics on running jobs
summary = {}
command = [ "showq", "--xml", '-r' ]
queue = et.fromstring( s.doCommand( command ) )
job_total = queue.find( 'queue' ).attrib[ 'count' ]
processors = queue.find( "cluster" ).attrib[ 'LocalAllocProcs' ]
nodes = queue.find( "cluster" ).attrib[ 'LocalActiveNodes' ]
for j in queue.findall( 'queue/job' ):
a = j.attrib[ 'Account' ]
p = int( j.attrib[ 'ReqProcs' ] )
wc = (
float( j.attrib[ 'ReqAWDuration' ] ) -
float( j.attrib[ 'StatPSDed' ] ) )
if wc < 0:
wc = -wc
ps = p * wc
print "account {}, procs {}, time {}, ps {}".format( a, p, wc, ps )
try:
summary[ a ][ 'procs' ] = summary[ a ][ 'procs' ] + p
summary[ a ][ 'wc' ] = summary[ a ][ 'wc' ] + wc
summary[ a ][ 'ps' ] = summary[ a ][ 'ps' ] + ps
except KeyError:
summary[ a ] = {}
summary[ a ][ 'procs' ] = p
summary[ a ][ 'wc' ] = wc
summary[ a ][ 'ps' ] = ps
return summary
def getIdleJobSummary( s ):
command = [ "showq", "--xml", '-i' ]
queue = et.fromstring( s.doCommand( command ) )
retval = []
for j in queue.findall( 'queue/job' ):
retval.append( j.attrib[ 'JobID' ] )
return retval
def main():
s = scheduler.Scheduler()
print s.state
summary = getRunningSummary( s )
for acct in summary.keys():
print acct, summary[ acct ][ 'procs' ]
getIdleJobSummary( s )
if __name__ == '__main__':
status = main()
sys.exit(status)