Lint / Python (flake8) (pull_request) Successful in 2m6s
Lint / JS (eslint) (pull_request) Successful in 18s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / Python Security (bandit) (pull_request) Successful in 2m11s
Test / Python Tests (pytest) (pull_request) Successful in 2m20s
Lint / JS (eslint) (push) Successful in 10s
Lint / Python (flake8) (push) Successful in 1m58s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 1m58s
Lint / Deploy (push) Successful in 4s
Test / Python Tests (pytest) (push) Successful in 58s
Modem and WAN: - Poll the BGW320 status pages read-only for light levels, PON and WAN state, with a WAN / Fiber panel, 7-day Rx trend, and alerts on WAN down, optical limits, and Rx drift - Read WAN outages and Smart Power restarts from the UniFi system log, since outages can be over between 5 minute polls Device pages: - Add device search to the dashboard and a page per host, switch, router, AP, PDU, or modem - Move all Link Debug data into expandable rows there; /links redirects - Collect UDM ports and UniFi device details (firmware, load, WAN, outlets) - Reorder the dashboard Monitoring fixes: - Alert when a configured host stops reporting: its series disappear rather than reporting down, so a dead host never raised an alert - Alert on Prometheus outages instead of blanking the dashboard - Treat a failed Pulse ping as unknown rather than host unreachable - Stop new switch ports reporting lifetime bytes as one interval's rate - Run database sessions in UTC: other server time zones shifted displayed ages and timed suppression expiries Also log every avatar 404 reason, add a favicon, and correct the WAN link labels (1G on Port 9, not 10G SFP+). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
3.0 KiB
SQL
64 lines
3.0 KiB
SQL
-- Gandalf Network Monitor – Database Schema
|
||
-- Run on MariaDB LXC 149 (10.10.10.50)
|
||
|
||
CREATE DATABASE IF NOT EXISTS gandalf
|
||
CHARACTER SET utf8mb4
|
||
COLLATE utf8mb4_unicode_ci;
|
||
|
||
USE gandalf;
|
||
|
||
-- ── Network events (open and resolved alerts) ─────────────────────────
|
||
CREATE TABLE IF NOT EXISTS network_events (
|
||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||
event_type VARCHAR(60) NOT NULL,
|
||
severity ENUM('critical','warning','info') NOT NULL DEFAULT 'warning',
|
||
source_type VARCHAR(20) NOT NULL, -- 'prometheus', 'unifi', 'ping'
|
||
target_name VARCHAR(255) NOT NULL, -- hostname or device name
|
||
target_detail VARCHAR(255) NOT NULL DEFAULT '', -- interface name, device type, IP
|
||
description TEXT,
|
||
first_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
last_seen TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||
resolved_at TIMESTAMP NULL,
|
||
consecutive_failures INT NOT NULL DEFAULT 1,
|
||
ticket_id VARCHAR(20) NULL,
|
||
|
||
INDEX idx_active (resolved_at),
|
||
INDEX idx_target (target_name, target_detail),
|
||
INDEX idx_type (event_type),
|
||
-- Compound index for hot upsert_event lookup: event_type+target+resolved_at
|
||
INDEX idx_event_lookup (event_type, target_name, target_detail, resolved_at)
|
||
) ENGINE=InnoDB;
|
||
|
||
-- ── Suppression rules ─────────────────────────────────────────────────
|
||
CREATE TABLE IF NOT EXISTS suppression_rules (
|
||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||
target_type VARCHAR(50) NOT NULL, -- 'host', 'interface', 'unifi_device', 'all'
|
||
target_name VARCHAR(255) NOT NULL DEFAULT '',
|
||
target_detail VARCHAR(255) NOT NULL DEFAULT '',
|
||
reason TEXT NOT NULL,
|
||
suppressed_by VARCHAR(255) NOT NULL,
|
||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||
expires_at TIMESTAMP NULL, -- NULL = manual (never auto-expires)
|
||
active BOOLEAN NOT NULL DEFAULT TRUE,
|
||
|
||
INDEX idx_active_exp (active, expires_at),
|
||
-- For suppression lookup by type+name
|
||
INDEX idx_sup_lookup (active, target_type, target_name, target_detail)
|
||
) ENGINE=InnoDB;
|
||
|
||
-- ── WAN modem optical history (one row per poll) ──────────────────────
|
||
-- Also created automatically at monitor startup (db.ensure_modem_schema).
|
||
CREATE TABLE IF NOT EXISTS modem_samples (
|
||
sampled_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP PRIMARY KEY,
|
||
rx_power_dbm DECIMAL(5,1) NULL,
|
||
tx_power_dbm DECIMAL(5,1) NULL,
|
||
temp_c DECIMAL(5,1) NULL
|
||
) ENGINE=InnoDB;
|
||
|
||
-- ── Monitor state (key/value store for snapshot + baseline) ───────────
|
||
CREATE TABLE IF NOT EXISTS monitor_state (
|
||
key_name VARCHAR(100) PRIMARY KEY,
|
||
value MEDIUMTEXT NOT NULL,
|
||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||
) ENGINE=InnoDB;
|