towerops/lib/towerops_web/live
Graham McIntire d7741cdc0e
feat: implement unified checks system (Phase 1-4)
This commit implements the unified checks architecture that consolidates
SNMP monitoring with HTTP/TCP/DNS checks under a single "check" abstraction,
enabling consistent graphing, alerting, and management across all check types.

Database Changes:
- Add source_type and source_id to checks table for tracking auto-discovered
  vs manually created checks
- Add value field to check_results for storing numeric sensor readings
- Maintain backward compatibility with existing check_results data

New SNMP Executors:
- SnmpSensorExecutor: Poll sensor OIDs and return formatted values with
  status determination (OK/WARNING/CRITICAL based on limits)
- SnmpInterfaceExecutor: Poll interface stats (bandwidth, packets, errors)
- SnmpProcessorExecutor: Poll CPU/processor usage
- SnmpStorageExecutor: Poll disk/memory usage with percentage calculations

Check Execution Worker:
- CheckExecutorWorker: Unified Oban worker that dispatches to appropriate
  executor based on check_type (snmp_sensor, snmp_interface, http, tcp, etc.)
- Self-schedules next execution with distributed polling offsets
- Records results in check_results TimescaleDB hypertable
- Updates check state (OK/WARNING/CRITICAL/UNKNOWN)

Discovery Integration:
- Auto-creates checks during SNMP discovery for sensors, interfaces,
  processors, and storage
- Links checks to source entities via source_id for data lookup
- Enables/disables checks based on discovery results

UI Enhancements:
- Checks tab on device detail page with grouped display
- FormComponent for adding manual HTTP/TCP/DNS checks
- Empty state with "Run Discovery" prompt
- Check status badges and last checked times

Graphing:
- Update GraphLive to accept check_id parameter
- Query check_results table for time-series data
- Support all check types (SNMP, HTTP response times, etc.)

Testing:
- Comprehensive test suite for SnmpSensorExecutor (5 tests)
- Test suite for CheckExecutorWorker (7 tests)
- Test coverage for discovery check creation (6 tests)
- Remove deprecated monitoring_test.exs testing old API

Bug Fixes:
- Fix SNMP executors reading credentials from correct Device schema fields
  (device.snmp_version instead of device.snmp_device.version)
- Update agent channel test to query MonitoringCheck table directly

Code Quality:
- Extract add_snmp_credentials helper to reduce cyclomatic complexity
- Use map-based lookups for sensor formatting and check type grouping
- Apply pattern matching in dispatcher to reduce complexity
- All credo checks passing with no issues

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 16:58:40 -06:00
..
account_live Replace single name field with first_name and last_name 2026-02-01 15:00:23 -06:00
admin fix 5 failing tests 2026-02-11 12:21:06 -06:00
agent_live fix: sync AgentLive.Index modal state to URL for browser navigation 2026-02-12 09:28:39 -06:00
alert_live feat: live device timestamp updates and org-scoped alert PubSub 2026-02-12 11:01:56 -06:00
check_live feat: implement unified checks system (Phase 1-4) 2026-02-12 16:58:40 -06:00
device_live feat: implement unified checks system (Phase 1-4) 2026-02-12 16:58:40 -06:00
graph_live feat: implement unified checks system (Phase 1-4) 2026-02-12 16:58:40 -06:00
help_live help update 2026-02-04 17:56:48 -06:00
helpers refactor: centralize LiveView access control checks 2026-02-04 17:51:05 -06:00
mikrotik_backup_live handle mikrotik ssh 2026-02-02 16:42:18 -06:00
org UI improvements 2026-02-05 14:57:11 -06:00
org_live UI improvements 2026-02-05 14:57:11 -06:00
site_live make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
user_settings_live more gettext 2026-02-02 13:10:08 -06:00
dashboard_live.ex feat: live device timestamp updates and org-scoped alert PubSub 2026-02-12 11:01:56 -06:00
dashboard_live.html.heex make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
mobile_qr_live.ex more dark mode 2026-01-20 17:23:11 -06:00
network_map_live.ex feat: add automatic network topology inference 2026-02-12 13:28:01 -06:00
network_map_live.html.heex feat: add automatic network topology inference 2026-02-12 13:28:01 -06:00
user_registration_live.ex add snmp port 2026-02-03 12:51:50 -06:00
user_reset_password_live.ex add HIBP password check 2026-02-01 08:57:01 -06:00
user_settings_live.ex fix: sync UserSettingsLive modal state to URL for browser navigation 2026-02-12 09:26:45 -06:00
user_settings_live.html.heex add default org 2026-02-02 10:45:37 -06:00