This commit is contained in:
henrygd
2025-12-17 17:32:59 -05:00
parent 82bd953941
commit d93067ec34
2 changed files with 26 additions and 21 deletions

View File

@@ -55,24 +55,29 @@ func (a *Agent) refreshStaticInfo() {
a.systemDetails.OsName = fmt.Sprintf("macOS %s", version)
} else if strings.Contains(platform, "indows") {
a.systemDetails.Os = system.Windows
a.systemDetails.OsName = fmt.Sprintf("%s %s", strings.Replace(platform, "Microsoft ", "", 1), version)
a.systemDetails.OsName = strings.Replace(platform, "Microsoft ", "", 1)
a.systemDetails.Kernel = version
} else if platform == "freebsd" {
a.systemDetails.Os = system.Freebsd
a.systemDetails.Kernel = version
a.systemDetails.Kernel, _ = host.KernelVersion()
if prettyName, err := getOsPrettyName(); err == nil {
a.systemDetails.OsName = prettyName
} else {
a.systemDetails.OsName = "FreeBSD"
}
} else {
a.systemDetails.Os = system.Linux
a.systemDetails.OsName = hostInfo.OperatingSystem
a.systemDetails.Kernel = hostInfo.KernelVersion
if a.systemDetails.OsName == "" {
if prettyName, err := getLinuxOsPrettyName(); err == nil {
if prettyName, err := getOsPrettyName(); err == nil {
a.systemDetails.OsName = prettyName
} else {
a.systemDetails.OsName = platform
}
}
a.systemDetails.Kernel = hostInfo.KernelVersion
if a.systemDetails.Kernel == "" {
a.systemDetails.Kernel = version
a.systemDetails.Kernel, _ = host.KernelVersion()
}
}
@@ -81,18 +86,17 @@ func (a *Agent) refreshStaticInfo() {
a.systemDetails.CpuModel = info[0].ModelName
}
// cores / threads
a.systemDetails.Cores, _ = cpu.Counts(false)
a.systemDetails.Threads = hostInfo.NCPU
if a.systemDetails.Threads == 0 {
if threads, err := cpu.Counts(true); err == nil {
if threads > 0 && threads < a.systemDetails.Cores {
// in lxc logical cores reflects container limits, so use that as cores if lower
a.systemDetails.Cores = threads
} else {
cores, _ := cpu.Counts(false)
threads := hostInfo.NCPU
if threads == 0 {
threads, _ = cpu.Counts(true)
}
// in lxc, logical cores reflects container limits, so use that as cores if lower
if threads > 0 && threads < cores {
cores = threads
}
a.systemDetails.Cores = cores
a.systemDetails.Threads = threads
}
}
}
// total memory
a.systemDetails.MemoryTotal = hostInfo.MemTotal
@@ -273,8 +277,8 @@ func getARCSize() (uint64, error) {
return 0, fmt.Errorf("failed to parse size field")
}
// getLinuxOsPrettyName attempts to get the pretty OS name from /etc/os-release on Linux systems
func getLinuxOsPrettyName() (string, error) {
// getOsPrettyName attempts to get the pretty OS name from /etc/os-release on Linux systems
func getOsPrettyName() (string, error) {
file, err := os.Open("/etc/os-release")
if err != nil {
return "", err

View File

@@ -41,9 +41,10 @@ export default function InfoBar({
// Fetch system_details on mount / when system changes
useEffect(() => {
setDetails(null)
// skip fetching system details if agent is older version which includes details in Info struct
if (!system.id || system.info?.m) {
return setDetails(null)
return
}
pb.collection<SystemDetailsRecord>("system_details")
.getOne(system.id, {
@@ -82,7 +83,6 @@ export default function InfoBar({
// show kernel in tooltip if os name is available, otherwise show the kernel
value: osName || kernel,
label: osName ? kernel : undefined,
// label: t({ comment: "Linux kernel", message: "Kernel" }),
},
[Os.Darwin]: {
Icon: AppleIcon,
@@ -91,6 +91,7 @@ export default function InfoBar({
[Os.Windows]: {
Icon: WindowsIcon,
value: osName || kernel,
label: osName ? kernel : undefined,
},
[Os.FreeBSD]: {
Icon: FreeBsdIcon,