/[pdpsoft]/nl.nikhef.pdp.dynsched-pbs-plugin/trunk/vomaxjobs-maui.cin
ViewVC logotype

Contents of /nl.nikhef.pdp.dynsched-pbs-plugin/trunk/vomaxjobs-maui.cin

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2146 - (show annotations) (download)
Fri Jan 14 16:11:45 2011 UTC (11 years, 8 months ago) by templon
File size: 2413 byte(s)
Merge release 2.2.0 changes with trunk
1 #!/usr/bin/python2
2 # vomaxjobs-maui
3 # J. A. Templon, NIKHEF/PDP 2005
4 # $URL$
5 # $Id$
6
7 # generate generic information on maximum job
8 # counts per VO. This version works with Maui.
9
10 import sys
11
12 def usage():
13 print "Usage: vomaxjobs-maui [-h <schedulerhost>]"
14
15 import getopt
16 import string
17
18 try:
19 opts, args = getopt.getopt(sys.argv[1:], "h:i:k:",
20 ["host=","input=","keyfile="])
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 schedhost = None
29 infile = None
30 keyarg = None
31
32 for o, a in opts:
33 if o in ("-h", "--host"):
34 schedhost = a
35 elif o in ("-i", "--input"):
36 infile = a
37 elif o in ("-k", "--keyfile"):
38 keyarg = a
39
40 if infile:
41 cmd = '/bin/cat ' + infile
42 else:
43 cmd = 'diagnose -g'
44 if schedhost:
45 cmd = cmd + ' --host=' + schedhost
46 if keyarg:
47 cmd = cmd + ' --keyfile=' + keyarg
48
49 import commands
50 (stat, out) = commands.getstatusoutput(cmd)
51 if stat:
52 print sys.argv[0] + ': command \'' + cmd + '\'' + \
53 ' exited with nonzero status'
54 sys.exit(1)
55
56 lines = out.split('\n')
57
58 # gather information on groups (==vos)
59
60 ### strategy: look for first line with 1st field == "Name"
61 ### and 2nd field == "Priority"; get field headings from here,
62 ### then skip one line and start picking up groups. Keep going
63 ### til end of "lines".
64
65 linenr = 0
66 for line in lines:
67 fields = line.split()
68 if len(fields) > 2 and fields[0] == "Name" and fields[1] == "Priority": break
69 linenr += 1
70
71 fieldnames = lines[linenr].split()
72 gpos = fieldnames.index('Name') # output column for group name
73 lpos = fieldnames.index('Limits') # output column for group process cap
74
75 # collect process caps for each group
76
77 pcaps = {}
78 for line in lines[linenr+2:]:
79 f = line.split()
80 if len(f) == lpos + 1:
81 t = f[lpos] # expect either [NONE] or MAXPROC=N or MAXPROC=N,M
82 if t.find('MAXPROC') == 0:
83 f2 = t.split('=')
84 if f2[1].find(',') >= 0: # then N,M format
85 max_asstring = f2[1].split(',')[1] # choose hard limit
86 else:
87 max_asstring = f2[1] # MAXPROC=N format
88
89 pcaps[f[gpos]] = int( max_asstring )
90
91 print pcaps
92
93 ### Local Variables: ***
94 ### mode: python ***
95 ### End: ***

Properties

Name Value
svn:eol-style native
svn:keywords Id URL

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