@@ -69,8 +69,6 @@ def __init__(self, serviceData):
69
69
70
70
def setCloneProcessId (self , cloneId ):
71
71
self .__cloneId = cloneId
72
- if not self .activityMonitoring :
73
- self ._monitor .setComponentName ("%s-Clone:%s" % (self ._name , cloneId ))
74
72
75
73
def _isMetaAction (self , action ):
76
74
referedAction = Service .SVC_VALID_ACTIONS [action ]
@@ -117,21 +115,13 @@ def initialize(self):
117
115
118
116
self .activityMonitoringReporter = MonitoringReporter (monitoringType = "ComponentMonitoring" )
119
117
gThreadScheduler .addPeriodicTask (100 , self .__activityMonitoringReporting )
120
- elif self ._standalone :
121
- self ._monitor = gMonitor
122
- else :
123
- self ._monitor = MonitoringClient ()
124
118
self ._initMonitoring ()
125
119
# Call static initialization function
126
120
try :
127
121
if self .activityMonitoring :
128
122
self ._handler ["class" ]._rh__initializeClass (
129
123
dict (self ._serviceInfoDict ), self ._lockManager , self ._msgBroker , self .activityMonitoringReporter
130
124
)
131
- else :
132
- self ._handler ["class" ]._rh__initializeClass (
133
- dict (self ._serviceInfoDict ), self ._lockManager , self ._msgBroker , self ._monitor
134
- )
135
125
if self ._handler ["init" ]:
136
126
for initFunc in self ._handler ["init" ]:
137
127
gLogger .verbose ("Executing initialization function" )
@@ -255,61 +245,15 @@ def _loadActions(self):
255
245
return S_OK ({"methods" : methodsList , "auth" : authRules , "types" : typeCheck })
256
246
257
247
def _initMonitoring (self ):
258
- if not self .activityMonitoring :
259
- # Init extra bits of monitoring
260
- self ._monitor .setComponentType (MonitoringClient .COMPONENT_SERVICE )
261
- self ._monitor .setComponentName (self ._name )
262
- self ._monitor .setComponentLocation (self ._cfg .getURL ())
263
- self ._monitor .initialize ()
264
- self ._monitor .registerActivity (
265
- "Connections" , "Connections received" , "Framework" , "connections" , MonitoringClient .OP_RATE
266
- )
267
- self ._monitor .registerActivity (
268
- "Queries" , "Queries served" , "Framework" , "queries" , MonitoringClient .OP_RATE
269
- )
270
- self ._monitor .registerActivity ("CPU" , "CPU Usage" , "Framework" , "CPU,%" , MonitoringClient .OP_MEAN , 600 )
271
- self ._monitor .registerActivity (
272
- "MEM" , "Memory Usage" , "Framework" , "Memory,MB" , MonitoringClient .OP_MEAN , 600
273
- )
274
- self ._monitor .registerActivity (
275
- "PendingQueries" , "Pending queries" , "Framework" , "queries" , MonitoringClient .OP_MEAN
276
- )
277
- self ._monitor .registerActivity (
278
- "ActiveQueries" , "Active queries" , "Framework" , "threads" , MonitoringClient .OP_MEAN
279
- )
280
- self ._monitor .registerActivity (
281
- "RunningThreads" , "Running threads" , "Framework" , "threads" , MonitoringClient .OP_MEAN
282
- )
283
- self ._monitor .registerActivity ("MaxFD" , "Max File Descriptors" , "Framework" , "fd" , MonitoringClient .OP_MEAN )
284
-
285
- self ._monitor .setComponentExtraParam ("DIRACVersion" , DIRAC .version )
286
- self ._monitor .setComponentExtraParam ("platform" , DIRAC .getPlatform ())
287
- self ._monitor .setComponentExtraParam ("startTime" , Time .dateTime ())
288
- props = [("__doc__" , "description" )]
289
- for prop in props :
290
- try :
291
- value = getattr (self ._handler ["module" ], prop [0 ])
292
- except Exception as e :
293
- gLogger .exception (e )
294
- gLogger .error ("Missing property" , prop [0 ])
295
- value = "unset"
296
- self ._monitor .setComponentExtraParam (prop [1 ], value )
297
-
298
248
for secondaryName in self ._cfg .registerAlsoAs ():
299
249
gLogger .info ("Registering %s also as %s" % (self ._name , secondaryName ))
300
250
self ._validNames .append (secondaryName )
301
-
302
251
return S_OK ()
303
252
304
253
def __reportThreadPoolContents (self ):
305
254
# TODO: remove later
306
255
pendingQueries = self ._threadPool ._work_queue .qsize ()
307
256
activeQuereies = len (self ._threadPool ._threads )
308
-
309
- self ._monitor .addMark ("PendingQueries" , pendingQueries )
310
- self ._monitor .addMark ("ActiveQueries" , activeQuereies )
311
- self ._monitor .addMark ("RunningThreads" , threading .activeCount ())
312
- self ._monitor .addMark ("MaxFD" , self .__maxFD )
313
257
self .__maxFD = 0
314
258
315
259
def getConfig (self ):
@@ -327,7 +271,6 @@ def handleConnection(self, clientTransport):
327
271
"""
328
272
if not self .activityMonitoring :
329
273
self ._stats ["connections" ] += 1
330
- self ._monitor .setComponentExtraParam ("queries" , self ._stats ["connections" ])
331
274
self ._threadPool .submit (self ._processInThread , clientTransport )
332
275
333
276
@property
@@ -663,9 +606,6 @@ def __activityMonitoringReporting(self):
663
606
return result ["OK" ]
664
607
665
608
def __startReportToMonitoring (self ):
666
- if not self .activityMonitoring :
667
- self ._monitor .addMark ("Queries" )
668
-
669
609
now = time .time ()
670
610
stats = os .times ()
671
611
cpuTime = stats [0 ] + stats [2 ]
@@ -677,15 +617,11 @@ def __startReportToMonitoring(self):
677
617
membytes = MemStat .VmB ("VmRSS:" )
678
618
if membytes :
679
619
mem = membytes / (1024.0 * 1024.0 )
680
- if not self .activityMonitoring :
681
- self ._monitor .addMark ("MEM" , mem )
682
620
return (now , cpuTime )
683
621
684
622
def __endReportToMonitoring (self , initialWallTime , initialCPUTime ):
685
623
wallTime = time .time () - initialWallTime
686
624
stats = os .times ()
687
625
cpuTime = stats [0 ] + stats [2 ] - initialCPUTime
688
626
percentage = cpuTime / wallTime * 100.0
689
- if percentage > 0 :
690
- if not self .activityMonitoring :
691
- self ._monitor .addMark ("CPU" , percentage )
627
+ return percentage
0 commit comments