mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 23:41:48 +01:00
Implements comprehensive Docker monitoring with a dedicated agent that collects container metrics and reports them to the main Pulse server. Adds Docker-specific alert rules and threshold management with a redesigned UI. Backend changes: - Add Docker agent binary with container metrics collection - Implement Docker host and container models with CPU/memory tracking - Add Docker-specific alert types (offline, state, health) - Extend threshold system to support Docker resources - Add WebSocket message types for Docker agent communication - Implement Docker agent API endpoints for registration and metrics Frontend changes: - Add Docker monitoring page with host/container views - Add Docker agent settings panel for configuration - Reorganize thresholds page with Proxmox/Docker tabs - Add Docker-specific alert threshold management - Improve layout consistency with vertical stacking - Fix defensive null checks and TypeScript errors This change enables monitoring of Docker containers across multiple hosts with the same alerting and threshold capabilities as Proxmox resources.
38 lines
606 B
Go
38 lines
606 B
Go
package dockeragent
|
|
|
|
import (
|
|
"bufio"
|
|
"errors"
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func readProcUptime() (float64, error) {
|
|
f, err := os.Open("/proc/uptime")
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
defer f.Close()
|
|
|
|
scanner := bufio.NewScanner(f)
|
|
if !scanner.Scan() {
|
|
if err := scanner.Err(); err != nil {
|
|
return 0, err
|
|
}
|
|
return 0, errors.New("empty /proc/uptime")
|
|
}
|
|
|
|
fields := strings.Fields(scanner.Text())
|
|
if len(fields) == 0 {
|
|
return 0, errors.New("invalid /proc/uptime contents")
|
|
}
|
|
|
|
value, err := strconv.ParseFloat(fields[0], 64)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
return value, nil
|
|
}
|