/[pdpsoft]/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/tdsp.py
ViewVC logotype

Contents of /nl.nikhef.pdp.dynsched-pbs-plugin/trunk/tdsp.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2527 - (show annotations) (download) (as text)
Wed Apr 25 13:39:40 2012 UTC (10 years, 3 months ago) by templon
File MIME type: application/x-python
File size: 2878 byte(s)
add comment to tdsp; remove the torqueJobs stuff, moved to the pjobstats tree.

1 #!/usr/bin/python2
2 # lrmsinfo-pbs
3 # J. A. Templon, NIKHEF/PDP 2005
4 # $Id: lrmsinfo-pbs.cin 2267 2011-04-05 13:52:24Z templon $
5 # $URL: svn+ssh://svn@ndpfsvn.nikhef.nl/repos/pdpsoft/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/lrmsinfo-pbs.cin $
6
7 # get information from pbs/torque LRMS, spit it out in uniform format
8 # this version uses the torqueJobs package to parse the qstat output.
9 # available from SVN tree at
10 # svn+ssh://svn@ndpfsvn.nikhef.nl/repos/pdpsoft/trunk/nl.nikhef.ndpf.tools/pjobstats
11
12 def usage():
13 print "Usage: lrmsinfo-pbs [-i <input_file>]"
14 print " input_file : optional text file containing 'qstat -f' output"
15
16 import sys, getopt, string
17
18 try:
19 opts, args = getopt.getopt(sys.argv[1:], "i:",
20 ["input="])
21 except getopt.GetoptError:
22 # print help information and exit:
23 print sys.argv[0] + ": error parsing command line: " + \
24 string.join(sys.argv)
25 usage()
26 sys.exit(2)
27
28 for o, a in opts:
29 if o in ("-i", "--input"):
30 infile = a
31
32 if infile:
33 cmd = '/bin/cat ' + infile
34 else:
35 cmd = 'diagnose -g'
36
37 from pbsServer import LiveServer
38 if infile:
39 bq = LiveServer(file='efile')
40 else:
41 bq = LiveServer()
42
43 tf = sys.stdout
44 tf.write("nactive %d\n" % (bq.slotsUp))
45 tf.write("nfree %d\n" % (bq.slotsFree))
46 tf.write("now %d\n" % (bq.now))
47 tf.write("schedCycle %d\n" % (bq.schedCycle))
48
49
50 import torqueJobs
51 jlist = torqueJobs.qs_parsefile(infile)
52
53 {'startAnchor': 'start_time'}
54
55 import torqueAttMappers as tam
56 usedkeys = ['egroup', 'Job_Name', 'qtime', 'jobid', 'queue', 'start_time', 'job_state', 'exec_host', 'euser',
57 'Resource_List.walltime', 'resources_used.walltime']
58
59 def mapatts(indict):
60 sdict = tam.sub_dict(indict,usedkeys)
61 changedkeys=tam.amap_dynsched.keys()
62 odict = dict()
63 for k in sdict.keys():
64 if k in tam.tfl and sdict[k]:
65 secs = tam.hms(sdict[k])
66 sdict[k] = secs
67 elif k in tam.tfl2 and sdict[k]:
68 secs = tam.tconv(sdict[k])
69 sdict[k] = secs
70 elif k == 'exec_host' and sdict[k]:
71 val = sdict[k].count('+') + 1
72 sdict[k] = val
73 elif k == 'job_state':
74 statelett = sdict[k]
75 if statelett in ['Q','W']:
76 val = 'queued'
77 elif statelett in ['R','E']:
78 val = 'running'
79 elif statelett in ['H', 'T']:
80 val = 'pending'
81 elif statelett == 'C':
82 val = 'done'
83 else:
84 val = 'unknown'
85 sdict[k] = val
86
87 if k in changedkeys:
88 odict[tam.amap_dynsched[k]] = sdict[k]
89 else:
90 odict[k] = sdict[k]
91 return odict
92
93 for job in jlist:
94 tf.write(repr(mapatts(job)) + "\n")
95
96 tf.close()
97
98 ### Local Variables: ***
99 ### mode: python ***
100 ### End: ***

Properties

Name Value
svn:executable *

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28