7 # $Id: wmsTxtView.py,v 1.18 2011/02/10 21:35:32 parag Exp $
10 # This tool displays the status of the glideinWMS pool
14 # [-pool collector_node] Entries|Sites|Gatekeepers
17 # Igor Sfiligoi (May 9th 2007)
23 sys
.path
.append(os
.path
.join(sys
.path
[0],"../factory"))
24 sys
.path
.append(os
.path
.join(sys
.path
[0],"../frontend"))
25 sys
.path
.append(os
.path
.join(sys
.path
[0],"../lib"))
27 #import glideFactoryInterface
28 import glideinFrontendInterface
32 remove_condor_stats
=True
46 factory_name
=sys
.argv
[i
]
47 elif ael
in ('Entries','Sites','Gatekeepers'):
51 print "wmsTxtView.py [-pool <node>[:<port>]] [-factory <factory>] [Entries|Sites|Gatekeepers] [-help]"
54 raise RuntimeError,"Unknown option '%s', try -help"%ael
58 factory_constraints
=None
59 if factory_name
!=None:
60 farr
=factory_name
.split('@')
62 # just the generic factory name
63 factory_constraints
='FactoryName=?="%s"'%factory
_name
65 factory_constraints
='(FactoryName=?="%s")&&(GlideinName=?="%s")'%(farr
[1],farr
[0])
67 factory_constraints
='(FactoryName=?="%s")&&(GlideinName=?="%s")&&(EntryName=?="%s")'%(farr
[2],farr
[1],farr
[0])
69 raise RuntimeError, "Invalid factory name; more than 2 @'s found"
71 glideins_obj
=glideinFrontendInterface
.findGlideins(pool_name
,None,None,factory_constraints
,get_only_matching
=False)
80 glideins
=glideins_obj
.keys()
81 for glidein
in glideins
:
82 glidein_el
=glideins_obj
[glidein
]
84 if txt_type
=='Entries':
86 elif txt_type
=='Sites':
87 key
=glidein_el
['attrs']['GLIDEIN_Site']
88 elif txt_type
=='Gatekeepers':
89 key
=glidein_el
['attrs']['GLIDEIN_Gatekeeper']
91 raise RuntimeError, "Unknwon type '%s'"%txt_type
94 if txt_data
.has_key(key
):
97 key_el
={'RequestedIdle':0,'Idle':0,'Running':0,'MaxRunning':0}
100 if glidein_el
.has_key('monitor'):
101 if glidein_el
['monitor'].has_key('TotalRequestedIdle'):
102 key_el
['RequestedIdle']+=glidein_el
['monitor']['TotalRequestedIdle']
103 key_el
['Idle']+=glidein_el
['monitor']['TotalStatusIdle']
104 key_el
['Running']+=glidein_el
['monitor']['TotalStatusRunning']
105 key_el
['MaxRunning']+=glidein_el
['monitor']['TotalRequestedMaxRun']
108 txt_keys
=txt_data
.keys()
111 print '%s ReqIdle Idle Running MaxRun'%string
.ljust('Entry',48)
112 print '================================================-=======-=======-=======-======='
115 print "%s %7i %7i %7i %7i"%(string
.ljust(key
,48),key_el
['RequestedIdle'],key_el
['Idle'],key_el
['Running'],key_el
['MaxRunning'])