/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/jplist/jplist
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/jplist/jplist

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2544 - (show annotations) (download)
Fri Apr 27 17:13:42 2012 UTC (9 years, 8 months ago) by templon
File size: 1501 byte(s)
check for race condition: new job enters system between calls
to qstat & diagnose

1 #!/usr/bin/env python
2
3 # $Id$
4 # Source: $URL$
5 # J. A. Templon, NIKHEF/PDP 2010
6
7 import os
8 import sys
9
10 # indices for qstat
11 JID=0
12 NAM=1
13 POOLU=2
14 TSTR=3
15 STAT=4
16 QNAM=5
17
18 # indices for diagnose -p
19 # JID zero here too
20 SCHEDRANK=1
21 PRIO=2
22 FS=3
23
24 import commands
25
26 statp, outp = commands.getstatusoutput('qstat')
27 lines = outp.split('\n')[2:]
28
29 jud = dict()
30 sd = dict()
31
32 for line in lines:
33 flds = line.split()
34 usr = flds[POOLU]
35 if usr not in sd:
36 sd[usr] = {'Q' : 0, 'R' : 0, 'other' : 0}
37 if flds[STAT] in ['R', 'Q']:
38 sd[usr][flds[STAT]] += 1
39 else:
40 sd[usr]['other'] += 1
41 jidstr = flds[JID]
42 endindex = jidstr.find('.stro')
43 jidnum = jidstr[:endindex]
44 jud[jidnum] = usr
45
46 statp, outp = commands.getstatusoutput('diagnose -p')
47 lines = outp.split('\n')[5:]
48 jpd = dict()
49 for line in lines:
50 if line == '': break
51 flds = line.split()
52 jid = flds[JID]
53 rank = flds[SCHEDRANK]
54 if jid in jud.keys():
55 usr = jud[jid]
56 if rank not in jpd.keys():
57 jpd[rank] = dict()
58 if usr not in jpd[rank].keys():
59 jpd[rank][usr] = list()
60 jpd[rank][usr].append(jid)
61
62 plist = jpd.keys()
63 plistnumeric = list()
64 for k in plist:
65 plistnumeric.append(int(k))
66 plistnumeric.sort(reverse=True)
67
68 print "Sched.rank User Jobs: Waiting / Running "
69 for p in plistnumeric:
70 users = jpd[repr(p)].keys()
71 for u in users:
72 njobs = len(jpd[repr(p)][u])
73 print "%7d %8s %5d %5d" % (p, u, njobs, sd[u]['R'])
74

Properties

Name Value
svn:executable *
svn:keywords Id URL

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