diff --git a/controller/docker-compose.yml b/controller/docker-compose.yml index d216851..2e14b30 100644 --- a/controller/docker-compose.yml +++ b/controller/docker-compose.yml @@ -27,6 +27,8 @@ services: - /sys:/host/sys:ro # Host OS info — for monitoring page system info - /etc/os-release:/host/etc/os-release:ro + # Host hostname — for monitoring page (os.Hostname() returns container ID) + - /etc/hostname:/host/etc/hostname:ro environment: - TZ=Europe/Budapest labels: diff --git a/controller/internal/metrics/sysinfo.go b/controller/internal/metrics/sysinfo.go index 71f5e12..77ec345 100644 --- a/controller/internal/metrics/sysinfo.go +++ b/controller/internal/metrics/sysinfo.go @@ -16,8 +16,12 @@ import ( func GetStaticInfo() StaticSystemInfo { info := StaticSystemInfo{} - // Hostname - info.Hostname, _ = os.Hostname() + // Hostname — try host mount first, fall back to os.Hostname() + if data, err := os.ReadFile("/host/etc/hostname"); err == nil { + info.Hostname = strings.TrimSpace(string(data)) + } else { + info.Hostname, _ = os.Hostname() + } // OS — try host mount first, fall back to container's info.OS = readOSRelease("/host/etc/os-release") diff --git a/controller/internal/web/templates/monitoring.html b/controller/internal/web/templates/monitoring.html index 92e9513..30864ec 100644 --- a/controller/internal/web/templates/monitoring.html +++ b/controller/internal/web/templates/monitoring.html @@ -41,9 +41,9 @@