Documentation
¶
Overview ¶
Package dashboard aggregates per-service health, container resource usage, and VPN status into a single payload for Pulse's UI dashboard.
Stitches three data sources:
- registry.Service — the canonical list of registered services
- dockerstats.Client — per-container CPU / memory / net (optional)
- gluetun.Client — VPN status (optional)
plus per-service /api/v1/stats and /api/v1/system/runtime fetched live.
Every dependency may be nil (Docker socket not mounted, no Gluetun configured); the aggregator degrades gracefully and returns whatever data it has.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveDownload ¶
type ActiveDownload struct {
ServiceID string `json:"service_id"`
ServiceName string `json:"service_name"`
Name string `json:"name"`
Progress float64 `json:"progress"` // 0-1
DownloadRate int64 `json:"download_rate"`
UploadRate int64 `json:"upload_rate"`
Peers int `json:"peers"`
ETASeconds int64 `json:"eta_seconds"`
Status string `json:"status"`
}
ActiveDownload is a torrent currently downloading on Haul (or any future download client). The dashboard renders the top N by activity with progress, rate, peers, ETA.
type ActiveImport ¶
type ActiveImport struct {
ServiceID string `json:"service_id"`
ServiceName string `json:"service_name"`
Title string `json:"title"`
Status string `json:"status"`
Size int64 `json:"size"`
Downloaded int64 `json:"downloaded_bytes"`
Progress float64 `json:"progress"` // 0-1, derived
GrabbedAt string `json:"grabbed_at"`
}
ActiveImport is an item in flight on a media manager (Pilot/Prism queue). Bundles items from both managers into a single feed so the dashboard can show "what's being processed" without per-service silos.
type Aggregator ¶
type Aggregator struct {
Registry *registry.Service
Docker *dockerstats.Client
Gluetun *gluetun.Client
HTTP *http.Client
GluetunService string // logical name used for the VPN container's stats card; default "vpn"
}
Aggregator builds dashboard payloads.
func New ¶
func New(reg *registry.Service, docker *dockerstats.Client, glu *gluetun.Client) *Aggregator
New returns an aggregator with sane defaults.
func (*Aggregator) Overview ¶
func (a *Aggregator) Overview(ctx context.Context) (*Overview, error)
Overview builds the dashboard's per-2s payload. Best-effort across all data sources — if Docker is disabled or Gluetun is unreachable, the affected fields are simply nil.
func (*Aggregator) ServiceDetail ¶
func (a *Aggregator) ServiceDetail(ctx context.Context, serviceID string) (*ServiceDetail, error)
ServiceDetail backs the drill-down drawer for a single service.
type ContainerStats ¶
type ContainerStats struct {
CPUPercent float64 `json:"cpu_percent"`
MemUsageBytes uint64 `json:"mem_usage_bytes"`
MemLimitBytes uint64 `json:"mem_limit_bytes"`
NetRxBytes uint64 `json:"net_rx_bytes"`
NetTxBytes uint64 `json:"net_tx_bytes"`
NetRxRateBps float64 `json:"net_rx_rate_bps"`
NetTxRateBps float64 `json:"net_tx_rate_bps"`
BlockReadBytes uint64 `json:"block_read_bytes"`
BlockWriteBytes uint64 `json:"block_write_bytes"`
HealthStatus string `json:"health_status"`
}
ContainerStats is the dashboard-relevant subset of dockerstats.Stats.
type EnvEntry ¶
type EnvEntry struct {
Key string `json:"key"`
Value string `json:"value"`
Redacted bool `json:"redacted"`
}
EnvEntry is one environment variable row from /api/v1/system/env.
type HaulSummary ¶
type HaulSummary struct {
DownloadSpeed int64 `json:"download_speed"`
UploadSpeed int64 `json:"upload_speed"`
ActiveDownloads int `json:"active_downloads"`
ActiveUploads int `json:"active_uploads"`
PeersConnected int `json:"peers_connected"`
}
HaulSummary is the throughput card on the overview.
type LogEntry ¶
type LogEntry struct {
Time string `json:"time"`
Level string `json:"level"`
Message string `json:"message"`
Fields map[string]any `json:"fields,omitempty"`
}
LogEntry is one log line from /api/v1/system/logs.
type Overview ¶
type Overview struct {
Services []ServiceSummary `json:"services"`
Haul *HaulSummary `json:"haul,omitempty"`
VPN *VPNSummary `json:"vpn,omitempty"`
ActiveDownloads []ActiveDownload `json:"active_downloads,omitempty"`
ActiveDownloadsTotal int `json:"active_downloads_total,omitempty"`
ActiveImports []ActiveImport `json:"active_imports,omitempty"`
ActiveImportsTotal int `json:"active_imports_total,omitempty"`
}
Overview is the small payload polled every 2s by the dashboard.
type RuntimeStats ¶
type RuntimeStats struct {
Goroutines int `json:"goroutines"`
HeapAlloc uint64 `json:"heap_alloc_bytes"`
HeapInUse uint64 `json:"heap_in_use_bytes"`
HeapObjects uint64 `json:"heap_objects"`
NumGC uint32 `json:"num_gc"`
LastGCPauseNs uint64 `json:"last_gc_pause_ns"`
UptimeSeconds int64 `json:"uptime_seconds"`
GoVersion string `json:"go_version"`
GoOS string `json:"goos"`
GoArch string `json:"goarch"`
NumCPU int `json:"num_cpu"`
Hostname string `json:"hostname"`
}
RuntimeStats is the per-service Go-runtime stats from /api/v1/system/runtime.
type ServiceDetail ¶
type ServiceDetail struct {
Service ServiceSummary `json:"service"`
Container *ContainerStats `json:"container,omitempty"`
Runtime *RuntimeStats `json:"runtime,omitempty"`
Env []EnvEntry `json:"env,omitempty"`
Logs []LogEntry `json:"logs,omitempty"`
Specifics map[string]any `json:"specifics,omitempty"`
}
ServiceDetail is the full payload backing the drill-down drawer.
type ServiceSummary ¶
type ServiceSummary struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Status string `json:"status"`
Version string `json:"version"`
Container *ContainerStats `json:"container,omitempty"`
}
ServiceSummary is a per-service card in the dashboard grid.
type VPNSummary ¶
type VPNSummary struct {
// Reachable: Pulse got at least one successful response from Gluetun's
// control server. False means we couldn't talk to it at all — the
// frontend hides the panel rather than showing a misleading
// "disconnected" state.
Reachable bool `json:"reachable"`
Connected bool `json:"connected"`
PublicIP string `json:"public_ip"`
Country string `json:"country"`
PortForwarded int `json:"port_forwarded"`
Provider string `json:"provider"`
DNSStatus string `json:"dns_status"`
}
VPNSummary is the small VPN card on the overview.