towerops/lib/towerops/preseem
Graham McIntire 6fd03ace16
feat: add comprehensive wireless client tracking and monitoring
Implements real-time wireless client monitoring with historical tracking,
LiveView UI, proactive alerting, and cross-browser e2e tests.

Phase 1: Historical Tracking
- Add TimescaleDB hypertable for wireless_client_readings
- Batch insert client metrics every 60 seconds from DevicePollerWorker
- 90-day retention with compression after 7 days
- Continuous aggregates for hourly (1 year) and daily (5 years) rollups

Phase 2: LiveView UI
- Add wireless tab to device detail page
- Real-time client list with PubSub updates
- Signal strength and SNR badges with 5-level thresholds
- Display MAC, IP, subscriber, TX/RX rates, distance, uptime
- Subscriber matching via device_subscriber_links
- Empty state handling

Phase 3: Proactive Alerting
- WirelessInsightWorker runs every 5 minutes via Oban cron
- 4 insight types with auto-resolution:
  * wireless_signal_weak: < -75 dBm (warning), < -85 dBm (critical)
  * wireless_snr_low: < 15 dB (warning), < 10 dB (critical)
  * wireless_ap_overloaded: > 50 clients (warning), > 75 clients (critical)
  * wireless_client_missing: expected subscribers not connecting
- Hysteresis thresholds prevent alert flapping
- Multi-organization isolation with proper deduplication

Code Quality:
- Refactored reload_current_tab_data to reduce cyclomatic complexity
- Combined double Enum.filter into single pass for efficiency
- Fixed length/1 comparison to use empty list check
- All Credo checks passing

Testing:
- 28 unit tests (ExUnit) - 100% passing
- 15 e2e tests (Playwright) - 100% passing across chromium/firefox/webkit
- Total: 73 tests, all passing

Files changed:
- lib/towerops/workers/wireless_insight_worker.ex (NEW)
- lib/towerops_web/live/device_live/show.ex (wireless tab + refactoring)
- lib/towerops_web/live/device_live/show.html.heex (wireless template)
- lib/towerops/snmp.ex (5 new query functions)
- lib/towerops/gaiia.ex (list_missing_subscribers)
- lib/towerops/preseem/insight.ex (5 new insight types)
- config/runtime.exs (Oban cron schedule)
- test/support/fixtures/snmp_fixtures.ex (NEW)
- test/towerops/workers/wireless_insight_worker_test.exs (NEW)
- test/towerops_web/live/device_live/show_test.exs (9 new tests)
- e2e/tests/wireless-clients.spec.ts (NEW - 15 cross-browser tests)
2026-03-10 09:57:12 -05:00
..
access_point.ex add preseem access points schema and migration 2026-02-12 17:11:36 -06:00
baseline.ex add preseem baseline and fleet intelligence computation 2026-02-13 08:40:04 -06:00
client.ex fix: Gaiia and Preseem sync bugs from API response mismatches 2026-02-15 12:23:47 -06:00
device_baseline.ex add preseem device baselines and fleet profiles schemas 2026-02-13 08:31:15 -06:00
device_matcher.ex add device matcher for preseem AP to towerops device linking 2026-02-12 17:52:54 -06:00
fleet_intelligence.ex test fix and preseem check fix 2026-02-13 09:42:39 -06:00
fleet_profile.ex add preseem device baselines and fleet profiles schemas 2026-02-13 08:31:15 -06:00
insight.ex feat: add comprehensive wireless client tracking and monitoring 2026-03-10 09:57:12 -05:00
insights.ex feat: command center dashboard with unified insights and contextual enrichment 2026-02-13 14:52:49 -06:00
subscriber_metric.ex add preseem subscriber metrics schema and migration 2026-02-12 17:12:53 -06:00
sync.ex feat: show human-readable sync status messages for integrations 2026-02-14 14:11:02 -06:00
sync_log.ex add preseem sync logs schema and migration 2026-02-12 17:12:19 -06:00