推送频率各个类型的警告各自限制频率
This commit is contained in:
@@ -376,7 +376,7 @@ class BaseFrameProcessorWorker(threading.Thread):
|
||||
|
||||
def _filter_duplicate_alerts(self, cam_id: int, alerts: list, current_time: float) -> list:
|
||||
"""
|
||||
过滤5秒内重复的告警
|
||||
过滤重复告警,支持不同 action 使用不同频率
|
||||
|
||||
Args:
|
||||
cam_id: 摄像头ID
|
||||
@@ -392,11 +392,16 @@ class BaseFrameProcessorWorker(threading.Thread):
|
||||
push_actions = []
|
||||
for alert in alerts:
|
||||
action = alert['action']
|
||||
|
||||
# 获取该 action 的推送间隔
|
||||
# 优先从配置中查找,没有则使用默认的 ALERT_PUSH_INTERVAL
|
||||
push_interval = constants.ALERT_PUSH_INTERVALS.get(action, ALERT_PUSH_INTERVAL)
|
||||
|
||||
last_push = self.last_alert_push_time[cam_id].get(action, 0)
|
||||
# 检查是否超过推送间隔
|
||||
if current_time - last_push >= ALERT_PUSH_INTERVAL:
|
||||
|
||||
# 使用各自的推送间隔进行检查
|
||||
if current_time - last_push >= push_interval:
|
||||
push_actions.append(action)
|
||||
# push_actions.append(get_alert_label(action))
|
||||
# 更新该action的最后推送时间
|
||||
self.last_alert_push_time[cam_id][action] = current_time
|
||||
|
||||
|
||||
Reference in New Issue
Block a user