diff --git a/beszel/internal/agent/system.go b/beszel/internal/agent/system.go index baa189c..a680dea 100644 --- a/beszel/internal/agent/system.go +++ b/beszel/internal/agent/system.go @@ -185,8 +185,12 @@ func (a *Agent) getSystemStats() system.Stats { // GPU data if a.gpuManager != nil { + // reset high gpu percent + a.systemInfo.GpuPct = 0 + // get current GPU data if gpuData := a.gpuManager.GetCurrentData(); len(gpuData) > 0 { systemStats.GPUData = gpuData + // add temperatures if systemStats.Temperatures == nil { systemStats.Temperatures = make(map[string]float64, len(gpuData)) @@ -195,6 +199,8 @@ func (a *Agent) getSystemStats() system.Stats { if gpu.Temperature > 0 { systemStats.Temperatures[gpu.Name] = gpu.Temperature } + // update high gpu percent for dashboard + a.systemInfo.GpuPct = max(a.systemInfo.GpuPct, gpu.Usage) } } } @@ -249,10 +255,7 @@ func (a *Agent) updateTemperatures(systemStats *system.Stats) error { continue } } - // assign high temperature if sensor temp is higher than a.systemInfo.HighTemp - if sensor.Temperature > a.systemInfo.HighTemp { - a.systemInfo.HighTemp = sensor.Temperature - } + a.systemInfo.HighTemp = max(a.systemInfo.HighTemp, sensor.Temperature) systemStats.Temperatures[sensorName] = twoDecimals(sensor.Temperature) } return nil diff --git a/beszel/internal/entities/system/system.go b/beszel/internal/entities/system/system.go index e1ef29e..4e8191d 100644 --- a/beszel/internal/entities/system/system.go +++ b/beszel/internal/entities/system/system.go @@ -75,7 +75,7 @@ type Info struct { Bandwidth float64 `json:"b"` AgentVersion string `json:"v"` Podman bool `json:"p,omitempty"` - Gpu float64 `json:"g,omitempty"` + GpuPct float64 `json:"g,omitempty"` HighTemp float64 `json:"ht,omitempty"` } diff --git a/beszel/site/src/components/systems-table/systems-table.tsx b/beszel/site/src/components/systems-table/systems-table.tsx index 28f883b..139e5d8 100644 --- a/beszel/site/src/components/systems-table/systems-table.tsx +++ b/beszel/site/src/components/systems-table/systems-table.tsx @@ -9,7 +9,7 @@ import { VisibilityState, getCoreRowModel, useReactTable, - Column, + HeaderContext, } from "@tanstack/react-table" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" @@ -66,7 +66,7 @@ import { useStore } from "@nanostores/react" import { cn, copyToClipboard, decimalString, isReadOnlyUser, useLocalStorage } from "@/lib/utils" import AlertsButton from "../alerts/alert-button" import { $router, Link, navigate } from "../router" -import { EthernetIcon, ThermometerIcon } from "../ui/icons" +import { EthernetIcon, GpuIcon, ThermometerIcon } from "../ui/icons" import { Trans, t } from "@lingui/macro" import { useLingui } from "@lingui/react" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/card" @@ -77,10 +77,10 @@ import { getPagePath } from "@nanostores/router" type ViewMode = "table" | "grid" function CellFormatter(info: CellContext) { - const val = info.getValue() as number + const val = (info.getValue() as number) || 0 return (
- {decimalString(val, 1)}% + {decimalString(val, 1)}% ) { ) } -function sortableHeader(column: Column, hideSortIcon = false) { +function sortableHeader(context: HeaderContext, hideSortIcon = false) { + const { column } = context return (