mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-21 21:26:16 +01:00
Compare commits
2 Commits
82bd953941
...
5d04ee5a65
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d04ee5a65 | ||
|
|
d93067ec34 |
@@ -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.OsName = "FreeBSD"
|
||||
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 {
|
||||
a.systemDetails.Threads = threads
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
@@ -7,7 +7,6 @@ import { cn, formatBytes, getHostDisplayValue, secondsToString, toFixedFloat } f
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import {
|
||||
AppleIcon,
|
||||
BinaryIcon,
|
||||
ChevronRightSquareIcon,
|
||||
ClockArrowUp,
|
||||
CpuIcon,
|
||||
@@ -22,6 +21,7 @@ import type { ChartData, SystemDetailsRecord, SystemRecord } from "@/types"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import { useLingui } from "@lingui/react/macro"
|
||||
import { pb } from "@/lib/api"
|
||||
import { plural } from "@lingui/core/macro"
|
||||
|
||||
export default function InfoBar({
|
||||
system,
|
||||
@@ -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, {
|
||||
@@ -69,7 +70,7 @@ export default function InfoBar({
|
||||
const hostname = details?.hostname ?? system.info.h
|
||||
const kernel = details?.kernel ?? system.info.k
|
||||
const cores = details?.cores ?? system.info.c
|
||||
const threads = details?.threads ?? system.info.t
|
||||
const threads = details?.threads ?? system.info.t ?? 0
|
||||
const cpuModel = details?.cpu ?? system.info.m
|
||||
const os = details?.os ?? system.info.os ?? Os.Linux
|
||||
const osName = details?.os_name
|
||||
@@ -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,
|
||||
@@ -118,7 +119,12 @@ export default function InfoBar({
|
||||
},
|
||||
{ value: uptime, Icon: ClockArrowUp, label: t`Uptime`, hide: !system.info.u },
|
||||
osInfo[os],
|
||||
{ value: arch, Icon: BinaryIcon, hide: !arch },
|
||||
{
|
||||
value: cpuModel,
|
||||
Icon: CpuIcon,
|
||||
hide: !cpuModel,
|
||||
label: `${plural(cores, { one: "# core", other: "# cores" })} / ${plural(threads, { one: "# thread", other: "# threads" })}${arch ? ` / ${arch}` : ""}`,
|
||||
},
|
||||
] as {
|
||||
value: string | number | undefined
|
||||
label?: string
|
||||
@@ -126,12 +132,6 @@ export default function InfoBar({
|
||||
hide?: boolean
|
||||
}[]
|
||||
|
||||
info.push({
|
||||
value: `${cpuModel} (${cores}c${threads ? `/${threads}t` : ""})`,
|
||||
Icon: CpuIcon,
|
||||
hide: !cpuModel,
|
||||
})
|
||||
|
||||
if (memory) {
|
||||
const memValue = formatBytes(memory, false, undefined, false)
|
||||
info.push({
|
||||
|
||||
Reference in New Issue
Block a user