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

Contents of /nl.nikhef.pdp.dynsched-pbs-plugin/branches/RB-2.2.0/vomaxjobs-maui.cin

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2136 - (show annotations) (download)
Fri Jan 14 13:40:24 2011 UTC (11 years ago) by templon
File size: 2405 byte(s)
add -k option to specify maui keyfile

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

Properties

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

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