/[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 2138 - (show annotations) (download)
Fri Jan 14 13:51:02 2011 UTC (11 years ago) by templon
File size: 2493 byte(s)
updating svn tags

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

Properties

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

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