Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| faa0707f79 | |||
| 9c52e4ad1a | |||
| 156ef97667 | |||
| 2f74266bd9 | |||
| 222bdb08ab |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true
|
||||||
|
},
|
||||||
|
"globals": {
|
||||||
|
"lt": "readonly",
|
||||||
|
"GANDALF_CONFIG": "readonly",
|
||||||
|
"CSS": "readonly"
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"no-undef": "error",
|
||||||
|
"no-unused-vars": ["warn", { "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }],
|
||||||
|
"no-console": "off",
|
||||||
|
"eqeqeq": ["error", "always", { "null": "ignore" }]
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2021,
|
||||||
|
"sourceType": "script"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -970,6 +970,7 @@ class NetworkMonitor:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f'Monitor loop error: {e}', exc_info=True)
|
logger.error(f'Monitor loop error: {e}', exc_info=True)
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
continue
|
||||||
|
|
||||||
time.sleep(self.poll_interval)
|
time.sleep(self.poll_interval)
|
||||||
|
|
||||||
|
|||||||
@@ -469,7 +469,7 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
<script>
|
<script>
|
||||||
// Start auto-refresh using saved settings interval (default 30 s)
|
// Start auto-refresh using saved settings interval (default 30 s)
|
||||||
const _savedInterval = (window.gandalfSettings && window.gandalfSettings.refreshInterval) || 30;
|
const _savedInterval = window.gandalfSettings?.refreshInterval ?? 30;
|
||||||
if (_savedInterval > 0) lt.autoRefresh.start(refreshAll, _savedInterval * 1000);
|
if (_savedInterval > 0) lt.autoRefresh.start(refreshAll, _savedInterval * 1000);
|
||||||
|
|
||||||
// When settings change, restart auto-refresh with new interval
|
// When settings change, restart auto-refresh with new interval
|
||||||
|
|||||||
@@ -473,7 +473,7 @@ async function loadInspector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadInspector();
|
loadInspector();
|
||||||
const _inspInterval = (window.gandalfSettings && window.gandalfSettings.refreshInterval) || 60;
|
const _inspInterval = window.gandalfSettings?.refreshInterval ?? 60;
|
||||||
if (_inspInterval > 0) lt.autoRefresh.start(loadInspector, Math.max(_inspInterval, 15) * 1000);
|
if (_inspInterval > 0) lt.autoRefresh.start(loadInspector, Math.max(_inspInterval, 15) * 1000);
|
||||||
|
|
||||||
window.onGandalfSettingsChanged = function(s) {
|
window.onGandalfSettingsChanged = function(s) {
|
||||||
|
|||||||
@@ -571,7 +571,7 @@ async function loadLinks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadLinks();
|
loadLinks();
|
||||||
const _linksInterval = (window.gandalfSettings && window.gandalfSettings.refreshInterval) || 60;
|
const _linksInterval = window.gandalfSettings?.refreshInterval ?? 60;
|
||||||
if (_linksInterval > 0) lt.autoRefresh.start(loadLinks, Math.max(_linksInterval, 15) * 1000);
|
if (_linksInterval > 0) lt.autoRefresh.start(loadLinks, Math.max(_linksInterval, 15) * 1000);
|
||||||
|
|
||||||
window.onGandalfSettingsChanged = function(s) {
|
window.onGandalfSettingsChanged = function(s) {
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ class TestBuildSshCommand:
|
|||||||
cmd = DiagnosticsRunner.build_ssh_command('10.0.0.1', 'eth0')
|
cmd = DiagnosticsRunner.build_ssh_command('10.0.0.1', 'eth0')
|
||||||
assert 'ethtool' in cmd
|
assert 'ethtool' in cmd
|
||||||
|
|
||||||
|
def test_dmesg_uses_fixed_string_grep(self):
|
||||||
|
# grep -F prevents iface names with dots (e.g. eth0.1) being treated as
|
||||||
|
# regex wildcards; -- prevents leading - from being parsed as a flag
|
||||||
|
cmd = DiagnosticsRunner.build_ssh_command('10.0.0.1', 'eth0')
|
||||||
|
assert 'grep -F --' in cmd
|
||||||
|
|
||||||
|
|
||||||
# ── parse_output ─────────────────────────────────────────────────────────────
|
# ── parse_output ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user