diff --git a/docs/source/AdministratorGuide/Systems/MonitoringSystem/index.rst b/docs/source/AdministratorGuide/Systems/MonitoringSystem/index.rst index 3e8ad148c73..7d50735e59f 100644 --- a/docs/source/AdministratorGuide/Systems/MonitoringSystem/index.rst +++ b/docs/source/AdministratorGuide/Systems/MonitoringSystem/index.rst @@ -14,7 +14,8 @@ The Monitoring system is used to monitor various components of DIRAC. Currently, - WMSHistory: for monitoring the DIRAC WMS - PilotsHistory: for monitoring of DIRAC pilots - - Component Monitoring: for monitoring DIRAC components such as services, agents, etc. + - Agent Monitoring: for monitoring DIRAC agents + - Service Monitoring: for monitoring DIRAC services - RMS Monitoring: for monitoring the DIRAC RequestManagement System (mostly the Request Executing Agent). - PilotSubmission Monitoring: for monitoring the DIRAC pilot submission statistics from SiteDirector agents - DataOperation Monitoring: for monitoring the DIRAC data operation statistics @@ -128,16 +129,13 @@ Enable PilotsHistory monitoring In order to enable PilotsHistory monitoring you need to set the flag ``monitoringEnabled = True`` in Operations/Defaults. -Enable Component monitoring -=========================== - -.. warning:: - - not yet fully working/ready +Enable Monitoring of DIRAC Agents and Services +============================================== You have to set ``EnableActivityMonitoring=True`` in the CS. It can be done globally, the ``Operations`` section, or per single component. + Enable RMS Monitoring ===================== diff --git a/src/DIRAC/Core/Base/AgentModule.py b/src/DIRAC/Core/Base/AgentModule.py index 5a54a2ff0da..d8063e9e44b 100644 --- a/src/DIRAC/Core/Base/AgentModule.py +++ b/src/DIRAC/Core/Base/AgentModule.py @@ -102,6 +102,7 @@ def __init__(self, agentName, loadName, baseAgentName=False, properties={}): self.__basePath = gConfig.getValue("/LocalSite/InstancePath", rootPath) self.__agentModule = None + self.agentName = agentName self.__codeProperties = {} self.__getCodeInfo() @@ -295,7 +296,7 @@ def __initializeMonitor(self): # this class (see https://github.com/DIRACGrid/DIRAC/issues/4793) from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter - self.activityMonitoringReporter = MonitoringReporter(monitoringType="ComponentMonitoring") + self.activityMonitoringReporter = MonitoringReporter(monitoringType="AgentMonitoring") # With the help of this periodic task we commit the data to ES at an interval of 100 seconds. gThreadScheduler.addPeriodicTask(100, self.__activityMonitoringReporting) self.__monitorLastStatsUpdate = time.time() @@ -340,10 +341,11 @@ def am_go(self): signal.signal(signal.SIGALRM, signal.SIG_DFL) signal.alarm(watchdogInt) elapsedTime = time.time() - cpuStats = self._startReportToMonitoring() + if self.activityMonitoring: + initialWallTime, initialCPUTime, mem = self._startReportToMonitoring() cycleResult = self.__executeModuleCycle() - if cpuStats: - self._endReportToMonitoring(*cpuStats) + if self.activityMonitoring and initialWallTime and initialCPUTime: + cpuPercentage = self._endReportToMonitoring(initialWallTime, initialCPUTime) # Increment counters self.__moduleProperties["cyclesDone"] += 1 # Show status @@ -362,15 +364,15 @@ def am_go(self): self.log.notice(" Cycle was successful") if self.activityMonitoring: # Here we record the data about the cycle duration along with some basic details about the - # component and right now it isn't committed to the ES backend. + # agent and right now it isn't committed to the ES backend. self.activityMonitoringReporter.addRecord( { - "timestamp": int(Time.toEpoch()), - "host": Network.getFQDN(), - "componentType": "agent", - "component": "_".join(self.__moduleProperties["fullName"].split("/")), - "cycleDuration": elapsedTime, - "cycles": 1, + "AgentName": self.agentName, + "Timestamp": int(Time.toEpoch()), + "Host": Network.getFQDN(), + "MemoryUsage": mem, + "CpuPercentage": cpuPercentage, + "CycleDuration": elapsedTime, } ) else: @@ -383,24 +385,17 @@ def am_go(self): return cycleResult def _startReportToMonitoring(self): - try: - if not self.activityMonitoring: - now = time.time() - stats = os.times() - cpuTime = stats[0] + stats[2] - if now - self.__monitorLastStatsUpdate < 10: - return (now, cpuTime) - # Send CPU consumption mark - self.__monitorLastStatsUpdate = now - # Send Memory consumption mark - membytes = MemStat.VmB("VmRSS:") - if membytes: - mem = membytes / (1024.0 * 1024.0) - return (now, cpuTime) - else: - return False - except Exception: - return False + now = time.time() + stats = os.times() + mem = None + cpuTime = stats[0] + stats[2] + if now - self.__monitorLastStatsUpdate < 10: + return (now, cpuTime, mem) + self.__monitorLastStatsUpdate = now + membytes = MemStat.VmB("VmRSS:") + if membytes: + mem = membytes / (1024.0 * 1024.0) + return (now, cpuTime, mem) def _endReportToMonitoring(self, initialWallTime, initialCPUTime): wallTime = time.time() - initialWallTime diff --git a/src/DIRAC/Core/DISET/private/Service.py b/src/DIRAC/Core/DISET/private/Service.py index 628e2059747..f8a3a777cc6 100644 --- a/src/DIRAC/Core/DISET/private/Service.py +++ b/src/DIRAC/Core/DISET/private/Service.py @@ -109,7 +109,7 @@ def initialize(self): # this class (see https://github.com/DIRACGrid/DIRAC/issues/4793) from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter - self.activityMonitoringReporter = MonitoringReporter(monitoringType="ComponentMonitoring") + self.activityMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring") gThreadScheduler.addPeriodicTask(100, self.__activityMonitoringReporting) self._initMonitoring() # Call static initialization function @@ -134,6 +134,8 @@ def initialize(self): gLogger.exception(e) gLogger.exception(errMsg) return S_ERROR(errMsg) + if self.activityMonitoring: + gThreadScheduler.addPeriodicTask(30, self.__reportActivity) # Load actions after the handler has initialized itself result = self._loadActions() @@ -141,9 +143,6 @@ def initialize(self): return result self._actions = result["Value"] - if not self.activityMonitoring: - gThreadScheduler.addPeriodicTask(30, self.__reportThreadPoolContents) - return S_OK() def __searchInitFunctions(self, handlerClass, currentClass=None): @@ -254,10 +253,25 @@ def _initMonitoring(self): self._validNames.append(secondaryName) return S_OK() - def __reportThreadPoolContents(self): - # TODO: remove later + def __reportActivity(self): + initialWallTime, initialCPUTime, mem = self.__startReportToMonitoring() pendingQueries = self._threadPool._work_queue.qsize() activeQuereies = len(self._threadPool._threads) + percentage = self.__endReportToMonitoring(initialWallTime, initialCPUTime) + self.activityMonitoringReporter.addRecord( + { + "timestamp": int(Time.toEpoch()), + "Host": Network.getFQDN(), + "ServiceName": "_".join(self._name.split("/")), + "Location": self._cfg.getURL(), + "MemoryUsage": mem, + "CpuPercentage": percentage, + "PendingQueries": pendingQueries, + "ActiveQueries": activeQuereies, + "RunningThreads": threading.activeCount(), + "MaxFD": self.__maxFD, + } + ) self.__maxFD = 0 def getConfig(self): @@ -351,7 +365,7 @@ def _processInThread(self, clientTransport): finally: self._lockManager.unlockGlobal() if monReport: - self.__endReportToMonitoring(*monReport) + self.__endReportToMonitoring(monReport[0], monReport[1]) @staticmethod def _createIdentityString(credDict, clientTransport=None): @@ -547,18 +561,21 @@ def _mbConnect(self, trid, handlerObj=None): def _executeAction(self, trid, proposalTuple, handlerObj): try: + initialWallTime, initialCPUTime, mem = self.__startReportToMonitoring() response = handlerObj._rh_executeAction(proposalTuple) if not response["OK"]: return response if self.activityMonitoring: + percentage = self.__endReportToMonitoring(initialWallTime, initialCPUTime) self.activityMonitoringReporter.addRecord( { "timestamp": int(Time.toEpoch()), - "host": Network.getFQDN(), - "componentType": "service", - "component": "_".join(self._name.split("/")), - "componentLocation": self._cfg.getURL(), - "ServiceResponseTime": response["Value"][1], + "Host": Network.getFQDN(), + "serviceName": "_".join(self._name.split("/")), + "Location": self._cfg.getURL(), + "ResponseTime": response["Value"][1], + "MemoryUsage": mem, + "CpuPercentage": percentage, } ) return response["Value"][0] @@ -567,6 +584,7 @@ def _executeAction(self, trid, proposalTuple, handlerObj): return S_ERROR("Server error while executing action: %s" % str(e)) def _mbReceivedMsg(self, trid, msgObj): + initialWallTime, initialCPUTime, mem = self.__startReportToMonitoring() result = self._authorizeProposal( ("Message", msgObj.getName()), trid, self._transportPool.get(trid).getConnectingCredentials() ) @@ -578,14 +596,16 @@ def _mbReceivedMsg(self, trid, msgObj): handlerObj = result["Value"] response = handlerObj._rh_executeMessageCallback(msgObj) if self.activityMonitoring and response["OK"]: + percentage = self.__endReportToMonitoring(initialWallTime, initialCPUTime) self.activityMonitoringReporter.addRecord( { "timestamp": int(Time.toEpoch()), - "host": Network.getFQDN(), - "componentType": "service", - "component": "_".join(self._name.split("/")), - "componentLocation": self._cfg.getURL(), - "ServiceResponseTime": response["Value"][1], + "Host": Network.getFQDN(), + "ServiceName": "_".join(self._name.split("/")), + "Location": self._cfg.getURL(), + "ResponseTime": response["Value"][1], + "MemoryUsage": mem, + "CpuPercentage": percentage, } ) if response["OK"]: @@ -606,22 +626,20 @@ def __activityMonitoringReporting(self): :return: True / False """ - result = self.activityMonitoringReporter.commit() - return result["OK"] + return self.activityMonitoringReporter.commit() def __startReportToMonitoring(self): now = time.time() stats = os.times() cpuTime = stats[0] + stats[2] + mem = None if now - self.__monitorLastStatsUpdate < 0: - return (now, cpuTime) - # Send CPU consumption mark + return (now, cpuTime, mem) self.__monitorLastStatsUpdate = now - # Send Memory consumption mark membytes = MemStat.VmB("VmRSS:") if membytes: mem = membytes / (1024.0 * 1024.0) - return (now, cpuTime) + return (now, cpuTime, mem) def __endReportToMonitoring(self, initialWallTime, initialCPUTime): wallTime = time.time() - initialWallTime diff --git a/src/DIRAC/Core/Tornado/Server/TornadoServer.py b/src/DIRAC/Core/Tornado/Server/TornadoServer.py index b1b89a2ae1b..7fb0b33922f 100644 --- a/src/DIRAC/Core/Tornado/Server/TornadoServer.py +++ b/src/DIRAC/Core/Tornado/Server/TornadoServer.py @@ -23,9 +23,10 @@ import DIRAC from DIRAC import gConfig, gLogger, S_OK from DIRAC.Core.Security import Locations -from DIRAC.Core.Utilities import MemStat +from DIRAC.Core.Utilities import MemStat, Time, Network from DIRAC.Core.Tornado.Server.HandlerManager import HandlerManager from DIRAC.ConfigurationSystem.Client import PathFinder +from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations sLog = gLogger.getSubLogger(__name__) DEBUG_M2CRYPTO = os.getenv("DIRAC_DEBUG_M2CRYPTO", "No").lower() in ("yes", "true") @@ -85,6 +86,7 @@ def __init__(self, services=True, endpoints=False, port=None): :param int port: Port to listen to. If ``None``, the port is resolved following the logic described in the class documentation """ + self.__startTime = time.time() # Application metadata, routes and settings mapping on the ports self.__appsSettings = {} # Default port, if enother is not discover @@ -101,12 +103,17 @@ def __init__(self, services=True, endpoints=False, port=None): self.__monitorLastStatsUpdate = None self.__monitoringLoopDelay = 60 # In secs + self.activityMonitoring = False + self.monitoringOption = Operations().getValue("MonitoringBackends", ["Accounting"]) + if "Monitoring" in self.monitoringOption: + self.activityMonitoring = True # If services are defined, load only these ones (useful for debug purpose or specific services) retVal = self.handlerManager.loadServicesHandlers() if not retVal["OK"]: sLog.error(retVal["Message"]) raise ImportError("Some services can't be loaded, check the service names and configuration.") - + # Response time to load services + self.__elapsedTime = time.time() - self.__startTime retVal = self.handlerManager.loadEndpointsHandlers() if not retVal["OK"]: sLog.error(retVal["Message"]) @@ -170,7 +177,6 @@ def startTornado(self): Starts the tornado server when ready. This method never returns. """ - # If there is no services loaded: if not self.__calculateAppSettings(): raise Exception("There is no services loaded, please check your configuration") @@ -192,17 +198,22 @@ def startTornado(self): } # Init monitoring - self._initMonitoring() - self.__monitorLastStatsUpdate = time.time() - self.__report = self.__startReportToMonitoringLoop() - - # Starting monitoring, IOLoop waiting time in ms, __monitoringLoopDelay is defined in seconds - tornado.ioloop.PeriodicCallback(self.__reportToMonitoring, self.__monitoringLoopDelay * 1000).start() - - # If we are running with python3, Tornado will use asyncio, - # and we have to convince it to let us run in a different thread - # Doing this ensures a consistent behavior between py2 and py3 - asyncio.set_event_loop_policy(tornado.platform.asyncio.AnyThreadEventLoopPolicy()) + if self.activityMonitoring: + from DIRAC.MonitoringSystem.Client.MonitoringReporter import MonitoringReporter + + self.activityMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring") + self.__monitorLastStatsUpdate = time.time() + self.__report = self.__startReportToMonitoringLoop() + # Response time + # Starting monitoring, IOLoop waiting time in ms, __monitoringLoopDelay is defined in seconds + tornado.ioloop.PeriodicCallback( + self.__reportToMonitoring(self.__elapsedTime), self.__monitoringLoopDelay * 1000 + ).start() + + # If we are running with python3, Tornado will use asyncio, + # and we have to convince it to let us run in a different thread + # Doing this ensures a consistent behavior between py2 and py3 + asyncio.set_event_loop_policy(tornado.platform.asyncio.AnyThreadEventLoopPolicy()) for port, app in self.__appsSettings.items(): sLog.debug(" - %s" % "\n - ".join(["%s = %s" % (k, ssl_options[k]) for k in ssl_options])) @@ -224,19 +235,25 @@ def startTornado(self): tornado.ioloop.IOLoop.current().start() - def _initMonitoring(self): + def __reportToMonitoring(self, responseTime): """ - Initialize the monitoring - """ - - def __reportToMonitoring(self): - """ - Periodically report to the monitoring of the CPU and MEM + Periodically reports to Monitoring """ # Calculate CPU usage by comparing realtime and cpu time since last report - self.__endReportToMonitoringLoop(*self.__report) - + percentage = self.__endReportToMonitoringLoop(self.__report[0], self.__report[1]) + # Send record to Monitoring + self.activityMonitoringReporter.addRecord( + { + "timestamp": int(Time.toEpoch()), + "Host": Network.getFQDN(), + "ServiceName": "Tornado", + "MemoryUsage": self.__report[2], + "CpuPercentage": percentage, + "ResponseTime": responseTime, + } + ) + self.activityMonitoringReporter.commit() # Save memory usage and save realtime/CPU time for next call self.__report = self.__startReportToMonitoringLoop() @@ -262,7 +279,7 @@ def __startReportToMonitoringLoop(self): membytes = MemStat.VmB("VmRSS:") if membytes: mem = membytes / (1024.0 * 1024.0) - return (now, cpuTime) + return (now, cpuTime, mem) def __endReportToMonitoringLoop(self, initialWallTime, initialCPUTime): """ diff --git a/src/DIRAC/MonitoringSystem/Client/Types/AgentMonitoring.py b/src/DIRAC/MonitoringSystem/Client/Types/AgentMonitoring.py new file mode 100644 index 00000000000..afed528b62a --- /dev/null +++ b/src/DIRAC/MonitoringSystem/Client/Types/AgentMonitoring.py @@ -0,0 +1,47 @@ +""" +AgentMonitoring type used to monitor DIRAC agents. +""" +from DIRAC.MonitoringSystem.Client.Types.BaseType import BaseType + + +class AgentMonitoring(BaseType): + """ + .. class:: AgentMonitoring + """ + + def __init__(self): + + super().__init__() + + self.keyFields = [ + "Host", + "AgentName", + "Status", + "Location", + ] + + self.monitoringFields = [ + "RunningTime", + "MemoryUsage", + "CpuPercentage", + "CycleDuration", + ] + + self.index = "agent_monitoring-index" + + self.addMapping( + { + "Host": {"type": "keyword"}, + "AgentName": {"type": "keyword"}, + "Status": {"type": "keyword"}, + "Location": {"type": "keyword"}, + "RunningTime": {"type": "long"}, + "MemoryUsage": {"type": "long"}, + "CpuPercentage": {"type": "long"}, + "CycleDuration": {"type": "long"}, + } + ) + + self.period = "month" + + self.checkType() diff --git a/src/DIRAC/MonitoringSystem/Client/Types/ComponentMonitoring.py b/src/DIRAC/MonitoringSystem/Client/Types/ComponentMonitoring.py deleted file mode 100644 index fefc18f8daa..00000000000 --- a/src/DIRAC/MonitoringSystem/Client/Types/ComponentMonitoring.py +++ /dev/null @@ -1,48 +0,0 @@ -""" -ComponentMonitoring type used to monitor DIRAC components. -""" -from DIRAC.MonitoringSystem.Client.Types.BaseType import BaseType - - -class ComponentMonitoring(BaseType): - """ - .. class:: ComponentMonitoring - """ - - def __init__(self): - """c'tor - - :param self: self reference - """ - - super(ComponentMonitoring, self).__init__() - - self.keyFields = ["host", "component", "pid", "status", "componentType", "componentLocation"] - - self.monitoringFields = [ - "runningTime", - "memoryUsage", - "threads", - "cpuPercentage", - "Connections", - "PendingQueries", - "ActiveQueries", - "RunningThreads", - "MaxFD", - "ServiceResponseTime", - "cycleDuration", - "cycles", - ] - - self.addMapping( - { - "host": {"type": "keyword"}, - "component": {"type": "keyword"}, - "status": {"type": "keyword"}, - "componentType": {"type": "keyword"}, - "componentLocation": {"type": "keyword"}, - } - ) - - self.period = "month" - self.checkType() diff --git a/src/DIRAC/MonitoringSystem/Client/Types/ServiceMonitoring.py b/src/DIRAC/MonitoringSystem/Client/Types/ServiceMonitoring.py new file mode 100644 index 00000000000..b756f1d2681 --- /dev/null +++ b/src/DIRAC/MonitoringSystem/Client/Types/ServiceMonitoring.py @@ -0,0 +1,59 @@ +""" +ServiceMonitoring type used to monitor DIRAC services. +""" +from DIRAC.MonitoringSystem.Client.Types.BaseType import BaseType + + +class ServiceMonitoring(BaseType): + """ + .. class:: ServiceMonitoring + """ + + def __init__(self): + + super().__init__() + + self.keyFields = [ + "Host", + "ServiceName", + "Status", + "Location", + ] + + self.monitoringFields = [ + "RunningTime", + "MemoryUsage", + "CpuPercentage", + "Connections", + "Queries", + "PendingQueries", + "ActiveQueries", + "RunningThreads", + "MaxFD", + "ResponseTime", + ] + + self.index = "service_monitoring-index" + + self.addMapping( + { + "Host": {"type": "keyword"}, + "ServiceName": {"type": "keyword"}, + "Status": {"type": "keyword"}, + "Location": {"type": "keyword"}, + "RunningTime": {"type": "long"}, + "MemoryUsage": {"type": "long"}, + "CpuPercentage": {"type": "long"}, + "Connections": {"type": "long"}, + "Queries": {"type": "long"}, + "PendingQueries": {"type": "long"}, + "ActiveQueries": {"type": "long"}, + "RunningThreads": {"type": "long"}, + "MaxFD": {"type": "long"}, + "ResponseTime": {"type": "long"}, + } + ) + + self.period = "month" + + self.checkType() diff --git a/src/DIRAC/MonitoringSystem/private/Plotters/ComponentMonitoringPlotter.py b/src/DIRAC/MonitoringSystem/private/Plotters/ComponentMonitoringPlotter.py deleted file mode 100644 index fc8e5ea0054..00000000000 --- a/src/DIRAC/MonitoringSystem/private/Plotters/ComponentMonitoringPlotter.py +++ /dev/null @@ -1,302 +0,0 @@ -""" -This class is used to define the plot using the plot attributes. -""" -from DIRAC import S_OK, gLogger - -from DIRAC.MonitoringSystem.Client.Types.ComponentMonitoring import ComponentMonitoring -from DIRAC.MonitoringSystem.private.Plotters.BasePlotter import BasePlotter - - -class ComponentMonitoringPlotter(BasePlotter): - - """ - .. class:: ComponentMonitoringPlotter - - It is used to create the plots. - - param: str _typeName monitoring type - param: list _typeKeyFields list of keys what we monitor (list of attributes) - """ - - _typeName = "ComponentMonitoring" - _typeKeyFields = ComponentMonitoring().keyFields - - def __reportAllResources(self, reportRequest, metric, unit): - - retVal = self._getTimedData( - startTime=reportRequest["startTime"], - endTime=reportRequest["endTime"], - selectField=metric, - preCondDict=reportRequest["condDict"], - metadataDict={"DynamicBucketing": False, "metric": "avg"}, - ) - if not retVal["OK"]: - return retVal - - dataDict, granularity = retVal["Value"] - try: - _, _, _, unitName = self._findSuitableUnit(dataDict, self._getAccumulationMaxValue(dataDict), unit) - except AttributeError as e: - gLogger.warn(e) - unitName = unit - - return S_OK({"data": dataDict, "granularity": granularity, "unit": unitName}) - - def __plotAllResources(self, reportRequest, plotInfo, filename, title): - metadata = { - "title": "%s by %s" % (title, reportRequest["grouping"]), - "starttime": reportRequest["startTime"], - "endtime": reportRequest["endTime"], - "span": plotInfo["granularity"], - "skipEdgeColor": True, - "ylabel": plotInfo["unit"], - } - - plotInfo["data"] = self._fillWithZero( - granularity=plotInfo["granularity"], - startEpoch=reportRequest["startTime"], - endEpoch=reportRequest["endTime"], - dataDict=plotInfo["data"], - ) - - return self._generateStackedLinePlot(filename=filename, dataDict=plotInfo["data"], metadata=metadata) - - _reportRunningThreadsName = "Number of running threads" - - def _reportRunningThreads(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "threads", "threads") - - def _plotRunningThreads(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of running threads") - - _reportCpuUsageName = "CPU usage" - - def _reportCpuUsage(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "cpuPercentage", "percentage") - - def _plotCpuUsage(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "CPU usage") - - _reportMemoryUsageName = "Memory usage" - - def _reportMemoryUsage(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "memoryUsage", "bytes") - - def _plotMemoryUsage(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Memory usage") - - _reportRunningTimeName = "Running time" - - def _reportRunningTime(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "runningTime", "time") - - def _plotRunningTime(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Running time") - - _reportConnectionsName = "Number of Connections" - - def _reportConnections(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "Connections", "Connections") - - def _plotConnections(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of Connections") - - _reportActiveQueriesName = "Number of ActiveQueries" - - def _reportActiveQueries(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "ActiveQueries", "ActiveQueries") - - def _plotActiveQueries(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of ActiveQueries") - - _reportPendingQueriesName = "Number of PendingQueries" - - def _reportPendingQueries(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "PendingQueries", "PendingQueries") - - def _plotPendingQueries(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of PendingQueries") - - _reportMaxFDName = "Max File Descriptors" - - def _reportMaxFD(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return: S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "MaxFD", "MaxFD") - - def _plotMaxFD(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Max File Descriptors") - - _reportActivityRunningThreadsName = "Number of activity running threads(activity)" - - def _reportActivityRunningThreads(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "RunningThreads", "RunningThreads") - - def _plotActivityRunningThreads(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of running threads(activity)") - - _reportServiceResponseTimeName = "Service response time" - - def _reportServiceResponseTime(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "ServiceResponseTime", "seconds") - - def _plotServiceResponseTime(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Service response time") - - _reportAgentCycleDurationName = "Agent cycle duration" - - def _reportAgentCycleDuration(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "cycleDuration", "seconds") - - def _plotAgentCycleDuration(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Agent cycle duration") - - _reportAgentCyclesName = "Number of agent cycles" - - def _reportAgentCycles(self, reportRequest): - """It is used to retrieve the data from the database. - - :param dict reportRequest: contains attributes used to create the plot. - :return S_OK or S_ERROR {'data':value1, 'granularity':value2} value1 is a dictionary, value2 is the bucket length - """ - return self.__reportAllResources(reportRequest, "cycles", "AgentCycles") - - def _plotAgentCycles(self, reportRequest, plotInfo, filename): - """It creates the plot. - - :param dict reportRequest: plot attributes - :param dict plotInfo: contains all the data which are used to create the plot - :param str filename: - :return: S_OK or S_ERROR { 'plot' : value1, 'thumbnail' : value2 } value1 and value2 are TRUE/FALSE - """ - return self.__plotAllResources(reportRequest, plotInfo, filename, "Number of agent cycles") diff --git a/tests/Integration/Monitoring/Test_MonitoringReporter.py b/tests/Integration/Monitoring/Test_MonitoringReporter.py index a16834b71b7..ed50d643c2f 100644 --- a/tests/Integration/Monitoring/Test_MonitoringReporter.py +++ b/tests/Integration/Monitoring/Test_MonitoringReporter.py @@ -61,7 +61,8 @@ gLogger.setLevel("INFO") wmsMonitoringReporter = MonitoringReporter(monitoringType="WMSHistory") -componentMonitoringReporter = MonitoringReporter(monitoringType="ComponentMonitoring") +agentMonitoringReporter = MonitoringReporter(monitoringType="AgentMonitoring") +serviceMonitoringReporter = MonitoringReporter(monitoringType="ServiceMonitoring") pilotMonitoringReporter = MonitoringReporter(monitoringType="PilotSubmissionMonitoring") pilotsHistoryReporter = MonitoringReporter(monitoringType="PilotsHistory") data = [ @@ -629,90 +630,124 @@ # This dataset is used for the ComponentMonitoringType as the data which gets stored in this type # is usually with these type of fields. -activityMonitoringData = [ +agentMonitoringData = [ + { + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, + "timestamp": 1458226213, + }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", - "Connections": 92946, - "Queries": 1880, - "PendingQueries": 200, - "ActiveQueries": 200, - "RunningThreads": 200, - "MaxFD": 200, + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, + "timestamp": 1458226213, + }, + { + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Agent": "SiteDirector", + "Status": "Active", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, + "CycleDuration": 53, + "Cycles": 4, + "timestamp": 1458226213, + }, +] +serviceMonitoringData = [ + { + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -722,10 +757,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -735,10 +772,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -748,10 +787,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -761,10 +802,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -774,10 +817,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -787,10 +832,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -800,10 +847,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -813,10 +862,12 @@ "timestamp": 1458226213, }, { - "site": "dirac-dev", - "componentType": "service", - "component": "Framework_SystemAdministrator", - "componentLocation": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "Host": "dirac-dev", + "Service": "Framework_SystemAdministrator", + "Location": "dips://dirac-dev:9162/Framework/SystemAdministrator", + "RunningTime": 325, + "MemoryUsage": 345, + "CpuPercentage": 44, "Connections": 92946, "Queries": 1880, "PendingQueries": 200, @@ -880,12 +931,20 @@ def test_addWMSRecords(): assert result["Value"] == len(data) -def test_addComponentRecords(): - for record in activityMonitoringData: - componentMonitoringReporter.addRecord(record) - result = componentMonitoringReporter.commit() +def test_addAgentRecords(): + for record in agentMonitoringData: + agentMonitoringReporter.addRecord(record) + result = agentMonitoringReporter.commit() + assert result["OK"] + assert result["Value"] == len(agentMonitoringData) + + +def test_addServiceRecords(): + for record in serviceMonitoringData: + serviceMonitoringReporter.addRecord(record) + result = serviceMonitoringReporter.commit() assert result["OK"] - assert result["Value"] == len(activityMonitoringData) + assert result["Value"] == len(serviceMonitoringData) def test_addPilotSubmissionRecords(): diff --git a/tests/Integration/Monitoring/Test_Plotter.py b/tests/Integration/Monitoring/Test_Plotter.py deleted file mode 100644 index 496a331a29f..00000000000 --- a/tests/Integration/Monitoring/Test_Plotter.py +++ /dev/null @@ -1,416 +0,0 @@ -""" This is the Regression test for DIRAC.MonitoringSystem.private.Plotters in order to ensure - the proper working of the plotter. -""" - -# pylint: disable=invalid-name,wrong-import-position -import os - -from DIRAC.tests.Utilities.plots import compare - -# sut -from DIRAC.MonitoringSystem.private.Plotters.ComponentMonitoringPlotter import ComponentMonitoringPlotter - -plots_directory = os.path.join(os.path.dirname(__file__), "plots") - - -def test_plotRunningThreads(): - """test for the method "_plotRunningThreads" """ - - plotName = "ComponentMonitoringPlotter_plotRunningThreads" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 9.0, - 1562857200: 0, - 1562854500: 0, - 1562855400: 0, - 1562856300: 0, - 1562858100: 0, - 1562849100: 9.75, - 1562860800: 0, - 1562850000: 10.0, - 1562848200: 9.142857142857142, - 1562859900: 0, - 1562850900: 9.428571428571429, - 1562851800: 9.0, - 1562847300: 8.5, - 1562852700: 9.0, - } - }, - "unit": "threads", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotRunningThreads(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotCpuUsage(): - """test for the method "_plotCpuUsage" """ - - plotName = "ComponentMonitoringPlotter_plotCpuUsage" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562857200: 0, - 1562854500: 0, - 1562855400: 0, - 1562856300: 0, - 1562858100: 0, - 1562849100: 2.5875000450760126, - 1562850000: 0.9428571707436016, - 1562848200: 2.171428546309471, - 1562859900: 0, - 1562850900: 0.9428571473274913, - 1562851800: 0.10000000149011612, - 1562847300: 4.950000047683716, - 1562852700: 0.033333333830038704, - } - }, - "unit": "percentage", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotCpuUsage(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotMemoryUsage(): - """test for the method "_plotMemoryUsage" """ - - plotName = "ComponentMonitoringPlotter_plotMemoryUsage" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 93.03776041666667, - 1562857200: 0, - 1562854500: 0, - 1562855400: 0, - 1562856300: 0, - 1562858100: 0, - 1562849100: 249.76318359375, - 1562860800: 0, - 1562850000: 165.26674107142858, - 1562848200: 260.68917410714283, - 1562859900: 0, - 1562850900: 180.12890625, - 1562851800: 186.35546875, - 1562847300: 121.13671875, - 1562852700: 186.35807291666666, - } - }, - "unit": "MB", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotMemoryUsage(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -# FIXME: failing - -# def test_plotRunningTime(): -# """ test for the method "_plotRunningTime" -# """ - -# plotName = "ComponentMonitoringPlotter_plotRunningTime" -# reportRequest = {'grouping': 'component', -# 'groupingFields': ('%s', ['component']), -# 'startTime': 1562796000, -# 'endTime': 1562882400, -# 'condDict': {'component': 'Monitoring_Monitoring'} -# } - -# plotInfo = {'data': {'Monitoring_Monitoring': {1562853600: 313.32080459594727, -# 1562857200: 0, -# 1562854500: 0, -# 1562855400: 0, -# 1562856300: 0, -# 1562858100: 0, -# 1562849100: 1754.9678344726562, -# 1562860800: 0, -# 1562850000: 492.68797302246094, -# 1562848200: 854.48386492048, -# 1562859900: 0, -# 1562850900: 1332.7680140904017, -# 1562851800: 1812.8760986328125, -# 1562847300: 314.9701385498047, -# 1562852700: 3452.56787109375} -# }, -# 'unit': 'seconds', -# 'granularity': 900} - -# obj = ComponentMonitoringPlotter(None, None) -# res = obj._plotRunningTime(reportRequest, plotInfo, plotName) -# assert res['OK'] is True -# assert res['Value'] == {'plot': True, 'thumbnail': False} - -# res = compare('%s.png' % plotName, -# '%s.png' % os.path.join(plots_directory, plotName)) -# assert res == 0.0 - - -def test_plotConnections(): - """test for the method "_plotConnections" """ - - plotName = "ComponentMonitoringPlotter_plotConnections" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 0, - 1562857200: 1.0, - 1562854500: 1.0, - 1562855400: 1.0, - 1562856300: 1.0, - 1562858100: 1.0, - 1562849100: 0, - 1562860800: 1.0, - 1562850000: 0, - 1562848200: 0, - 1562859900: 0, - 1562850900: 0, - 1562851800: 0, - 1562847300: 0, - 1562852700: 0, - } - }, - "unit": "Connections", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotConnections(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotActiveQueries(): - """test for the method "_plotActiveQueries" """ - - plotName = "ComponentMonitoringPlotter_plotActiveQueries" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 0, - 1562857200: 0.06666666666666667, - 1562854500: 0, - 1562855400: 0.2, - 1562856300: 0, - 1562858100: 0, - 1562849100: 0, - 1562860800: 0, - 1562850000: 0, - 1562848200: 0, - 1562859900: 0, - 1562850900: 0, - 1562851800: 0, - 1562847300: 0, - 1562852700: 0, - } - }, - "unit": "ActiveQueries", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotActiveQueries(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotPendingQueries(): - """test for the method "_plotPendingQueries" """ - - plotName = "ComponentMonitoringPlotter_plotPendingQueries" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 0, - 1562857200: 0, - 1562854500: 0, - 1562855400: 0, - 1562856300: 0, - 1562858100: 0, - 1562849100: 0, - 1562860800: 0, - 1562850000: 0, - 1562848200: 0, - 1562859900: 0, - 1562850900: 0, - 1562851800: 0, - 1562847300: 0, - 1562852700: 0, - } - }, - "unit": "PendingQueries", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotPendingQueries(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotMaxFD(): - """test for the method "_plotMaxFD" """ - - plotName = "ComponentMonitoringPlotter_plotMaxFD" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 0, - 1562857200: 1.0, - 1562861700: 2.5, - 1562854500: 4.4, - 1562855400: 2.3333333333333335, - 1562856300: 2.076923076923077, - 1562858100: 1.3333333333333333, - 1562849100: 0, - 1562860800: 3.4615384615384617, - 1562850000: 0, - 1562848200: 0, - 1562859900: 0, - 1562850900: 0, - 1562851800: 0, - 1562847300: 0, - 1562852700: 0, - } - }, - "unit": "MaxFD", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotMaxFD(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 - - -def test_plotActivityRunningThreads(): - """test for the method "_plotActivityRunningThreads" """ - - plotName = "ComponentMonitoringPlotter_plotActivityRunningThreads" - reportRequest = { - "grouping": "component", - "groupingFields": ("%s", ["component"]), - "startTime": 1562796000, - "endTime": 1562882400, - "condDict": {"component": "Monitoring_Monitoring"}, - } - - plotInfo = { - "data": { - "Monitoring_Monitoring": { - 1562853600: 0, - 1562857200: 6.866666666666666, - 1562861700: 6.0, - 1562854500: 5.6, - 1562855400: 6.2, - 1562856300: 6.538461538461538, - 1562858100: 6.333333333333333, - 1562849100: 0, - 1562860800: 6.153846153846154, - 1562850000: 0, - 1562848200: 0, - 1562859900: 6.2, - 1562850900: 0, - 1562851800: 0, - 1562847300: 0, - 1562852700: 0, - } - }, - "unit": "RunningThreads", - "granularity": 900, - } - - obj = ComponentMonitoringPlotter(None, None) - res = obj._plotActivityRunningThreads(reportRequest, plotInfo, plotName) - assert res["OK"] is True - assert res["Value"] == {"plot": True, "thumbnail": False} - - res = compare("%s.png" % plotName, "%s.png" % os.path.join(plots_directory, plotName)) - assert res == 0.0 diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActiveQueries.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActiveQueries.png deleted file mode 100644 index 801d0ab7a51..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActiveQueries.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActivityRunningThreads.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActivityRunningThreads.png deleted file mode 100644 index 54c32f86e0f..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotActivityRunningThreads.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotConnections.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotConnections.png deleted file mode 100644 index 26a14fa96de..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotConnections.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotCpuUsage.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotCpuUsage.png deleted file mode 100644 index 968399b478d..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotCpuUsage.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMaxFD.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMaxFD.png deleted file mode 100644 index 5f9443979ff..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMaxFD.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMemoryUsage.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMemoryUsage.png deleted file mode 100644 index f7123350723..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotMemoryUsage.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotPendingQueries.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotPendingQueries.png deleted file mode 100644 index c421cf040bc..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotPendingQueries.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningThreads.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningThreads.png deleted file mode 100644 index aacee63c550..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningThreads.png and /dev/null differ diff --git a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningTime.png b/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningTime.png deleted file mode 100644 index d992b0fa2f8..00000000000 Binary files a/tests/Integration/Monitoring/plots/ComponentMonitoringPlotter_plotRunningTime.png and /dev/null differ diff --git a/tests/Integration/all_integration_server_tests.sh b/tests/Integration/all_integration_server_tests.sh index db9814ff5a3..e59ee2e8e01 100644 --- a/tests/Integration/all_integration_server_tests.sh +++ b/tests/Integration/all_integration_server_tests.sh @@ -35,7 +35,6 @@ pytest "${THIS_DIR}/Framework/Test_AuthServer.py" |& tee -a "${SERVER_TEST_OUTPU #-------------------------------------------------------------------------------# echo -e "*** $(date -u) **** MONITORING TESTS ****\n" pytest "${THIS_DIR}/Monitoring/Test_MonitoringReporter.py" |& tee -a "${SERVER_TEST_OUTPUT}"; (( ERR |= "${?}" )) -pytest "${THIS_DIR}/Monitoring/Test_Plotter.py" |& tee -a "${SERVER_TEST_OUTPUT}"; (( ERR |= "${?}" )) pytest "${THIS_DIR}/Monitoring/Test_MonitoringDB.py" |& tee -a "${SERVER_TEST_OUTPUT}"; (( ERR |= "${?}" )) #-------------------------------------------------------------------------------#