From aa835bbe47055b189729ba29843a54bf0e50f922 Mon Sep 17 00:00:00 2001 From: XuJiacheng Date: Tue, 10 Feb 2026 09:07:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0Kafka=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=E8=AD=A6?= =?UTF-8?q?=E6=8A=A5=E5=8A=9F=E8=83=BD=EF=BC=8C=E8=B0=83=E6=95=B4=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E6=95=B0=E6=8D=AE=E6=A3=80=E6=9F=A5=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=BA2=E5=88=86=E9=92=9F=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Models/TimerClass.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Models/TimerClass.cs b/Models/TimerClass.cs index 449b838..b96cd19 100644 --- a/Models/TimerClass.cs +++ b/Models/TimerClass.cs @@ -439,6 +439,7 @@ namespace AutoNotificatPhone.Models if (string.IsNullOrWhiteSpace(connectionString)) { logger.Error("Postgres配置缺失,无法检查Kafka入库心跳"); + ExecuteKafkaDbConnectionAlert(); return; } @@ -451,18 +452,19 @@ namespace AutoNotificatPhone.Models if (result == null || result == DBNull.Value) { - ExecuteKafkaInactiveAlert(); + ExecuteKafkaDbConnectionAlert(); return; } if (!long.TryParse(result.ToString(), out long lastTsMs)) { logger.Error("Kafka入库心跳ts_ms解析失败"); + ExecuteKafkaDbConnectionAlert(); return; } long nowMs = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); - if (nowMs - lastTsMs > TimeSpan.FromMinutes(5).TotalMilliseconds) + if (nowMs - lastTsMs > TimeSpan.FromMinutes(2).TotalMilliseconds) { ExecuteKafkaInactiveAlert(); } @@ -470,6 +472,7 @@ namespace AutoNotificatPhone.Models catch (Exception ex) { logger.Error($"Kafka入库心跳检查错误: {ex.Message}"); + ExecuteKafkaDbConnectionAlert(); } await Task.CompletedTask; } @@ -530,13 +533,26 @@ namespace AutoNotificatPhone.Models private void ExecuteKafkaInactiveAlert() { SendAlert( - smsContent: "[BLV运维提示] BLS数据库5分钟内入库数据为0。", - callContent: "BLV运维提示 BLS数据库5分钟内入库数据为0", + smsContent: "[BLV运维提示] BLS数据库1分钟内入库数据为0。", + callContent: "BLV运维提示 BLS数据库1分钟内入库数据为0", alertType: "BLS-数据库入库警报", extendedDeadline: true ); } + /// + /// 执行Kafka入库数据库连接失败警报 + /// + private void ExecuteKafkaDbConnectionAlert() + { + SendAlert( + smsContent: "[BLV运维提示] 数据库连接失败!", + callContent: "[BLV运维提示] 数据库连接失败", + alertType: "BLS-数据库连接警报", + extendedDeadline: true + ); + } + /// /// 解析CPU值字符串为整数列表 ///