Internet health from UniFi: Needs attention line and a 24 hour strip
Lint / JS (eslint) (push) Successful in 1m10s
Lint / Python (flake8) (push) Successful in 2m31s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m26s
Lint / Python (flake8) (pull_request) Successful in 1m4s
Test / Python Tests (pytest) (push) Successful in 1m13s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m0s
Test / Python Tests (pytest) (pull_request) Successful in 1m3s
Lint / JS (eslint) (push) Successful in 1m10s
Lint / Python (flake8) (push) Successful in 2m31s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m26s
Lint / Python (flake8) (pull_request) Successful in 1m4s
Test / Python Tests (pytest) (push) Successful in 1m13s
Lint / JS (eslint) (pull_request) Successful in 7s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 1m0s
Test / Python Tests (pytest) (pull_request) Successful in 1m3s
UniFi already rates the WAN every 5 minutes (fine, high latency, packet loss, down), the same timeline its Network app charts. The monitor now reads the last day of it from the dashboard API each cycle, read only, instead of Gandalf pinging on its own. - modem.wan_quality() turns the dashboard data into periods, drops and current service latencies; stored as monitor_state.wan_quality. - Needs attention: "Internet: packet loss in N of the last 12 five-minute periods" (2+ lossy periods, red), "high latency" (3+ bad periods, amber), and drops in the last hour. Stale copies are ignored. - WAN / Fiber panel: a 24 hour strip with a legend and latency now, also shown while the modem itself can't be read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f1355c4bd8
commit
6a717af3f2
11 files changed
+344
-8
No files matched your search
@@ -1018,3 +1018,33 @@ class TestSyncOpenTickets:
|
||||
mon._open_tickets_synced -= monitor.OPEN_TICKETS_SYNC_S + 1
|
||||
mon._sync_open_tickets()
|
||||
assert mon.tickets.open_tickets.call_count == 2
|
||||
|
||||
|
||||
class TestWanQualityCollection:
|
||||
def test_stores_the_timeline(self, mon, db):
|
||||
mon.unifi = MagicMock()
|
||||
mon.unifi.get_wan_dashboard.return_value = {'wan_history': {'wan_history_details': [
|
||||
{'network_group': 'WAN', 'health_history': [{'timestamp': 1000, 'high_latency': True}]}]}}
|
||||
mon._collect_wan_quality()
|
||||
key, value = db.set_state.call_args.args
|
||||
assert key == 'wan_quality'
|
||||
assert value['periods'] == [{'ts': 1.0, 'state': 'latency'}]
|
||||
|
||||
def test_unavailable_keeps_the_last_copy(self, mon, db):
|
||||
mon.unifi = MagicMock()
|
||||
mon.unifi.get_wan_dashboard.return_value = None
|
||||
mon._collect_wan_quality()
|
||||
assert not db.set_state.called
|
||||
|
||||
def test_client_reads_the_day(self):
|
||||
c = monitor.UnifiClient({'controller': 'https://udm.test', 'api_key': 'k'})
|
||||
c.session.get = MagicMock(return_value=MagicMock(json=lambda: {'wan_history': {}}))
|
||||
assert c.get_wan_dashboard() == {'wan_history': {}}
|
||||
url = c.session.get.call_args.args[0]
|
||||
assert url.endswith('/proxy/network/v2/api/site/default/aggregated-dashboard')
|
||||
assert c.session.get.call_args.kwargs['params'] == {'historySeconds': 86400}
|
||||
|
||||
def test_client_error_is_none(self):
|
||||
c = monitor.UnifiClient({'controller': 'https://udm.test', 'api_key': 'k'})
|
||||
c.session.get = MagicMock(side_effect=RuntimeError('boom'))
|
||||
assert c.get_wan_dashboard() is None
|
||||
Reference in new issue
Block a user