A new doc condor_config.html is being added showing the condor configuration
[burt-test.git] / tools / wmsTxtView.py
blob4930268e1bd67ac8337854826448beea96363f19
1 #!/usr/bin/env python
3 # Project:
4 # glideinWMS
6 # File Version:
7 # $Id: wmsTxtView.py,v 1.18 2011/02/10 21:35:32 parag Exp $
9 # Description:
10 # This tool displays the status of the glideinWMS pool
11 # in a text format
13 # Arguments:
14 # [-pool collector_node] Entries|Sites|Gatekeepers
16 # Author:
17 # Igor Sfiligoi (May 9th 2007)
20 import string
21 import os.path
22 import sys
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
30 pool_name=None
31 factory_name=None
32 remove_condor_stats=True
33 remove_internals=True
34 txt_type='Entries'
36 # parse arguments
37 alen=len(sys.argv)
38 i=1
39 while (i<alen):
40 ael=sys.argv[i]
41 if ael=='-pool':
42 i=i+1
43 pool_name=sys.argv[i]
44 elif ael=='-factory':
45 i=i+1
46 factory_name=sys.argv[i]
47 elif ael in ('Entries','Sites','Gatekeepers'):
48 txt_type=ael
49 elif ael=='-help':
50 print "Usage:"
51 print "wmsTxtView.py [-pool <node>[:<port>]] [-factory <factory>] [Entries|Sites|Gatekeepers] [-help]"
52 sys.exit(1)
53 else:
54 raise RuntimeError,"Unknown option '%s', try -help"%ael
55 i=i+1
57 # get data
58 factory_constraints=None
59 if factory_name!=None:
60 farr=factory_name.split('@')
61 if len(farr)==1:
62 # just the generic factory name
63 factory_constraints='FactoryName=?="%s"'%factory_name
64 elif len(farr)==2:
65 factory_constraints='(FactoryName=?="%s")&&(GlideinName=?="%s")'%(farr[1],farr[0])
66 elif len(farr)==3:
67 factory_constraints='(FactoryName=?="%s")&&(GlideinName=?="%s")&&(EntryName=?="%s")'%(farr[2],farr[1],farr[0])
68 else:
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)
73 # Get a dictionary of
74 # RequestedIdle
75 # Idle
76 # Running
77 txt_data={}
79 # extract data
80 glideins=glideins_obj.keys()
81 for glidein in glideins:
82 glidein_el=glideins_obj[glidein]
84 if txt_type=='Entries':
85 key=glidein
86 elif txt_type=='Sites':
87 key=glidein_el['attrs']['GLIDEIN_Site']
88 elif txt_type=='Gatekeepers':
89 key=glidein_el['attrs']['GLIDEIN_Gatekeeper']
90 else:
91 raise RuntimeError, "Unknwon type '%s'"%txt_type
94 if txt_data.has_key(key):
95 key_el=txt_data[key]
96 else:
97 key_el={'RequestedIdle':0,'Idle':0,'Running':0,'MaxRunning':0}
98 txt_data[key]=key_el
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']
107 #print data
108 txt_keys=txt_data.keys()
109 txt_keys.sort()
111 print '%s ReqIdle Idle Running MaxRun'%string.ljust('Entry',48)
112 print '================================================-=======-=======-=======-======='
113 for key in txt_keys:
114 key_el=txt_data[key]
115 print "%s %7i %7i %7i %7i"%(string.ljust(key,48),key_el['RequestedIdle'],key_el['Idle'],key_el['Running'],key_el['MaxRunning'])