|
|
@@ -83,7 +83,7 @@
|
|
|
<select id="getExistenceAlarmsCount" resultType="java.lang.Long" parameterType="java.lang.String">
|
|
|
SELECT COUNT(*)
|
|
|
FROM sec_data_undelivered_monitor
|
|
|
- WHERE DATE_FORMAT(trigger_time, '%Y-%m') = #{month}
|
|
|
+ WHERE DATE_FORMAT(trigger_time, '%Y-%m') = #{month}
|
|
|
</select>
|
|
|
|
|
|
|
|
|
@@ -136,16 +136,16 @@
|
|
|
|
|
|
<!-- 6. 按系统统计列表(完整信息) -->
|
|
|
<select id="getSystemStatsDetail" resultType="cn.chinaunicom.omniFlowNetCompute.pojo.SystemStatsDetailVO">
|
|
|
- SELECT si.system_id as systemId,
|
|
|
- si.system_name as systemName,
|
|
|
- si.business_unit as businessUnit,
|
|
|
- si.vendor as vendor,
|
|
|
- si.contact_name as contactName,
|
|
|
- si.contact_phone as contactPhone,
|
|
|
+ SELECT si.system_id as systemId,
|
|
|
+ si.system_name as systemName,
|
|
|
+ si.business_unit as businessUnit,
|
|
|
+ si.vendor as vendor,
|
|
|
+ si.contact_name as contactName,
|
|
|
+ si.contact_phone as contactPhone,
|
|
|
|
|
|
-- 总告警数
|
|
|
COALESCE(pm.total, 0) + COALESCE(dbm.total, 0) + COALESCE(cm.total, 0) +
|
|
|
- COALESCE(ipm.total, 0) + COALESCE(tm.total, 0) + COALESCE(um.total, 0) as totalAlarms,
|
|
|
+ COALESCE(ipm.total, 0) + COALESCE(tm.total, 0) + COALESCE(um.total, 0) as totalAlarms,
|
|
|
|
|
|
-- 已办理数
|
|
|
COALESCE(pm.processed, 0) + COALESCE(dbm.processed, 0) + COALESCE(cm.processed, 0) +
|
|
|
@@ -156,19 +156,19 @@
|
|
|
COALESCE(ipm.untreated, 0) + COALESCE(tm.untreated, 0) + COALESCE(um.untreated, 0) as untreatedCount,
|
|
|
|
|
|
-- 内容类告警(数据库监控)
|
|
|
- COALESCE(dbm.total, 0) as thresholdAlarms,
|
|
|
+ COALESCE(dbm.total, 0) as thresholdAlarms,
|
|
|
|
|
|
-- 阈值类告警(权限+连接+异常IP+定时任务)
|
|
|
COALESCE(pm.total, 0) + COALESCE(cm.total, 0) +
|
|
|
- COALESCE(ipm.total, 0) + COALESCE(tm.total, 0) as contentAlarms,
|
|
|
+ COALESCE(ipm.total, 0) + COALESCE(tm.total, 0) as contentAlarms,
|
|
|
|
|
|
-- 各监控类型数量
|
|
|
- COALESCE(pm.total, 0) as permissionCount,
|
|
|
- COALESCE(dbm.total, 0) as dbCount,
|
|
|
- COALESCE(cm.total, 0) as connectCount,
|
|
|
- COALESCE(ipm.total, 0) as ipCount,
|
|
|
- COALESCE(tm.total, 0) as taskCount,
|
|
|
- COALESCE(um.total, 0) as existenceAlarms
|
|
|
+ COALESCE(pm.total, 0) as permissionCount,
|
|
|
+ COALESCE(dbm.total, 0) as dbCount,
|
|
|
+ COALESCE(cm.total, 0) as connectCount,
|
|
|
+ COALESCE(ipm.total, 0) as ipCount,
|
|
|
+ COALESCE(tm.total, 0) as taskCount,
|
|
|
+ COALESCE(um.total, 0) as existenceAlarms
|
|
|
|
|
|
FROM sec_system_info si
|
|
|
LEFT JOIN (SELECT system_id,
|
|
|
@@ -176,7 +176,7 @@
|
|
|
SUM(CASE WHEN alarm_status = 'processed' THEN 1 ELSE 0 END) as processed,
|
|
|
SUM(CASE WHEN alarm_status = 'untreated' THEN 1 ELSE 0 END) as untreated
|
|
|
FROM sec_data_undelivered_monitor
|
|
|
- WHERE DATE_FORMAT(trigger_time, '%Y-%m') = #{month}
|
|
|
+ WHERE DATE_FORMAT(trigger_time, '%Y-%m') = #{month}
|
|
|
GROUP BY system_id) um ON si.system_id = um.system_id
|
|
|
LEFT JOIN (SELECT system_id,
|
|
|
COUNT(*) as total,
|
|
|
@@ -229,7 +229,6 @@
|
|
|
</select>
|
|
|
|
|
|
|
|
|
-
|
|
|
<!-- 1.2 获取配置了内容类指标(cus_db_monitor)的系统列表 -->
|
|
|
<select id="getContentConfiguredSystems" resultType="java.lang.String">
|
|
|
SELECT DISTINCT system_id
|
|
|
@@ -240,51 +239,33 @@
|
|
|
<!-- 1.3 获取已配置内容类指标且7日内有发送数据的系统列表 -->
|
|
|
<select id="getContentHasDataSystems" resultType="java.lang.String">
|
|
|
SELECT DISTINCT system_id
|
|
|
- FROM cus_db_monitor
|
|
|
- WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- AND system_id IN (SELECT DISTINCT system_id
|
|
|
- FROM sec_system_metrics
|
|
|
- WHERE metric_code = 'cus_db_monitor')
|
|
|
+ FROM sec_data_undelivered_monitor
|
|
|
+ WHERE metric_name = '数据库监控'
|
|
|
</select>
|
|
|
|
|
|
<!-- 1.4 获取配置了阈值类指标的系统列表 -->
|
|
|
<select id="getThresholdConfiguredSystems" resultType="java.lang.String">
|
|
|
- SELECT DISTINCT system_id
|
|
|
- FROM sec_system_metrics
|
|
|
- WHERE metric_code IN (
|
|
|
- 'sec_permission_monitor',
|
|
|
- 'cus_internal_connect_monitor',
|
|
|
- 'cus_ip_abnormal_monitor',
|
|
|
- 'cus_task_exception_monitor'
|
|
|
- )
|
|
|
+ SELECT system_id
|
|
|
+ FROM (SELECT system_id
|
|
|
+ FROM sec_system_metrics
|
|
|
+ WHERE metric_code IN ('sec_permission_monitor',
|
|
|
+ 'cus_internal_connect_monitor',
|
|
|
+ 'cus_ip_abnormal_monitor',
|
|
|
+ 'cus_task_exception_monitor')
|
|
|
+ GROUP BY system_id
|
|
|
+ HAVING COUNT(DISTINCT metric_code) = 4) AS incomplete_systems;
|
|
|
</select>
|
|
|
|
|
|
<!-- 1.5 获取已配置阈值类指标且7日内有发送数据的系统列表 -->
|
|
|
<select id="getThresholdHasDataSystems" resultType="java.lang.String">
|
|
|
SELECT DISTINCT system_id
|
|
|
- FROM (SELECT system_id
|
|
|
- FROM sec_permission_monitor
|
|
|
- WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION
|
|
|
- SELECT system_id
|
|
|
- FROM cus_internal_connect_monitor
|
|
|
- WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION
|
|
|
- SELECT system_id
|
|
|
- FROM cus_ip_abnormal_monitor
|
|
|
- WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION
|
|
|
- SELECT system_id
|
|
|
- FROM cus_task_exception_monitor
|
|
|
- WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)) t
|
|
|
- WHERE system_id IN (SELECT DISTINCT system_id
|
|
|
- FROM sec_system_metrics
|
|
|
- WHERE metric_code IN (
|
|
|
- 'sec_permission_monitor',
|
|
|
- 'cus_internal_connect_monitor',
|
|
|
- 'cus_ip_abnormal_monitor',
|
|
|
- 'cus_task_exception_monitor'
|
|
|
- ))
|
|
|
+ FROM sec_data_undelivered_monitor
|
|
|
+ WHERE metric_name in (
|
|
|
+ '系统内部连接性监控',
|
|
|
+ '用户权限变更监控',
|
|
|
+ '异常ip访问监控',
|
|
|
+ '定时任务异常情况监控'
|
|
|
+ )
|
|
|
</select>
|
|
|
|
|
|
<!-- 2. 获取实时告警列表(按时间排序取20条) -->
|
|
|
@@ -433,9 +414,8 @@
|
|
|
</select>
|
|
|
|
|
|
<select id="getExistenceDailyTrend" resultType="cn.chinaunicom.omniFlowNetCompute.pojo.DateCountVO">
|
|
|
- SELECT
|
|
|
- DATE_FORMAT(trigger_time, '%m-%d') as date,
|
|
|
- COUNT(*) as count
|
|
|
+ SELECT DATE_FORMAT(trigger_time, '%m-%d') as date,
|
|
|
+ COUNT(*) as count
|
|
|
FROM sec_data_undelivered_monitor
|
|
|
WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
GROUP BY DATE_FORMAT(trigger_time, '%m-%d')
|
|
|
@@ -460,9 +440,8 @@
|
|
|
|
|
|
<!-- 4.4 获取7天内所有已送达的报送记录 -->
|
|
|
<select id="getDeliveryRecordsLast7Days" resultType="cn.chinaunicom.omniFlowNetCompute.pojo.SystemCategoryVO">
|
|
|
- SELECT
|
|
|
- system_id as systemId,
|
|
|
- COUNT(*) as contentCount
|
|
|
+ SELECT system_id as systemId,
|
|
|
+ COUNT(*) as contentCount
|
|
|
FROM sec_data_undelivered_monitor
|
|
|
WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
GROUP BY system_id
|
|
|
@@ -470,9 +449,8 @@
|
|
|
|
|
|
<!-- 获取所有系统信息 -->
|
|
|
<select id="getAllSystemInfos" resultType="cn.chinaunicom.omniFlowNetCompute.dto.SystemInfo">
|
|
|
- SELECT
|
|
|
- system_id as systemId,
|
|
|
- system_name as systemName
|
|
|
+ SELECT system_id as systemId,
|
|
|
+ system_name as systemName
|
|
|
FROM sec_system_info
|
|
|
WHERE del_flag = '0'
|
|
|
AND status = '1'
|
|
|
@@ -480,9 +458,8 @@
|
|
|
|
|
|
<!-- 获取7天内内容类告警数量(按系统分组) -->
|
|
|
<select id="getContentAlarmCountLast7Days" resultType="cn.chinaunicom.omniFlowNetCompute.pojo.SystemCategoryVO">
|
|
|
- SELECT
|
|
|
- system_id as systemId,
|
|
|
- COUNT(*) as contentCount
|
|
|
+ SELECT system_id as systemId,
|
|
|
+ COUNT(*) as contentCount
|
|
|
FROM cus_db_monitor
|
|
|
WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
GROUP BY system_id
|
|
|
@@ -490,19 +467,24 @@
|
|
|
|
|
|
<!-- 获取7天内阈值类告警数量(按系统分组) -->
|
|
|
<select id="getThresholdAlarmCountLast7Days" resultType="cn.chinaunicom.omniFlowNetCompute.pojo.SystemCategoryVO">
|
|
|
- SELECT
|
|
|
- system_id as systemId,
|
|
|
- COUNT(*) as thresholdCount
|
|
|
- FROM (
|
|
|
- SELECT system_id FROM sec_permission_monitor WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION ALL
|
|
|
- SELECT system_id FROM cus_internal_connect_monitor WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION ALL
|
|
|
- SELECT system_id FROM cus_ip_abnormal_monitor WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- UNION ALL
|
|
|
- SELECT system_id FROM cus_task_exception_monitor WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
- ) t
|
|
|
+ SELECT system_id as systemId,
|
|
|
+ COUNT(*) as thresholdCount
|
|
|
+ FROM (SELECT system_id
|
|
|
+ FROM sec_permission_monitor
|
|
|
+ WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ UNION ALL
|
|
|
+ SELECT system_id
|
|
|
+ FROM cus_internal_connect_monitor
|
|
|
+ WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ UNION ALL
|
|
|
+ SELECT system_id
|
|
|
+ FROM cus_ip_abnormal_monitor
|
|
|
+ WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
|
|
+ UNION ALL
|
|
|
+ SELECT system_id
|
|
|
+ FROM cus_task_exception_monitor
|
|
|
+ WHERE trigger_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)) t
|
|
|
GROUP BY system_id
|
|
|
</select>
|
|
|
-
|
|
|
+
|
|
|
</mapper>
|