def task_detect(task, task_config):
    """
    监控任务的检测，对任务是否已完成，任务完成质量的检测
    :param task: 任务信息
    :param task_config: 任务的配置信息
    :return: content，报警信息，若检测通过返回空字符串
    """
    content = ''
    queue_length = int(task[b'queue_length'])
    left = int(task[b'left'])
    if left < 0:
        content += f'Abnormal data:: left: {left}<br />'
    else:
        if left > 0:
            content += f'任务未完成:: {left} left<br />'
        if task_config.get(b'failure_rate_up') and task.get(b'failed'):
            failure_rate = float(task[b'failed']) / (queue_length - left)
            failure_rate_up = float(task_config[b'failure_rate_up'])
            if failure_rate > failure_rate_up:
                content += (
                    f'失败率超标:: {round(failure_rate, 2)} > {failure_rate_up}<br />'
                    )
        if task_config.get(b'avg_time_up') and task.get(b'crawl_time'):
            avg_time = float(task[b'crawl_time']) / (queue_length - left)
            avg_time_up = float(task_config[b'avg_time_up'])
            if avg_time > avg_time_up:
                content += f'爬取时长超标:: {round(avg_time, 2)} > {avg_time_up}'
    return content
