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值字符串为整数列表
///