From 64dcfcb8cc0ab0938cebc47148bccc1413fa0bf0 Mon Sep 17 00:00:00 2001 From: Kayck Matias <48569093+KayckMatias@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:15:46 -0300 Subject: [PATCH] Alert map location fix (#14380) * Update devices in alert-logs to init_select2 * Fix function ->exists * Add init_select2 to location filter in ports * fixes * Fixed alerts rule system not filtering by location --- LibreNMS/Alert/AlertUtil.php | 9 +++---- includes/html/common/alert-log.inc.php | 33 ++++---------------------- includes/html/pages/ports.inc.php | 19 +-------------- includes/html/pages/ports/list.inc.php | 3 +++ 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/LibreNMS/Alert/AlertUtil.php b/LibreNMS/Alert/AlertUtil.php index 3da6ab8fab..dadf54ef51 100644 --- a/LibreNMS/Alert/AlertUtil.php +++ b/LibreNMS/Alert/AlertUtil.php @@ -181,14 +181,15 @@ class AlertUtil LEFT JOIN alert_device_map d ON a.id=d.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND d.device_id = ?) LEFT JOIN alert_group_map g ON a.id=g.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND g.group_id IN (SELECT DISTINCT device_group_id FROM device_group_device WHERE device_id = ?)) LEFT JOIN alert_location_map l ON a.id=l.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND l.location_id IN (SELECT DISTINCT location_id FROM devices WHERE device_id = ?)) + LEFT JOIN devices ld ON l.location_id=ld.location_id AND ld.device_id = ? LEFT JOIN device_group_device dg ON g.group_id=dg.device_group_id AND dg.device_id = ? WHERE a.disabled = 0 AND ( - (d.device_id IS NULL AND g.group_id IS NULL) - OR (a.invert_map = 0 AND (d.device_id=? OR dg.device_id=?)) - OR (a.invert_map = 1 AND (d.device_id != ? OR d.device_id IS NULL) AND (dg.device_id != ? OR dg.device_id IS NULL)) + (d.device_id IS NULL AND g.group_id IS NULL AND l.location_id IS NULL) + OR (a.invert_map = 0 AND (d.device_id=? OR dg.device_id=? OR ld.device_id=?)) + OR (a.invert_map = 1 AND (d.device_id != ? OR d.device_id IS NULL) AND (dg.device_id != ? OR dg.device_id IS NULL) AND (ld.device_id != ? OR ld.device_id IS NULL)) )'; - $params = [$device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id]; + $params = [$device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id, $device_id]; return dbFetchRows($query, $params); } diff --git a/includes/html/common/alert-log.inc.php b/includes/html/common/alert-log.inc.php index 785c0664a3..313c3a87fa 100644 --- a/includes/html/common/alert-log.inc.php +++ b/includes/html/common/alert-log.inc.php @@ -54,13 +54,9 @@ $common_output[] = '