Dashboard Editor & Layout: - Full-screen visual editor for reorganizing cards - Drag-and-drop cards between sections - Toggle card visibility with persistence to localStorage - Reset to default layout option Alerts System: - Threshold-based alerts for CPU, memory, temperature, disk, GPU - Alert manager with duration requirements - AlertsCard component with settings UI - API endpoints for alerts CRUD New Collectors: - Docker container monitoring with parallel stats fetching - Systemd service status via D-Bus - Historical metrics storage (1 hour at 1s intervals) PWA Support: - Service worker with offline caching - Web app manifest with SVG icons - iOS PWA meta tags Mobile Responsive: - Collapsible hamburger menu on mobile - Adaptive grid layouts for all screen sizes - Touch-friendly hover states - Safe area insets for notched devices UI Enhancements: - Light/dark theme toggle with persistence - Keyboard shortcuts (T=theme, R=refresh, ?=help) - Per-process expandable details in ProcessesCard - Sparkline charts for historical data Performance Fixes: - Buffered SSE channels to prevent blocking - Parallel Docker stats collection with timeout - D-Bus timeout for systemd collector Tests: - Unit tests for CPU, memory, network collectors - Alert manager tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
70 lines
2.4 KiB
Go
70 lines
2.4 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// AlertType represents different types of metrics that can trigger alerts
|
|
type AlertType string
|
|
|
|
const (
|
|
AlertTypeCPU AlertType = "cpu"
|
|
AlertTypeMemory AlertType = "memory"
|
|
AlertTypeTemperature AlertType = "temperature"
|
|
AlertTypeDisk AlertType = "disk"
|
|
AlertTypeGPU AlertType = "gpu"
|
|
)
|
|
|
|
// AlertSeverity indicates the urgency level
|
|
type AlertSeverity string
|
|
|
|
const (
|
|
AlertSeverityWarning AlertSeverity = "warning"
|
|
AlertSeverityCritical AlertSeverity = "critical"
|
|
)
|
|
|
|
// AlertThreshold defines when an alert should trigger
|
|
type AlertThreshold struct {
|
|
Type AlertType `json:"type"`
|
|
WarningValue float64 `json:"warningValue"` // Trigger warning at this value
|
|
CriticalValue float64 `json:"criticalValue"` // Trigger critical at this value
|
|
Enabled bool `json:"enabled"`
|
|
DurationSeconds int `json:"durationSeconds"` // Must exceed threshold for this long
|
|
}
|
|
|
|
// Alert represents an active or historical alert
|
|
type Alert struct {
|
|
ID string `json:"id"`
|
|
Type AlertType `json:"type"`
|
|
Severity AlertSeverity `json:"severity"`
|
|
Message string `json:"message"`
|
|
Value float64 `json:"value"`
|
|
Threshold float64 `json:"threshold"`
|
|
TriggeredAt time.Time `json:"triggeredAt"`
|
|
ResolvedAt *time.Time `json:"resolvedAt,omitempty"`
|
|
Acknowledged bool `json:"acknowledged"`
|
|
}
|
|
|
|
// AlertConfig holds all alert thresholds
|
|
type AlertConfig struct {
|
|
Thresholds []AlertThreshold `json:"thresholds"`
|
|
}
|
|
|
|
// AlertsResponse is the API response for alerts
|
|
type AlertsResponse struct {
|
|
Active []Alert `json:"active"`
|
|
History []Alert `json:"history"`
|
|
Config AlertConfig `json:"config"`
|
|
}
|
|
|
|
// DefaultAlertConfig returns sensible default thresholds
|
|
func DefaultAlertConfig() AlertConfig {
|
|
return AlertConfig{
|
|
Thresholds: []AlertThreshold{
|
|
{Type: AlertTypeCPU, WarningValue: 80, CriticalValue: 95, Enabled: true, DurationSeconds: 30},
|
|
{Type: AlertTypeMemory, WarningValue: 85, CriticalValue: 95, Enabled: true, DurationSeconds: 30},
|
|
{Type: AlertTypeTemperature, WarningValue: 75, CriticalValue: 90, Enabled: true, DurationSeconds: 10},
|
|
{Type: AlertTypeDisk, WarningValue: 85, CriticalValue: 95, Enabled: true, DurationSeconds: 0},
|
|
{Type: AlertTypeGPU, WarningValue: 85, CriticalValue: 95, Enabled: true, DurationSeconds: 30},
|
|
},
|
|
}
|
|
}
|