Обновить hardwareAvailabilityReport.sql

This commit is contained in:
2026-06-30 22:30:27 +00:00
parent 0b1540238a
commit 63845ac273
+31 -1
View File
@@ -36,6 +36,7 @@ checks AS (
WHERE
-- Только мониторимые хосты
h.status = 0
and h.host not like '%WiMAX'
-- Исключаем оборудование, начинающееся на IRZ (любой регистр)
--AND UPPER(h.host) NOT LIKE 'IRZ%'
-- Период: май 2026 года (измените под свои даты)
@@ -124,6 +125,30 @@ grouped_intervals AS (
interval_id
),
-- Определение маршрутизатора (заглушка)
router as
(
select
m.host_name,
m.visible_name,
m.equipment_type,
v.object_number,
v.coordinates,
v.check_time,
v.next_check_time,
v.status
from grouped_intervals v
join
(
select host_name, visible_name, object_number, equipment_type, date_trunc('day', check_time) as time_start_dt
from grouped_intervals
where equipment_type like 'Маршрутизатор%'
group by 1,2,3,4,5
) m on m.object_number = v.object_number
where v.equipment_type like 'Видеокамера%'
and m.time_start_dt = date_trunc('day', v.check_time)
),
daily_stats AS (
select *,
case when unavailable_hours is not null then coalesce(extract('hour' from available_hours)::int,0) else 24 end AS a_h,
@@ -144,7 +169,12 @@ daily_stats AS (
sum(case when status = 1 then next_check_time - check_time else null end) AS available_hours,
sum(case when status = 0 then next_check_time - check_time else null end) AS unavailable_hours
--sum(next_check_time - check_time) AS all_hours
FROM grouped_intervals
FROM
(
select * from grouped_intervals where equipment_type not like 'Маршрутизатор%'
union all
select * from router
) g
GROUP BY
host_name,
visible_name,