ca9faa0acd
Add node-aware check history and probe registration infrastructure: - ProbeNode model and nodes table (SQLite + Postgres) - node_id column on check_history for multi-source tracking - Store interface: RegisterNode, GetNode, GetAllNodes, DeleteNode, SaveCheckFromNode - Dialect: UpsertNodeSQL (INSERT OR REPLACE / ON CONFLICT) - API endpoints: POST /api/probe/register, GET /api/probe/assignments, POST /api/probe/results - Backward compatible: existing SaveCheck wraps SaveCheckFromNode with empty node_id
74 lines
1.3 KiB
Go
74 lines
1.3 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
type Site struct {
|
|
ID int
|
|
Name string
|
|
URL string
|
|
Type string // "http", "push", "ping", "port", "dns", "group"
|
|
Token string
|
|
Interval int
|
|
AlertID int
|
|
CheckSSL bool
|
|
ExpiryThreshold int
|
|
MaxRetries int
|
|
|
|
Hostname string
|
|
Port int
|
|
Timeout int
|
|
Method string
|
|
Description string
|
|
ParentID int
|
|
AcceptedCodes string
|
|
DNSResolveType string
|
|
DNSServer string
|
|
IgnoreTLS bool
|
|
Paused bool
|
|
|
|
FailureCount int
|
|
Status string
|
|
StatusCode int
|
|
Latency time.Duration
|
|
CertExpiry time.Time
|
|
HasSSL bool
|
|
LastCheck time.Time
|
|
SentSSLWarning bool
|
|
}
|
|
|
|
type AlertConfig struct {
|
|
ID int
|
|
Name string
|
|
Type string
|
|
Settings map[string]string
|
|
}
|
|
|
|
type User struct {
|
|
ID int
|
|
Username string
|
|
PublicKey string
|
|
Role string
|
|
}
|
|
|
|
type CheckRecord struct {
|
|
SiteID int
|
|
NodeID string
|
|
LatencyNs int64
|
|
IsUp bool
|
|
CheckedAt time.Time
|
|
}
|
|
|
|
type ProbeNode struct {
|
|
ID string
|
|
Name string
|
|
Region string
|
|
LastSeen time.Time
|
|
Version string
|
|
}
|
|
|
|
type Backup struct {
|
|
Sites []Site `json:"sites"`
|
|
Alerts []AlertConfig `json:"alerts"`
|
|
Users []User `json:"users"`
|
|
}
|