/[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 2012 - (show annotations) (download)
Fri Oct 8 13:11:04 2010 UTC (11 years, 11 months ago) by templon
File size: 2273 byte(s)
first checkin, copied from old tree

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:",
19 ["host=","input="])
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
30 for o, a in opts:
31 if o in ("-h", "--host"):
32 schedhost = a
33 elif o in ("-i", "--input"):
34 infile = a
35
36 if infile:
37 cmd = '/bin/cat ' + infile
38 else:
39 cmd = 'diagnose -g'
40 if schedhost:
41 cmd = cmd + ' --host=' + schedhost
42
43 import commands
44 (stat, out) = commands.getstatusoutput(cmd)
45 if stat:
46 print sys.argv[0] + ': command \'' + cmd + '\'' + \
47 ' exited with nonzero status'
48 sys.exit(1)
49
50 lines = out.split('\n')
51
52 # gather information on groups (==vos)
53
54 ### strategy: look for first line with 1st field == "Name"
55 ### and 2nd field == "Priority"; get field headings from here,
56 ### then skip one line and start picking up groups. Keep going
57 ### til end of "lines".
58
59 linenr = 0
60 for line in lines:
61 fields = line.split()
62 if len(fields) > 2 and fields[0] == "Name" and fields[1] == "Priority": break
63 linenr += 1
64
65 fieldnames = lines[linenr].split()
66 gpos = fieldnames.index('Name') # output column for group name
67 lpos = fieldnames.index('Limits') # output column for group process cap
68
69 # collect process caps for each group
70
71 pcaps = {}
72 for line in lines[linenr+2:]:
73 f = line.split()
74 if len(f) == lpos + 1:
75 t = f[lpos] # expect either [NONE] or MAXPROC=N or MAXPROC=N,M
76 if t.find('MAXPROC') == 0:
77 f2 = t.split('=')
78 if f2[1].find(',') >= 0: # then N,M format
79 max_asstring = f2[1].split(',')[1] # choose hard limit
80 else:
81 max_asstring = f2[1] # MAXPROC=N format
82
83 pcaps[f[gpos]] = int( max_asstring )
84
85 print pcaps
86
87 ### Local Variables: ***
88 ### mode: python ***
89 ### End: ***

Properties

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

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