diff --git a/monitoring/unit/os_darwin.go b/monitoring/unit/os_darwin.go index 94c552f..757c43a 100644 --- a/monitoring/unit/os_darwin.go +++ b/monitoring/unit/os_darwin.go @@ -19,3 +19,14 @@ func OSName() string { name := strings.TrimSpace(string(output)) return name } + +// KernelVersion returns the kernel version on Darwin (macOS) +func KernelVersion() string { + cmd := exec.Command("uname", "-r") + output, err := cmd.Output() + if err != nil { + return "Unknown" + } + + return strings.TrimSpace(string(output)) +} diff --git a/monitoring/unit/os_freebsd.go b/monitoring/unit/os_freebsd.go index e572555..b2c1be8 100644 --- a/monitoring/unit/os_freebsd.go +++ b/monitoring/unit/os_freebsd.go @@ -19,3 +19,14 @@ func OSName() string { name := strings.TrimSpace(string(output)) return name } + +// KernelVersion returns the kernel version on FreeBSD +func KernelVersion() string { + cmd := exec.Command("uname", "-r") + output, err := cmd.Output() + if err != nil { + return "Unknown" + } + + return strings.TrimSpace(string(output)) +} diff --git a/monitoring/unit/os_linux.go b/monitoring/unit/os_linux.go index e226cff..eb2fae0 100644 --- a/monitoring/unit/os_linux.go +++ b/monitoring/unit/os_linux.go @@ -156,3 +156,13 @@ func detectProxmoxVE() string { return "Proxmox VE" } + +// KernelVersion returns the kernel version on Linux systems +func KernelVersion() string { + out, err := exec.Command("uname", "-r").Output() + if err != nil { + return "Unknown" + } + + return strings.TrimSpace(string(out)) +} diff --git a/monitoring/unit/os_windows.go b/monitoring/unit/os_windows.go index 7136e34..a6676cd 100644 --- a/monitoring/unit/os_windows.go +++ b/monitoring/unit/os_windows.go @@ -48,3 +48,27 @@ func OSName() string { return productName } + +// KernelVersion returns the kernel version on Windows systems (build number) +func KernelVersion() string { + key, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE) + if err != nil { + return "Unknown" + } + defer key.Close() + + // Get current build number + buildNumber, _, err := key.GetStringValue("CurrentBuild") + if err != nil { + return "Unknown" + } + + // Get UBR (Update Build Revision) if available + ubr, _, err := key.GetIntegerValue("UBR") + if err != nil { + // UBR not available, just return build number + return buildNumber + } + + return buildNumber + "." + strconv.FormatUint(ubr, 10) +} diff --git a/server/basicInfo.go b/server/basicInfo.go index d3c4926..29c4127 100644 --- a/server/basicInfo.go +++ b/server/basicInfo.go @@ -35,6 +35,7 @@ func uploadBasicInfo() error { cpu := monitoring.Cpu() osname := monitoring.OSName() + kernelVersion := monitoring.KernelVersion() ipv4, ipv6, _ := monitoring.GetIPAddress() data := map[string]interface{}{ @@ -42,6 +43,7 @@ func uploadBasicInfo() error { "cpu_cores": cpu.CPUCores, "arch": cpu.CPUArchitecture, "os": osname, + "kernel_version": kernelVersion, "ipv4": ipv4, "ipv6": ipv6, "mem_total": monitoring.Ram().Total,