예제 #1
0
파일: models.py 프로젝트: Laisky/kipp
    def start(self):
        d = {
            "command": self._command,
            "updated_at": utcnow(),
            "created_at": utcnow(),
            "status": RunStats.running,
        }
        if self._args:
            d.update({"arguments": self._args})

        r = self.mongo.create_documents(RUNSTATSMONITOR_COLLECTION_NAME, [d])
        self.task_id = r[0]
        return self.task_id
예제 #2
0
    def start(self):
        d = {
            'command': self._command,
            'updated_at': utcnow(),
            'created_at': utcnow(),
            'status': RunStats.running
        }
        if self._args:
            d.update({'arguments': self._args})

        r = self.mongo.create_documents(RUNSTATSMONITOR_COLLECTION_NAME, [d])
        self.task_id = r[0]
        return self.task_id
예제 #3
0
 def fail(self, err_msg):
     self.mongo.update_fields(RUNSTATSMONITOR_COLLECTION_NAME,
                              {'_id': self.task_id}, {
                                  'updated_at': utcnow(),
                                  'status': RunStats.failed,
                                  'err_msg': err_msg
                              })
예제 #4
0
def send_alert_email(msg):
    get_logger().info("try to send runner alert email...")
    if opt.debug:
        receivers = "*****@*****.**"
    else:
        receivers = ",".join(RECEIVERS)

    content = dedent("""
        time: {dt}
        command: {command}
        error: {err}
        """.format(dt=utcnow().strftime("%Y-%m-%dT%H:%M:%S"),
                   command=opt.command,
                   err=msg))

    opt.sender.send_email(
        mail_from="*****@*****.**",
        mail_to=receivers,
        subject="DATA Monitoring: Runner got critical error",
        content=content,
    )
예제 #5
0
파일: models.py 프로젝트: Laisky/kipp
 def fail(self, err_msg):
     self.mongo.update_fields(
         RUNSTATSMONITOR_COLLECTION_NAME,
         {"_id": self.task_id},
         {"updated_at": utcnow(), "status": RunStats.failed, "err_msg": err_msg},
     )
예제 #6
0
파일: models.py 프로젝트: Laisky/kipp
 def clean_logs_by_timedelta(self, timedelta):
     get_logger().info("clean_logs_by_timedelta for timedelta %s", timedelta)
     self.collection.remove({"updated_at": {"$lt": utcnow() + timedelta}})
예제 #7
0
파일: models.py 프로젝트: Laisky/kipp
 def success(self):
     self.mongo.update_fields(
         RUNSTATSMONITOR_COLLECTION_NAME,
         {"_id": self.task_id},
         {"updated_at": utcnow(), "status": RunStats.successed},
     )
예제 #8
0
 def clean_logs_by_timedelta(self, timedelta):
     get_logger().info('clean_logs_by_timedelta for timedelta %s',
                       timedelta)
     self.collection.remove({'updated_at': {'$lt': utcnow() + timedelta}})
예제 #9
0
 def success(self):
     self.mongo.update_fields(RUNSTATSMONITOR_COLLECTION_NAME,
                              {'_id': self.task_id}, {
                                  'updated_at': utcnow(),
                                  'status': RunStats.successed
                              })