/[pdpsoft]/nl.nikhef.ndpf.groupviews/trunk/mcpeil
ViewVC logotype

Annotation of /nl.nikhef.ndpf.groupviews/trunk/mcpeil

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2702 - (hide annotations) (download)
Mon Apr 28 13:28:46 2014 UTC (8 years, 5 months ago) by templon
File size: 3172 byte(s)
updates

1 templon 2701 #!/usr/bin/env python
2     from torque_utils import pbsnodes
3    
4     import os
5     import sys
6     import subprocess
7    
8 templon 2702 GROUPS = ['atlb', 'datagrid']
9     MCQUEUE = 'atlasmc'
10     TORQUE = "stro.nikhef.nl"
11    
12 templon 2701 wnodes = pbsnodes()
13     mcnodes = list()
14    
15     for node in wnodes:
16     if \
17     'mc' in node.properties \
18     and 'el6' not in node.properties \
19     and node.state.count('offline') == 0:
20     mcnodes.append(node)
21    
22     mcslots = 0
23     mcfree = 0
24     mcrun = 0
25    
26 templon 2702 usedkeys = ['egroup', 'jobid', 'queue', 'job_state', 'euser', 'exec_host' ]
27 templon 2701
28 templon 2702 import torqueJobs
29     import torqueAttMappers as tam
30    
31     import tempfile
32     qsfname = tempfile.mktemp(".txt","qsmf",os.environ['HOME']+"/tmp")
33    
34     import time
35     os.system('/usr/bin/qstat -f %s@%s' %(MCQUEUE, TORQUE) + ' > ' + qsfname)
36     now = time.mktime(time.localtime())
37    
38     jlist = torqueJobs.qs_parsefile(qsfname)
39    
40     os.system('mv ' + qsfname + ' ' + os.environ['HOME'] + '/tmp/qstat.last.mcpool.txt')
41    
42     def mapatts(indict,inkeys):
43     sdict = tam.sub_dict(indict,inkeys)
44     odict = dict()
45     for k in sdict.keys():
46     if k in tam.tfl and sdict[k]:
47     secs = tam.hms(sdict[k])
48     sdict[k] = secs/3600.
49     if k in tam.mfl and sdict[k]:
50     mebi = tam.memconvert(sdict[k])
51     sdict[k] = mebi
52     if k in tam.tfl2 and sdict[k]:
53     secs = tam.tconv(sdict[k])
54     sdict[k] = secs
55     elif k == 'job_state':
56     statelett = sdict[k]
57     if statelett in ['Q','W']:
58     sdict[k] = 'queued'
59     elif statelett in ['R','E']:
60     sdict[k] = 'running'
61     elif k == 'exec_host' and sdict[k]:
62     termpos = sdict[k].find('/')
63     wnstring = sdict[k][:termpos]
64     odict['wn'] = wnstring
65     if sdict[k]:
66     odict[k] = sdict[k]
67     return odict
68    
69     mcjobdict = dict()
70     for j in jlist:
71     mcjobdict[j['jobid']] = mapatts(j,usedkeys)
72    
73     # {'queue': 'atlasmc', 'euser': 'templon', 'job_state': 'queued', \
74     # 'egroup': 'datagrid', 'jobid': '43609804.stro.nikhef.nl'}
75    
76     runjobdict = dict() # runjobdict[wn][group] = num running procs
77    
78     nq = dict()
79     nr = dict()
80    
81     for g in GROUPS:
82     nq[g] = 0
83     nr[g] = 0
84    
85     for jid in mcjobdict :
86     thisj = mcjobdict[jid]
87     if thisj['job_state'] == 'queued':
88     nq[thisj['egroup']] += 1
89     elif thisj['job_state'] == 'running':
90     if thisj['wn'] not in runjobdict.keys():
91     runjobdict[thisj['wn']] = dict()
92     if thisj['egroup'] not in runjobdict[thisj['wn']].keys():
93     runjobdict[thisj['wn']][thisj['egroup']] = 0
94     runjobdict[thisj['wn']][thisj['egroup']] += thisj['exec_host'].count('+') + 1
95    
96 templon 2701 for n in mcnodes:
97     mcslots += n.numCpu
98     mcfree += n.freeCpu
99 templon 2702 if n.name in runjobdict:
100     for gd in runjobdict[n.name]:
101     nr[gd] += runjobdict[n.name][gd]
102 templon 2701
103 templon 2702 rtot = sum(nr.values())
104    
105 templon 2701 import rrdtool
106     DATADIR=os.environ['HOME'] + '/ndpfdata/'
107 templon 2702 rrdtool.update(DATADIR+'capacity.mcpool.rrd', 'N:%d' % (mcslots))
108     rrdtool.update(DATADIR+'unused.mcpool.rrd', 'N:%d' % (mcfree))
109     rrdtool.update(DATADIR+'nonmc.running.mcpool.rrd', 'N:%d' % (mcslots - mcfree - rtot))
110 templon 2701
111 templon 2702 for g in nr:
112     rrdtool.update(DATADIR+'%s.running.mcpool.rrd' % g, 'N:%d' % (nr[g]))
113     rrdtool.update(DATADIR+'%s.queued.mcpool.rrd' % g, 'N:%d' % (nq[g]))

Properties

Name Value
svn:executable *

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