|
@@ -20,8 +20,34 @@ select
|
|
`m`.`is_active_alarm` AS `is_active_alarm`,
|
|
`m`.`is_active_alarm` AS `is_active_alarm`,
|
|
floor((`m`.`alarm_count` / `m`.`months`)) AS `avg_alarm_count`,
|
|
floor((`m`.`alarm_count` / `m`.`months`)) AS `avg_alarm_count`,
|
|
if((`m`.`alarm_source` = '性能告警'),
|
|
if((`m`.`alarm_source` = '性能告警'),
|
|
- ((60 / 5) * 24 * days_in_month),
|
|
|
|
- ((60 * 2) * 24 * days_in_month)) AS `collection_frequency`
|
|
|
|
|
|
+ (((60 / 5) * 24) * `m`.`days_in_month`),
|
|
|
|
+ (((60 * 2) * 24) * `m`.`days_in_month`)) AS `collection_frequency`,
|
|
|
|
+ (case
|
|
|
|
+ when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
|
|
|
|
+ and (`m`.`update_time` >= `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
|
|
|
|
+ str_to_date(`m`.`thedvalue_b`,
|
|
|
|
+ '%Y%m%d%H%m'),
|
|
|
|
+ str_to_date(`m`.`thedvalue_e`,
|
|
|
|
+ '%Y%m%d%H%m'))
|
|
|
|
+ when ((`m`.`occur_time` > `m`.`thedvalue_b`)
|
|
|
|
+ and (`m`.`update_time` >= `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
|
|
|
|
+ str_to_date(`m`.`occur_time`,
|
|
|
|
+ '%Y%m%d%H%m'),
|
|
|
|
+ str_to_date(`m`.`thedvalue_e`,
|
|
|
|
+ '%Y%m%d%H%m'))
|
|
|
|
+ when ((`m`.`occur_time` <= `m`.`thedvalue_b`)
|
|
|
|
+ and (`m`.`update_time` < `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
|
|
|
|
+ str_to_date(`m`.`thedvalue_b`,
|
|
|
|
+ '%Y%m%d%H%m'),
|
|
|
|
+ str_to_date(`m`.`update_time`,
|
|
|
|
+ '%Y%m%d%H%m'))
|
|
|
|
+ when ((`m`.`occur_time` > `m`.`thedvalue_b`)
|
|
|
|
+ and (`m`.`update_time` < `m`.`thedvalue_e`)) then timestampdiff(MINUTE,
|
|
|
|
+ str_to_date(`m`.`occur_time`,
|
|
|
|
+ '%Y%m%d%H%m'),
|
|
|
|
+ str_to_date(`m`.`update_time`,
|
|
|
|
+ '%Y%m%d%H%m'))
|
|
|
|
+ end) AS `alarm_duration`
|
|
from
|
|
from
|
|
(
|
|
(
|
|
select
|
|
select
|
|
@@ -42,8 +68,12 @@ from
|
|
'MONTH' AS `dtype`,
|
|
'MONTH' AS `dtype`,
|
|
`dates`.`thedvalue` AS `thedvalue`,
|
|
`dates`.`thedvalue` AS `thedvalue`,
|
|
1 AS `is_active_alarm`,
|
|
1 AS `is_active_alarm`,
|
|
- alarm_source,
|
|
|
|
- DAYOFMONTH(last_day(DATE_ADD(MAKEDATE(`dates`.`thedvalue`/100, 1), INTERVAL MOD(`dates`.`thedvalue`,100)-1 MONTH))) days_in_month
|
|
|
|
|
|
+ `aa`.`alarm_source` AS `alarm_source`,
|
|
|
|
+ dayofmonth(last_day((makedate((`dates`.`thedvalue` / 100), 1) + interval ((`dates`.`thedvalue` % 100) - 1) month))) AS `days_in_month`,
|
|
|
|
+ date_format(str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d'), '%Y%m%d0000') AS `thedvalue_b`,
|
|
|
|
+ date_format((str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d') + interval 1 month), '%Y%m%d%H00') AS `thedvalue_e`,
|
|
|
|
+ date_format(`aa`.`occur_time`, '%Y%m%d%H%m') AS `occur_time`,
|
|
|
|
+ date_format(`aa`.`update_time`, '%Y%m%d%H%m') AS `update_time`
|
|
from
|
|
from
|
|
(`t_alm_active_alarm` `aa`
|
|
(`t_alm_active_alarm` `aa`
|
|
join (
|
|
join (
|
|
@@ -72,8 +102,12 @@ union all
|
|
'MONTH' AS `dtype`,
|
|
'MONTH' AS `dtype`,
|
|
`dates`.`thedvalue` AS `thedvalue`,
|
|
`dates`.`thedvalue` AS `thedvalue`,
|
|
0 AS `is_active_alarm`,
|
|
0 AS `is_active_alarm`,
|
|
- alarm_source,
|
|
|
|
- DAYOFMONTH(last_day(DATE_ADD(MAKEDATE(`dates`.`thedvalue`/100, 1), INTERVAL MOD(`dates`.`thedvalue`,100)-1 MONTH))) days_in_month
|
|
|
|
|
|
+ `ha`.`alarm_source` AS `alarm_source`,
|
|
|
|
+ dayofmonth(last_day((makedate((`dates`.`thedvalue` / 100), 1) + interval ((`dates`.`thedvalue` % 100) - 1) month))) AS `days_in_month`,
|
|
|
|
+ date_format(str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d'), '%Y%m%d0000') AS `thedvalue_b`,
|
|
|
|
+ date_format((str_to_date(concat(`dates`.`thedvalue`, '01'), '%Y%m%d%H%m') + interval 1 month), '%Y%m%d%H00') AS `thedvalue_e`,
|
|
|
|
+ date_format(`ha`.`occur_time`, '%Y%m%d%H%m') AS `occur_time`,
|
|
|
|
+ date_format(`ha`.`update_time`, '%Y%m%d%H%m') AS `update_time`
|
|
from
|
|
from
|
|
(`t_alm_history_alarm` `ha`
|
|
(`t_alm_history_alarm` `ha`
|
|
join (
|
|
join (
|