Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 222bdb08ab | |||
| 8dd744b039 | |||
| 9e2be150b5 | |||
| ed5ba5c59e |
@@ -174,17 +174,26 @@ _PAGE_LIMIT = 200 # max events returned per request
|
|||||||
|
|
||||||
|
|
||||||
def _annotate_suppressions(events: list, suppressions: list) -> None:
|
def _annotate_suppressions(events: list, suppressions: list) -> None:
|
||||||
"""Annotate each event dict in-place with an is_suppressed bool."""
|
"""Annotate each event dict in-place with an is_suppressed bool.
|
||||||
|
|
||||||
|
Mirrors the suppression check order in monitor.py exactly:
|
||||||
|
interface_down → interface OR host
|
||||||
|
unifi_device_* → unifi_device
|
||||||
|
everything else → host
|
||||||
|
"""
|
||||||
for ev in events:
|
for ev in events:
|
||||||
sup_type = (
|
etype = ev.get('event_type', '')
|
||||||
'unifi_device' if ev.get('event_type') == 'unifi_device_offline'
|
name = ev.get('target_name', '')
|
||||||
else 'interface' if ev.get('event_type') == 'interface_down'
|
detail = ev.get('target_detail', '') or ''
|
||||||
else 'host'
|
if etype == 'interface_down':
|
||||||
)
|
ev['is_suppressed'] = (
|
||||||
ev['is_suppressed'] = db.check_suppressed(
|
db.check_suppressed(suppressions, 'interface', name, detail) or
|
||||||
suppressions, sup_type,
|
db.check_suppressed(suppressions, 'host', name)
|
||||||
ev.get('target_name', ''), ev.get('target_detail', '') or '',
|
)
|
||||||
)
|
elif etype == 'unifi_device_offline':
|
||||||
|
ev['is_suppressed'] = db.check_suppressed(suppressions, 'unifi_device', name, detail)
|
||||||
|
else:
|
||||||
|
ev['is_suppressed'] = db.check_suppressed(suppressions, 'host', name, detail)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
+1
-1
@@ -68,7 +68,7 @@ class DiagnosticsRunner:
|
|||||||
f' echo "=== ip_route ===";'
|
f' echo "=== ip_route ===";'
|
||||||
f' ip route show dev {q} 2>/dev/null;'
|
f' ip route show dev {q} 2>/dev/null;'
|
||||||
f' echo "=== dmesg ===";'
|
f' echo "=== dmesg ===";'
|
||||||
f' dmesg 2>/dev/null | grep {q} | tail -50;'
|
f' dmesg 2>/dev/null | grep -F -- {q} | tail -50;'
|
||||||
f' echo "=== lldpctl ===";'
|
f' echo "=== lldpctl ===";'
|
||||||
f' lldpctl 2>/dev/null || echo "lldpd not running";'
|
f' lldpctl 2>/dev/null || echo "lldpd not running";'
|
||||||
f' echo "=== end ==="'
|
f' echo "=== end ==="'
|
||||||
|
|||||||
+6
-6
@@ -734,7 +734,7 @@ class NetworkMonitor:
|
|||||||
f'Interface {iface} on {host} went link-down ({_now_utc()})',
|
f'Interface {iface} on {host} went link-down ({_now_utc()})',
|
||||||
)
|
)
|
||||||
if not sup and consec >= self.fail_thresh:
|
if not sup and consec >= self.fail_thresh:
|
||||||
self._ticket_interface(event_id, is_new, host, iface, consec)
|
self._ticket_interface(event_id, host, iface, consec)
|
||||||
|
|
||||||
if host_has_regression:
|
if host_has_regression:
|
||||||
hosts_with_regression.append(host)
|
hosts_with_regression.append(host)
|
||||||
@@ -771,7 +771,7 @@ class NetworkMonitor:
|
|||||||
db.resolve_event('cluster_network_issue', self.cluster_name, '')
|
db.resolve_event('cluster_network_issue', self.cluster_name, '')
|
||||||
|
|
||||||
def _ticket_interface(
|
def _ticket_interface(
|
||||||
self, event_id: int, is_new: bool, host: str, iface: str, consec: int
|
self, event_id: int, host: str, iface: str, consec: int
|
||||||
) -> None:
|
) -> None:
|
||||||
title = (
|
title = (
|
||||||
f'[{host}][auto][production][issue][network][single-node] '
|
f'[{host}][auto][production][issue][network][single-node] '
|
||||||
@@ -810,11 +810,11 @@ class NetworkMonitor:
|
|||||||
f'UniFi {name} ({d.get("ip","")}) offline ({_now_utc()})',
|
f'UniFi {name} ({d.get("ip","")}) offline ({_now_utc()})',
|
||||||
)
|
)
|
||||||
if not sup and consec >= self.fail_thresh:
|
if not sup and consec >= self.fail_thresh:
|
||||||
self._ticket_unifi(event_id, is_new, d)
|
self._ticket_unifi(event_id, d)
|
||||||
else:
|
else:
|
||||||
db.resolve_event('unifi_device_offline', name, d.get('type', ''))
|
db.resolve_event('unifi_device_offline', name, d.get('type', ''))
|
||||||
|
|
||||||
def _ticket_unifi(self, event_id: int, is_new: bool, device: dict) -> None:
|
def _ticket_unifi(self, event_id: int, device: dict) -> None:
|
||||||
name = device['name']
|
name = device['name']
|
||||||
title = (
|
title = (
|
||||||
f'[{name}][auto][production][issue][network][single-node] '
|
f'[{name}][auto][production][issue][network][single-node] '
|
||||||
@@ -850,12 +850,12 @@ class NetworkMonitor:
|
|||||||
f'Host {name} ({ip}) unreachable via ping ({_now_utc()})',
|
f'Host {name} ({ip}) unreachable via ping ({_now_utc()})',
|
||||||
)
|
)
|
||||||
if not sup and consec >= self.fail_thresh:
|
if not sup and consec >= self.fail_thresh:
|
||||||
self._ticket_unreachable(event_id, is_new, name, ip, consec)
|
self._ticket_unreachable(event_id, name, ip, consec)
|
||||||
else:
|
else:
|
||||||
db.resolve_event('host_unreachable', name, ip)
|
db.resolve_event('host_unreachable', name, ip)
|
||||||
|
|
||||||
def _ticket_unreachable(
|
def _ticket_unreachable(
|
||||||
self, event_id: int, is_new: bool, name: str, ip: str, consec: int
|
self, event_id: int, name: str, ip: str, consec: int
|
||||||
) -> None:
|
) -> None:
|
||||||
title = (
|
title = (
|
||||||
f'[{name}][auto][production][issue][network][single-node] '
|
f'[{name}][auto][production][issue][network][single-node] '
|
||||||
|
|||||||
@@ -324,6 +324,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="host-grid" id="host-grid">
|
<div class="host-grid" id="host-grid">
|
||||||
|
{%- set has_global_sup = suppressions | selectattr('target_type', 'equalto', 'all') | list | length > 0 -%}
|
||||||
{% for name, host in snapshot.hosts.items() %}
|
{% for name, host in snapshot.hosts.items() %}
|
||||||
{% set suppressed = suppressions | selectattr('target_name', 'equalto', name) | list %}
|
{% set suppressed = suppressions | selectattr('target_name', 'equalto', name) | list %}
|
||||||
<div class="host-card host-card-{{ host.status }}" data-host="{{ name }}">
|
<div class="host-card host-card-{{ host.status }}" data-host="{{ name }}">
|
||||||
@@ -331,7 +332,7 @@
|
|||||||
<div class="host-name-row">
|
<div class="host-name-row">
|
||||||
<span class="host-status-dot dot-{{ host.status }}"></span>
|
<span class="host-status-dot dot-{{ host.status }}"></span>
|
||||||
<span class="host-name">{{ name }}</span>
|
<span class="host-name">{{ name }}</span>
|
||||||
{% if suppressed %}
|
{% if suppressed or has_global_sup %}
|
||||||
<span class="badge-suppressed" title="Suppressed">🔕</span>
|
<span class="badge-suppressed" title="Suppressed">🔕</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user