7 # $Id: glidein_status.py,v 1.34 2011/02/10 21:35:31 parag Exp $
10 # Equivalent to condor_status, but with glidein specific info
13 # glidein_status.py [-help] [-gatekeeper] [-glidecluster] [-withmonitor] [-total] [-site] [-pool name]
20 print "glidein_status.py [-help] [-gatekeeper] [-glidecluster] [-glexec] [-withmonitor] [-bench] [-total] [-site] [-pool name] [-constraint name]"
23 print " -gatekeeper : Print out the glidein gatekeeper"
24 print " -glidecluster : Print out the glidein cluster nr"
25 print " -glexec : Print out if glexec is used"
26 print " -withmonitor : Print out the monitoring VMs, too"
27 print " -bench : Print out the benchmarking numbers, too"
28 print " -total : Print out only the totals (skip details)"
29 print " -site : Summarize by site (default by entry name)"
30 print " -pool : Same as -pool in condor_status"
31 print " -constraint : Same as -constraint in condor_status"
37 sys
.path
.append(os
.path
.join(sys
.path
[0],"../lib"))
45 want_glidecluster
=False
57 if arg
=='-gatekeeper':
59 elif arg
=='-glidecluster':
60 want_glidecluster
=True
63 elif arg
=='-withmonitor':
74 elif arg
=='-constraint':
76 constraint
=sys
.argv
[i
]
85 constraint
='IS_MONITOR_VM =!= TRUE'
87 constraint
='(%s) && (IS_MONITOR_VM =!= TRUE)'%constraint
89 format_list
=[('Machine','s'),('State','s'),('Activity','s'),
91 ('GLIDEIN_Factory','s'),('GLIDEIN_Name','s'),('GLIDEIN_Entry_Name','s'),('EnteredCurrentActivity','i')]
92 attrs
=['State','Activity','GLIDEIN_Site','GLIDEIN_Factory','GLIDEIN_Name','GLIDEIN_Entry_Name','EnteredCurrentActivity']
95 format_list
.append(('GLIDEIN_Gatekeeper','s'))
96 format_list
.append(('GLIDEIN_GridType','s'))
97 attrs
.append('GLIDEIN_Gatekeeper')
98 attrs
.append('GLIDEIN_GridType')
100 if want_glidecluster
:
101 format_list
.append(('GLIDEIN_ClusterId','i'))
102 format_list
.append(('GLIDEIN_ProcId','i'))
103 format_list
.append(('GLIDEIN_Schedd','s'))
104 attrs
.append('GLIDEIN_ClusterId')
105 attrs
.append('GLIDEIN_ProcId')
106 attrs
.append('GLIDEIN_Schedd')
109 format_list
.append(('GLEXEC_STARTER','b'))
110 format_list
.append(('GLEXEC_JOB','b'))
111 attrs
.append('GLEXEC_STARTER')
112 attrs
.append('GLEXEC_JOB')
115 format_list
.append(('KFlops','i'))
116 format_list
.append(('Mips','i'))
117 attrs
.append('KFlops')
120 cs
=condorMonitor
.CondorStatus(pool_name
=pool_name
)
121 cs
.load(constraint
=constraint
,format_list
=format_list
)
126 # sort on the Machine attribute
127 def machine_cmp(x
,y
):
128 res
=cmp(data
[x
]['Machine'],data
[y
]['Machine'])
133 keys
.sort(machine_cmp
)
136 counts_header
=('Total','Owner','Claimed/Busy','Claimed/Retiring','Claimed/Other','Unclaimed','Matched','Other')
139 counts_header
+=('GFlops',' GIPS')
141 now
=long(time
.time())
150 return "%i+%02i:%02i:%02i"%(diff_days
,diff_hours
,diff_mins
,diff_secs
)
153 print_mask
="%-39s %-9s"
155 print_mask
+=" %-5s %-43s"
156 print_mask
+=" %-19s %-19s"
157 if want_glidecluster
:
158 print_mask
+=" %-39s %-14s"
162 print_mask
+=" %-5s %-5s"
163 print_mask
+=" %-9s %-8s %-10s"
165 header
=('Name','Site')
167 header
+=('Grid','Gatekeeper')
168 header
+=('Factory','Entry')
169 if want_glidecluster
:
170 header
+=('GlideSchedd','GlideCluster')
174 header
+=('MFlop','Mips')
175 header
+=('State','Activity','ActvtyTime')
179 print print_mask
%header
183 for c
in counts_header
:
189 cel
={} # this will have all the needed attributes (??? if nothing else)
195 if cel
['EnteredCurrentActivity']!='???':
196 cel
['EnteredCurrentActivity']=fmt_time(long(cel
['EnteredCurrentActivity']))
199 activity
=cel
['Activity']
201 if el
.has_key('KFlops'):
202 gflops
=(el
['KFlops']*1.e
-6)
203 mflops_str
="%i"%(el
['KFlops']/1000)
208 if el
.has_key('Mips'):
209 gips
=el
['Mips']*1.e
-3
215 if summarize
=='site':
216 sum_str
=cel
['GLIDEIN_Site']
218 sum_str
="%s@%s@%s"%(cel
['GLIDEIN_Entry_Name'],cel
['GLIDEIN_Name'],cel
['GLIDEIN_Factory'])
219 if not counts
.has_key(sum_str
):
221 for c
in counts_header
:
224 for t
in ('Total',sum_str
):
227 if state
in ('Owner','Unclaimed','Matched'):
229 elif state
=='Claimed':
230 if activity
in ('Busy','Retiring'):
231 ct
['%s/%s'%(state
,activity
)]+=1
233 ct
['Claimed/Other']+=1
242 print_arr
=(vm_name
,cel
['GLIDEIN_Site'])
244 print_arr
+=(cel
['GLIDEIN_GridType'],cel
['GLIDEIN_Gatekeeper'])
245 print_arr
+=("%s@%s"%(cel
['GLIDEIN_Name'],cel
['GLIDEIN_Factory']),cel
['GLIDEIN_Entry_Name'])
246 if want_glidecluster
:
247 print_arr
+=(cel
['GLIDEIN_Schedd'],"%i.%i"%(cel
['GLIDEIN_ClusterId'],cel
['GLIDEIN_ProcId']))
250 if el
.has_key('GLEXEC_JOB') and el
['GLEXEC_JOB']:
252 elif el
.has_key('GLEXEC_STARTER') and el
['GLEXEC_STARTER']:
254 print_arr
+=(glexec_str
,)
256 print_arr
+=(mflops_str
,mips_str
)
257 print_arr
+=(state
,activity
,cel
['EnteredCurrentActivity'])
259 print print_mask
%print_arr
263 count_print_mask
="%39s"
264 for c
in counts_header
:
265 count_print_mask
+=" %%%is"%len(c
)
266 print count_print_mask
%(('',)+counts_header
)
270 def ltotal_cmp(x
,y
): # Total last
292 # split in pieces and sort end to front
296 res
=cmp(x_arr
[i
],y_arr
[i
])
301 if summarize
=='site':
302 ckeys
.sort(ltotal_cmp
)
303 else: # default is entry
304 ckeys
.sort(entry_cmp
)
307 print # put a space before the entry names
311 print # put an empty line before Total
313 for c
in counts_header
:
314 count_print_val
.append(int(counts
[t
][c
]))
316 print count_print_mask
%tuple(count_print_val
)