Commit graph

2198 commits

Author SHA1 Message Date
cd6603873a fix: update Phoenix.PubSub.Redis configuration for 3.1.0 compatibility (#197)
The recent dependency update to phoenix_pubsub_redis 3.1.0 introduced
breaking changes in the configuration API. The new version no longer
accepts connection options at the top level - they must be nested in
:redis_opts.

Changes:
- Move Redix connection options into :redis_opts keyword list
- Keep only :node_name at top level per v3.1.0 requirements
- Maintains all resilience settings (timeouts, backoff, keepalive)

Before (invalid for v3.1.0):
  [node_name: node(), host: "...", port: 6379, timeout: 5000, ...]

After (valid for v3.1.0):
  [node_name: node(), redis_opts: [host: "...", port: 6379, timeout: 5000, ...]]

This fixes the production crash with error:
  NimbleOptions.ValidationError: unknown options [:timeout, :backoff_initial,
  :backoff_max, :exit_on_disconnection, :sync_connect]

Related: commit 0399b30d (Update Elixir dependencies)

Reviewed-on: graham/towerops-web#197
2026-03-27 17:31:25 -05:00
39039a4455 fix: remove stale oban hex repo references from mix.lock (#195)
The previous dependency update left mix.lock with references to the
"oban" hex repository for vendored packages (oban_pro, oban_web, oban_met).
This caused production deployment failures with error:
"Unknown repository 'oban', add new repositories with the mix hex.repo add task"

Since these packages are vendored from vendor/ directory, they should not
have hex repo references in the lock file. Removed the hex entries entirely
and regenerated the lock file with only the vendored path dependencies.

Reviewed-on: graham/towerops-web#195
2026-03-27 17:18:48 -05:00
0399b30d21 Update Elixir dependencies (#194)
Updated packages:
- bandit: 1.10.3 → 1.10.4
- phoenix_live_view: 1.1.27 → 1.1.28
- phoenix_pubsub_redis: 3.0.1 → 3.1.0
- oban_met: 1.0.6 → 1.1.0 (vendored)
- oban_web: 2.11.8 → 2.12.1 (vendored)

All tests passing (8923 tests, 0 failures).

Reviewed-on: graham/towerops-web#194
2026-03-27 17:13:12 -05:00
30248504e2 optimize-slow-tests (#193)
Reviewed-on: graham/towerops-web#193
2026-03-27 17:05:29 -05:00
c4e301a84c fix: address code review findings - memory leaks and redundant queries (#192)
Fixed 5 critical issues from code review:

1. **GlobalSearchTrigger hook listener leak**
   - Added destroyed() callback to remove click listener
   - Prevents memory leak on LiveView unmount

2. **NetworkMap/WeathermapViewer hook listener leaks**
   - Store zoom/fit button handlers as properties
   - Remove DOM event listeners in destroyed() callback
   - Fixes leak on every LiveView remount

3. **SitesMap uses undocumented window.liveSocket.execJS**
   - Changed to proper LiveView pattern using pushEvent
   - Attach listener via Leaflet's popupopen event

4. **handle_info(:refresh_data) double DB fetch**
   - Removed redundant Devices.get_device call
   - Reuse device from assign_base_data

5. **Redundant DB queries in DeviceLive.Show overview**
   - Changed load_sensor_chart_data to accept snmp_device
   - Changed load_overall_traffic_chart_data to accept snmp_device
   - Eliminated 4 redundant Snmp.get_device_with_associations calls

Also removed unused functions:
- load_equipment_data/2
- reload_active_tab_data/1
- assign_subscriber_impact/1

Note: DeviceLive.Show module size (2252 lines) is acknowledged but
deferred as it requires larger architectural refactoring.

Reviewed-on: graham/towerops-web#192
2026-03-27 16:34:42 -05:00
7606efc635 fix: use docker-container buildx driver to resolve mount permission errors (#191)
The production deployment was failing with "operation not permitted" errors
when BuildKit tried to perform bind mounts during Docker image builds.

Root cause:
- The workflow starts Docker with --storage-driver=vfs for unprivileged runners
- VFS storage driver doesn't support the advanced mount operations needed by BuildKit
- The Dockerfile uses --mount=type=cache for build performance
- Using buildx driver=docker tried to use the daemon's VFS storage directly

Solution:
- Switch to driver=docker-container which runs BuildKit in an isolated container
- This container has its own storage layer that properly supports BuildKit features
- BuildKit container uses overlay2 internally regardless of host storage driver

This is the recommended approach for CI/CD environments with storage limitations.

Reviewed-on: graham/towerops-web#191
2026-03-27 13:44:22 -05:00
c7a95164e3 fix snmp handling to be more like librenms (#190)
Reviewed-on: graham/towerops-web#190
2026-03-27 13:37:27 -05:00
3f08fd42b6 fix: handle alert_changed message in DashboardLive (#189)
Fixes FunctionClauseError when DashboardLive receives {:alert_changed, org_id}
message broadcast by user_auth hooks.

The user_auth module subscribes all LiveViews to the
"organization:#{org_id}:alerts" topic and broadcasts {:alert_changed, org_id}
messages when alerts are created or resolved. DashboardLive was missing a
handle_info/2 clause to handle this message format, causing crashes in
production.

Solution:
- Added handle_info/2 clause for {:alert_changed, _org_id} message
- Uses existing debounced reload pattern to update dashboard
- Added test to verify message is handled without crashing
- Updated both technical and user-facing changelogs

All tests pass. The fix follows the same pattern used in AlertLive.Index
and DeviceLive.Show.

Reviewed-on: graham/towerops-web#189
2026-03-27 13:26:39 -05:00
a9c2f8e5e5 fix/findings-medium-priority (#188)
Reviewed-on: graham/towerops-web#188
2026-03-27 12:31:53 -05:00
0bc6407c3f feature/entity-physical-inventory (#187)
Reviewed-on: graham/towerops-web#187
2026-03-27 10:48:50 -05:00
8a58c7c238 feat: implement mempools (memory pools) feature for SNMP monitoring (#184)
Add complete memory pool monitoring using HOST-RESOURCES-MIB.
Tracks RAM/swap usage with historical data and real-time updates.

- Add Mempool and MempoolReading schemas
- Integrate discovery and polling with concurrent Task.async_stream
- Add 7 context API functions for querying mempools
- 24 new tests, all 8754 tests passing (0 failures)

Implements C1 from findings_librenms.md

Reviewed-on: graham/towerops-web#184
2026-03-26 17:07:43 -05:00
a8e43b38d6 feat: implement batched SNMP GET for multi-OID requests (#183)
Replace sequential multi-GET with true batched SNMP GET support.
Previously, Client.get_multiple/2 sent N individual SNMP GET PDUs
for N OIDs. Now sends a single PDU with multiple varbinds, reducing
network round-trips by ~80% for multi-OID operations.

Implementation:
- Add get_multiple/3 callback to SnmpBehaviour
- Implement batched GET in Manager using PDU.build_get_request_multi/2
- Update Client.get_multiple/2 to use batched GET with sequential fallback
- Return map format %{oid => {type, value}} for batched results
- Convert to ordered list for backward compatibility
- Handle SNMP exceptions (noSuchObject, noSuchInstance) in result map

Testing:
- Update all test mocks to use get_multiple expectations
- Add individual get stubs for categorize_device_speed and optional fields
- 2249/2251 tests passing (99.87%)

This addresses F1 from LibreNMS feature parity analysis:
"Replace sequential multi-get with batched GET support."

Impact:
- Discovery system info (6 OIDs): 1 SNMP request instead of 6
- Storage polling (3 OIDs/entry): 1 request per entry instead of 3
- Network round-trips reduced by ~80% for all get_multiple operations

Reviewed-on: graham/towerops-web#183
2026-03-26 16:37:34 -05:00
c7a236e504 reliability-audit-fixes (#181)
Reviewed-on: graham/towerops-web#181
2026-03-26 14:10:36 -05:00
0f3f16d443 fix: only send SNMP jobs to agent for SNMP-enabled devices (#180)
- Check device.snmp_enabled before creating discovery/polling jobs
- Also check snmp_enabled for MikroTik jobs
- Prevents agent from attempting SNMP operations on ping-only devices
- Fixes "Agent collected 0 OIDs" errors for devices without SNMP

Reviewed-on: graham/towerops-web#180
2026-03-26 11:10:27 -05:00
6f6f1757ea fix: handle existing index in deduplicate_discovery_checks migration (#179)
- Drop index if exists before creating to handle manual creation
- Prevents duplicate_table error when index was created manually

Reviewed-on: graham/towerops-web#179
2026-03-26 11:01:53 -05:00
a9e82779e7 fix: make deduplicate_discovery_checks migration production-safe (#178)
- Add @disable_ddl_transaction and @disable_migration_lock for concurrent index
- Increase statement_timeout to 10min for DELETE operation on large tables
- Use concurrently: true on index creation to avoid table locks
- Refactor detect_airfiber_counter_overrides to fix credo nesting warning
- Prevents timeout errors in production deployment

Reviewed-on: graham/towerops-web#178
2026-03-26 10:39:09 -05:00
11f9c4450c done i think (#177)
Reviewed-on: graham/towerops-web#177
2026-03-26 10:23:26 -05:00
06ca0390f0 ui: hide weathermap navigation links (#174)
Commented out weathermap navigation in sidebar and mobile menu.
Feature not ready for production use yet.

Files: lib/towerops_web/components/layouts.ex
Changelog: CHANGELOG.txt

Reviewed-on: graham/towerops-web#174
2026-03-25 16:40:11 -05:00
7656052395 update deps (#173)
Reviewed-on: graham/towerops-web#173
2026-03-25 16:35:12 -05:00
a97340873f feat: Add network weathermap with real-time utilization visualization (#172)
- Create WeathermapLive module at /weathermap with 60s auto-refresh
- Extend Topology.get_topology_for_weathermap with bandwidth utilization data
- Add WeathermapViewer JavaScript hook with color-coded edges:
  * Green (0-30%) → Yellow (30-60%) → Orange (60-80%) → Red (80%+)
- Display throughput/capacity labels on edges (e.g., '847 Mbps / 1 Gbps')
- Add utilization stats dashboard with link count by usage level
- Support full-screen mode for NOC displays
- Integrate with existing dark mode and responsive design
- Add navigation links in sidebar and mobile menu

Technical implementation:
- Leverages existing Capacity module for interface utilization calculations
- Extends topology edges with utilization_level, utilization_pct, throughput_bps
- Builds on NetworkMapLive foundation with enhanced edge styling
- Auto-refresh via Phoenix PubSub and 60s timer
- Filter support for high/critical utilization links

Reviewed-on: graham/towerops-web#172
2026-03-25 16:26:11 -05:00
f442c59ad0 fix/ping-monitoring-without-snmp (#171)
Reviewed-on: graham/towerops-web#171
2026-03-25 16:01:05 -05:00
3d5c74e7ae fix: correct AirFiber proprietary OID mapping and v1-only device support (#170)
Root cause: AF11X devices only support SNMPv1, IF-MIB eth0 counters
return zero, and air0 32-bit counters wrap too fast for backhaul speeds.

Fixes:
- Use correct UBNT-AirFIBER-MIB OID indices from MIB SEQUENCE definition:
  .7.1 = rxOctetsOK (inbound), .6.1 = txOctetsOK (outbound)
  .10.1 = rxErroredFrames, .11.1 = txErroredFrames
- Detect AirFiber devices by sysDescr instead of SNMP probing (v1 devices
  cannot return Counter64 via standard probe queries)
- Force SNMPv1 for AirFiber proprietary queries
- Apply proprietary counters to all real interfaces (not just eth0)

Verified against live AF11X at 10.250.1.90:
- IF-MIB eth0 returns zero counters
- Proprietary .6.1/.7.1 show real traffic (3.75TB rx / 43TB tx)

Reviewed-on: graham/towerops-web#170
2026-03-25 15:02:45 -05:00
ce682991fe fix: correct AirFiber proprietary OID mapping and v1-only device support (#169)
Root cause: AF11X devices only support SNMPv1, IF-MIB eth0 counters
return zero, and air0 32-bit counters wrap too fast for backhaul speeds.

Fixes:
- Use correct UBNT-AirFIBER-MIB OID indices from MIB SEQUENCE definition:
  .7.1 = rxOctetsOK (inbound), .6.1 = txOctetsOK (outbound)
  .10.1 = rxErroredFrames, .11.1 = txErroredFrames
- Detect AirFiber devices by sysDescr instead of SNMP probing (v1 devices
  cannot return Counter64 via standard probe queries)
- Force SNMPv1 for AirFiber proprietary queries
- Apply proprietary counters to all real interfaces (not just eth0)

Verified against live AF11X at 10.250.1.90:
- IF-MIB eth0 returns zero counters
- Proprietary .6.1/.7.1 show real traffic (3.75TB rx / 43TB tx)

Reviewed-on: graham/towerops-web#169
2026-03-25 14:30:13 -05:00
de455d1cf4 fix: improve bandwidth counter handling to match LibreNMS approach (#168)
- Clamp negative counter deltas to zero instead of attempting 32-bit wrap
  correction (matches LibreNMS behavior — wraps are indistinguishable from
  HC counter resets, so discard the ambiguous data point)
- Add rate sanity check: discard values exceeding 400 Gbps as counter anomalies
- Add 4-byte binary decoding for 32-bit SNMP counters in decode_snmp_value
- Track HC vs standard counter usage per interface stat (is_hc field)
- Add migration for is_hc column on snmp_interface_stats
- Update tests to match new clamping behavior

Reviewed-on: graham/towerops-web#168
2026-03-25 13:33:45 -05:00
d75eeb5389 fix: add missing foreign key indexes for performance and referential integrity (#167)
Missing indexes detected on 7 foreign key columns:
- on_call_overrides.user_id
- on_call_layer_members.user_id
- site_outages.site_id
- escalation_targets.user_id
- notification_digests.organization_id
- on_call_notifications.user_id
- alerts.site_outage_id (already existed, skipped)

Without indexes, PostgreSQL must perform sequential scans for:
- Referential integrity checks on DELETE/UPDATE of parent rows
- JOIN operations on these columns
- Can cause lock contention and slow queries

Indexes created with CONCURRENTLY option to avoid blocking production
tables during deployment.

Migration uses @disable_ddl_transaction and @disable_migration_lock
to ensure indexes are built without holding locks.

Reviewed-on: graham/towerops-web#167
2026-03-25 13:04:48 -05:00
dba9a286d3 fix: respect device SNMP version for agent polling instead of forcing v2c (#166)
Devices configured as SNMPv1 were being force-upgraded to v2c for agent
polling, which breaks devices that don't support v2c (returning empty
OID responses and no throughput/capacity data).

Reviewed-on: graham/towerops-web#166
2026-03-25 12:52:24 -05:00
68354af021 fix: prevent Oban index bloat by reindexing primary key and scheduling index (#165)
Severe index bloat discovered on oban_jobs:
- oban_jobs_pkey: 82.2 bloat ratio, 3.2GB waste
- oban_jobs_state_queue_priority_scheduled_at_id_index: 216.8 bloat, 7.9GB waste

Root cause: High DELETE churn from aggressive Pruner config (10k jobs/sec)
causes PostgreSQL VACUUM to leave dead index entries. VACUUM only marks space
as reusable but cannot shrink indexes.

The Oban Reindexer plugin was only reindexing args_index and meta_index by
default, missing the primary key and main scheduling index.

Solution: Explicitly configure Reindexer to include all high-churn indexes:
- oban_jobs_pkey (primary key, used by all queries)
- oban_jobs_state_queue_priority_scheduled_at_id_index (job scheduling)
- oban_jobs_args_index (default, GIN index)
- oban_jobs_meta_index (default, GIN index)

Daily REINDEX CONCURRENTLY at 2 AM will prevent future bloat accumulation.

Manual immediate reindex required to reclaim 11GB:
  REINDEX INDEX CONCURRENTLY oban_jobs_pkey;
  REINDEX INDEX CONCURRENTLY oban_jobs_state_queue_priority_scheduled_at_id_index;

Reviewed-on: graham/towerops-web#165
2026-03-25 12:36:10 -05:00
94fd8780de fix/counter-wrap-detection (#164)
Reviewed-on: graham/towerops-web#164
2026-03-25 12:25:13 -05:00
86db804729 fix: correct 32-bit SNMP counter wrap detection for all traffic calculations (#163)
The wrap detection only applied the 2^32 correction when the previous
counter was in the upper half of the 32-bit range (> 2^31). On fast
links, counters wrap regardless of where in the range they sit. Three
graph rendering paths had no wrap detection at all, just max(0).

Consolidated all bps calculations into a single public
Capacity.calculate_bps/3 that always tries the 2^32 correction for
negative deltas. 64-bit HC counter resets remain clamped to zero since
the corrected delta stays negative.

Reviewed-on: graham/towerops-web#163
2026-03-25 11:03:43 -05:00
e68ac74e90 chore(deps): update node.js to v22.22.2 (#147)
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [node](https://nodejs.org) ([source](https://github.com/nodejs/node)) | minor | `22.17.1` → `22.22.2` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/9) for more information.

>  **Important**
>
> Release Notes retrieval for this PR were skipped because no github.com credentials were available.
> If you are self-hosted, please see [this instruction](https://github.com/renovatebot/renovate/blob/master/docs/usage/examples/self-hosting.md#githubcom-token-for-release-notes).

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43Ny44IiwidXBkYXRlZEluVmVyIjoiNDMuNzcuOCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Reviewed-on: graham/towerops-web#147
2026-03-25 10:32:35 -05:00
4b6538df8e fix: remove duplicate handle_info and schedule_cleanup function definitions in AgentCache (#162)
Removed duplicate function definitions that were causing compile warnings:
- handle_info(:cleanup_expired, state) was defined twice (lines 94 and 110)
- schedule_cleanup/0 was defined twice (lines 105 and 121)

The duplicate definitions at lines 110-124 were exact copies and have been removed.

Reviewed-on: graham/towerops-web#162
2026-03-25 10:18:11 -05:00
f0fe3c025c fix: recover correct bandwidth rate when 32-bit SNMP counters wrap (#161)
Standard ifInOctets/ifOutOctets are 32-bit counters that wrap around
4,294,967,296 bytes (~4.3 GB). At 1 Gbps this wraps every ~34 seconds,
causing brief drops to 0 bps in traffic charts and capacity reports.

When prev > 2^31 and delta is negative, add 2^32 to recover the correct
rate. If the result is still negative (HC 64-bit counter after reboot),
clamp to 0. Small-value decreases (prev < 2^31) continue to clamp to 0
since they cannot be real 32-bit wraps.

Fixes both capacity.ex (utilization reports) and device_live/show.ex
(per-device traffic chart).

Reviewed-on: graham/towerops-web#161
2026-03-25 09:52:15 -05:00
53c8f495d1 fix/critical-logic-and-memory-bugs (#159)
Reviewed-on: graham/towerops-web#159
2026-03-25 09:50:21 -05:00
cc3533ce93 update more (#146)
Reviewed-on: graham/towerops-web#146
2026-03-24 16:32:09 -05:00
3e6902d5b9 add doc (#145)
Reviewed-on: graham/towerops-web#145
2026-03-24 15:36:29 -05:00
3f0f6e7d5f feat: add per-organization data retention with 1-year default (#144)
Add data_retention_days field to organizations (default 365, range 30-730).
DataRetentionWorker runs nightly at 1 AM to purge expired time-series data
across 8 tables, respecting each org's retention setting.

TimescaleDB global retention bumped from 90 to 730 days as safety net.
Resolved alerts are cleaned up; unresolved alerts kept regardless of age.

Reviewed-on: graham/towerops-web#144
2026-03-24 15:30:43 -05:00
9d7dfe0060 fix/agent-reload-reconnect (#143)
Reviewed-on: graham/towerops-web#143
2026-03-24 13:01:02 -05:00
303c64ceae fix: set last_heartbeat_db_update on agent join to fix offline detection (#142)
When an agent joins, we update last_seen_at in the database but don't set
last_heartbeat_db_update in the socket. This causes the heartbeat throttling
logic to be out of sync:

- On join: DB updated, but last_heartbeat_db_update not set (nil)
- First heartbeat: Updates DB again because last_heartbeat_db_update is nil
- Subsequent heartbeats: Check if >30s since last DB update
- Problem: last_heartbeat_db_update tracks the first heartbeat, not the join DB update

This manifests when Phoenix recompiles during development - the channel process
continues running with old socket assigns, and if last_heartbeat_db_update is
recent, heartbeats won't update the DB. After 10+ minutes without DB updates,
the agent appears offline even though it's still connected.

Fix: Set last_heartbeat_db_update when we update the DB on join, so the
throttling logic accurately tracks the most recent DB update.

Reviewed-on: graham/towerops-web#142
2026-03-24 12:19:13 -05:00
56643dde86 fix: use correct struct field names for Check protobuf (#141)
The Check protobuf has a `oneof config` field which generates separate
fields in the Elixir struct: :http, :tcp, :dns, :ssl. However,
check_type_config/2 was returning [config: {:http, ...}] which doesn't
match the struct definition, causing a KeyError crash in
build_and_push_check_jobs/1.

This bug was originally fixed in e0a74e2f but was accidentally
reintroduced in f703e61b when attempting to use "tagged tuple config".

Fix: Return field-specific keyword lists (e.g., [http: %HttpCheckConfig{}])
instead of [config: {:http, ...}].

Also added comprehensive test that creates all 4 check types and verifies
no KeyError crash occurs when sending check jobs to agent.

Reviewed-on: graham/towerops-web#141
2026-03-24 12:04:48 -05:00
f703e61b12 fix: code quality improvements and test reliability (#139)
Various code quality improvements and fixes:

- Settings: return error instead of auto-creating unknown settings
- PagerDuty: proper backoff timing with to_timeout()
- Gaiia sync: remove unnecessary transaction wrapper
- HTTP/UISP: simplify test plug setup
- Agent channel: tagged tuple config for check types
- SNMP: fix Task.yield/shutdown pattern, remove stale preload
- Discovery: simplify error handling
- Tests: bump executor timeouts for CI reliability
- Dockerfile: remove unnecessary --force compile
- Renovate/CI: config cleanup

Split from #135.

Reviewed-on: graham/towerops-web#139
2026-03-24 09:12:59 -05:00
cb9becae4e fix: traffic graph invisible — scale dominated by capacity lines (#140)
## Problem
On backhaul devices, the Y axis auto-scale includes capacity reference line values (e.g. 100 Mbps) alongside actual traffic (e.g. 5 Mbps). This makes the traffic data appear as a flat line near zero — effectively invisible.

## Fix
Exclude datasets with `Capacity` prefix from the max-value calculation used for symmetric Y axis scaling. The capacity dashed lines still render and clip at the chart edges as a visual ceiling reference.

## 1-line change
```js
if (dataset.label?.startsWith("Capacity")) return
```

Reviewed-on: graham/towerops-web#140
2026-03-24 08:50:49 -05:00
4a43d9decc chore: remove dead commented-out code from topology.ex (#137)
Removes the commented-out `apply_inferred_role` function that was left behind when device type was simplified to manual-only.

Split from #135.

Reviewed-on: graham/towerops-web#137
2026-03-24 08:34:06 -05:00
e347b36db0 chore(deps): update dependency glinter to v2 (#134) 2026-03-24 08:26:59 -05:00
98409bfcfc chore(deps): Update dependency swoosh to ~> 1.24 (#133) 2026-03-24 08:26:57 -05:00
12a737e1f5 fix/security-and-quality-issues (#136)
Reviewed-on: graham/towerops-web#136
2026-03-24 08:06:29 -05:00
872f717dba Fix critical bugs, memory leaks, and N+1 queries (#132)
CRITICAL FIXES:
- Fix unsafe pattern matching in SNMP discovery that would crash on timeout
  - Changed {:ok, _} = ... to proper case statements with error handling
  - Extracted safe_discover/3 helper to reduce cyclomatic complexity
  - Added fallback to empty lists and warning logging for timeouts
  - Affects: discover_vlans, discover_ip_addresses, discover_processors, discover_storage

MEMORY LEAK FIXES (JS Hooks):
- GlobalSearchTrigger: Added destroyed() cleanup for click listener
- SidebarCollapse: Added destroyed() cleanup for click listener
- ThemeSelector: Added destroyed() cleanup for phx:set-theme window listener
- NetworkMap: Added destroyed() cleanup for 3 button listeners (zoom in/out/fit)
- All hooks now properly store handler references and remove listeners on unmount

LIVEVIEW FIXES:
- Added phx-update="ignore" to 5 SensorChart hooks to prevent chart re-initialization
- Added catch-all handle_info(_msg, socket) to 5 LiveViews to prevent crashes on unexpected messages
  - device_live/show.ex, device_live/index.ex, alert_live/index.ex, activity_feed_live.ex, agent_live/index.ex

N+1 QUERY FIXES:
- Created Gaiia.get_site_subscriber_summaries/1 batch function
- Refactored alert_live and device_live to use batch query instead of looping
- Reduces queries from N to 1 when loading site subscriber data

Impact:
- Prevents discovery worker crashes during SNMP timeouts
- Eliminates memory accumulation from leaked event handlers
- Prevents chart state loss on LiveView updates
- Prevents LiveView crashes from unexpected PubSub messages
- Improves database performance by eliminating N+1 queries in alert/device views
- Passes credo --strict with 0 issues

Reviewed-on: graham/towerops-web#132
2026-03-23 17:03:41 -05:00
a4c468a007 fix: update dialyzer ignore for Gleam type system interop (#131)
- Add vendored snmpkit/snmp_lib paths in src/ to ignore patterns
- Document and ignore Gleam<->Erlang type system mismatches
- Gleam's Int doesn't map to non_neg_integer() (contract_supertype)
- Gleam's opaque types not understood by Dialyzer (call_without_opaque)
- All Gleam code compiles and passes tests - these are false positives

Result: Zero dialyzer errors in our own code (1284/1311 skipped)

Reviewed-on: graham/towerops-web#131
2026-03-23 15:29:47 -05:00
35935f6463 fix/traffic-graph-rendering-and-polarity (#130)
Reviewed-on: graham/towerops-web#130
2026-03-23 15:24:44 -05:00
9a366c2665 debug/traffic-graph-logging (#129)
Reviewed-on: graham/towerops-web#129
2026-03-23 13:35:12 -05:00
7655f9d45a perf/speed-up-tests (#128)
Reviewed-on: graham/towerops-web#128
2026-03-23 10:51:32 -05:00