소스 검색

feat:添加分析任务

zhaohaipeng 1 년 전
부모
커밋
299e4ef6fb
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      feature_spark_monitor.py

+ 5 - 0
feature_spark_monitor.py

@@ -119,6 +119,11 @@ def _main():
     # 获取最近七小时的Spark任务
     hours_7_early = int((datetime.now() - timedelta(hours=7)).timestamp()) * 1000
     result = yarn_client.get_apps(finished_time_begin=hours_7_early)
+
+    if len(result) == 0:
+        print("未获取到数据,跳过本次告警")
+        return
+
     result = [
         {**item, 'name': item['name'].split(":")[1].strip()}
         for item in result