def _executeInternal(self):
   from common import SystemStatusManager
   SystemStatusManager.setKafkaComponentStatus(MediationStatusProducer.name,
                                               MediationStatusProducer.instance().status,
                                               AppConfig.getCurrentTime())
   SystemStatusManager.setKafkaComponentStatus(MediationDataConsumer.name,
                                               MediationDataConsumer.instance().status,
                                               AppConfig.getCurrentTime())
Ejemplo n.º 2
0
 def run(self):
   try:
     while True:
       job = self.queue.get_nowait()
       FlowAnalyzer(job).run(AppConfig.getCurrentTime())
   except Exception as e:
     pass
 def _setStatusMetadata(self, flowStatus, flow):
     ticTime = flowStatus["ticTime"]
     if not flow["options"]["enabled"]:
         return {"status": status.DISABLED}
     granDelta = datetime.timedelta(
         minutes=flow["options"]["granularity"] + 3
     )  # set as N_A after it has not been analyzed for more than 3 minutes than it should have
     if ticTime + 2 * granDelta < AppConfig.getCurrentTime():
         return {"status": status.NA}
     return flowStatus
Ejemplo n.º 4
0
 def shouldSchedule(self, flow):
   granularity = flow["options"]["granularity"]
   lastExecution = self.lastExecutions[flow["gName"]]
   if lastExecution["status"] == status.NA:
     return True
   lastTicTime = lastExecution["ticTime"]
   if lastTicTime < AppConfig.getCurrentTime() - datetime.timedelta(minutes=2 * granularity):
     return True
   else:
     return False
Ejemplo n.º 5
0
    def sendEmail(self, component, body):
        emailConfig = IntegrationConfig.getEmailConfig()
        if emailConfig is None:
            return
        if not self.canSendEmail(component):
            return
        msg = MIMEText(body + "\ntime:" +
                       util.dateToTimeString(AppConfig.getCurrentTime()) +
                       "\ncomponent:" + component)

        msg['Subject'] = 'Mediation monitoring: ' + component
        msg['From'] = emailConfig["from"]
        msg['To'] = emailConfig["to"]

        s = smtplib.SMTP(emailConfig["smtpHostname"])
        s.login(emailConfig["login"], emailConfig["password"])
        s.send_message(msg)
        self.lastComponentEmailTime[component] = AppConfig.getCurrentTime()
        s.quit()
Ejemplo n.º 6
0
 def execute(self):
     try:
         logging.debug(" Running " + self.name + " on thread " +
                       str(threading.get_ident()))
         self._executeInternal()
         from common import SystemStatusManager
         SystemStatusManager.saveExecutorSuccessfulExecution(
             self.name, AppConfig.getCurrentTime())
     except Exception as e:
         logging.exception("Executing failed.")
     return
Ejemplo n.º 7
0
 def logStatusChangeEvent(flow, message, ticTime, newStatus):
     currentTime = AppConfig.getCurrentTime()
     obj = {
         "flowName": flow["name"],
         "lobName": flow["lobName"],
         "country": flow["country"],
         "time": currentTime,
         "message": message,
         "newStatus": newStatus,
         "ticTime": ticTime
     }
     logging.debug("flow: " + flow["gName"] + " message:" + message)
     mongo.events().insert_one(obj)
Ejemplo n.º 8
0
 def _analyzeFlow(self, flow, lastExecution):
   analyzer = FlowAnalyzer(flow)
   analyzer.run(AppConfig.getCurrentTime())
   previousStatus = lastExecution["status"]
   newStatus = analyzer.status
   self.statusManager.saveStatus(flow, previousStatus, newStatus, analyzer.difference, analyzer.ticTime)
Ejemplo n.º 9
0
 def __init__(self):
     super().__init__(DiscoverFlowsExecutor.name,
                      DiscoverFlowsExecutor.interval)
     self.toDate = AppConfig.getCurrentTime()
     self.fromDate = self.toDate - datetime.timedelta(days=7)
Ejemplo n.º 10
0
 def canSendEmail(self, component):
     lastTime = self.lastComponentEmailTime.get(component, None)
     if lastTime is None:
         return True
     return AppConfig.getCurrentTime() - lastTime > MIN_DELAY
Ejemplo n.º 11
0
def _statusIsExpired(time, maxSeconds=60 * 5):
  return AppConfig.getCurrentTime() - time > datetime.timedelta(seconds=maxSeconds)
Ejemplo n.º 12
0
 def _executeInternal(self):
     clusterStatus = self.analyzer.run()
     self.checkStatusChange(StatusManager.getClusterStatus(), clusterStatus)
     StatusManager.saveClusterStatus(clusterStatus,
                                     AppConfig.getCurrentTime())
Ejemplo n.º 13
0
def currentTime():
    return jsonify(
        {"currentTime": util.dateToTimeString(AppConfig.getCurrentTime())})