mirror of
https://github.com/Buriburizaem0n/nezha-dash-v1.git
synced 2026-11-05 01:10:20 +00:00
feat: show GPU memory under the GPU chart (#92)
Renders state.gpus[i] when the agent provides it, using the existing formatBytes helper so it reads like the memory card. Older agents omit the field and nothing changes. Refs nezhahq/nezha#1235
This commit is contained in:
1 parent
ba37e11931
commit
203438242a
2 files changed
+20
No files matched your search
@@ -274,6 +274,8 @@ export default function ServerDetailChart({
|
|||||||
|
|
||||||
const gpuStats = server.state.gpu || [];
|
const gpuStats = server.state.gpu || [];
|
||||||
const gpuList = server.host.gpu || [];
|
const gpuList = server.host.gpu || [];
|
||||||
|
// Newer agents also report memory per card, index-aligned with the above.
|
||||||
|
const gpuDetails = server.state.gpus || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="flex flex-col">
|
<section className="flex flex-col">
|
||||||
@@ -298,6 +300,7 @@ export default function ServerDetailChart({
|
|||||||
now={nezhaWsData.now}
|
now={nezhaWsData.now}
|
||||||
gpuStat={gpuStats[index]}
|
gpuStat={gpuStats[index]}
|
||||||
gpuName={gpu}
|
gpuName={gpu}
|
||||||
|
gpuMemory={gpuDetails[index]}
|
||||||
messageHistory={messageHistory}
|
messageHistory={messageHistory}
|
||||||
period={selectedPeriod}
|
period={selectedPeriod}
|
||||||
key={index}
|
key={index}
|
||||||
@@ -311,6 +314,7 @@ export default function ServerDetailChart({
|
|||||||
now={nezhaWsData.now}
|
now={nezhaWsData.now}
|
||||||
gpuStat={gpu}
|
gpuStat={gpu}
|
||||||
gpuName={`#${index + 1}`}
|
gpuName={`#${index + 1}`}
|
||||||
|
gpuMemory={gpuDetails[index]}
|
||||||
messageHistory={messageHistory}
|
messageHistory={messageHistory}
|
||||||
period={selectedPeriod}
|
period={selectedPeriod}
|
||||||
key={index}
|
key={index}
|
||||||
@@ -426,6 +430,7 @@ function GpuChart({
|
|||||||
index,
|
index,
|
||||||
gpuStat,
|
gpuStat,
|
||||||
gpuName,
|
gpuName,
|
||||||
|
gpuMemory,
|
||||||
messageHistory,
|
messageHistory,
|
||||||
period,
|
period,
|
||||||
}: {
|
}: {
|
||||||
@@ -434,6 +439,7 @@ function GpuChart({
|
|||||||
index: number;
|
index: number;
|
||||||
gpuStat: number;
|
gpuStat: number;
|
||||||
gpuName?: string;
|
gpuName?: string;
|
||||||
|
gpuMemory?: { memory_used?: number; memory_total?: number };
|
||||||
messageHistory: NezhaWebsocketResponse[];
|
messageHistory: NezhaWebsocketResponse[];
|
||||||
period: ChartPeriod;
|
period: ChartPeriod;
|
||||||
}) {
|
}) {
|
||||||
@@ -532,6 +538,14 @@ function GpuChart({
|
|||||||
<section className="flex flex-col items-center gap-2">
|
<section className="flex flex-col items-center gap-2">
|
||||||
{!gpuName && <p className="text-md font-medium">GPU</p>}
|
{!gpuName && <p className="text-md font-medium">GPU</p>}
|
||||||
{gpuName && <p className="text-xs mt-1 mb-1.5">GPU: {gpuName}</p>}
|
{gpuName && <p className="text-xs mt-1 mb-1.5">GPU: {gpuName}</p>}
|
||||||
|
{gpuMemory?.memory_total ? (
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{gpuMemory.memory_used != null
|
||||||
|
? formatBytes(gpuMemory.memory_used * 1024 * 1024)
|
||||||
|
: "—"}{" "}
|
||||||
|
/ {formatBytes(gpuMemory.memory_total * 1024 * 1024)}
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
<section className="flex items-center gap-2">
|
<section className="flex items-center gap-2">
|
||||||
<p className="text-xs text-end w-10 font-medium">
|
<p className="text-xs text-end w-10 font-medium">
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ export interface NezhaServerStatus {
|
|||||||
process_count: number;
|
process_count: number;
|
||||||
temperatures: temperature[];
|
temperatures: temperature[];
|
||||||
gpu: number[];
|
gpu: number[];
|
||||||
|
// Per-card figures; index-aligned with host.gpu. Absent on older agents.
|
||||||
|
gpus?: {
|
||||||
|
utilization: number;
|
||||||
|
memory_used?: number;
|
||||||
|
memory_total?: number;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface temperature {
|
interface temperature {
|
||||||
|
|||||||
Reference in new issue
Block a user