fix: dashdot gpu (#5347)
This commit is contained in:
1 parent
e9c908b317
commit
192a43a031
1 file changed
+19
-17
@@ -85,7 +85,7 @@ export class DashDotIntegration extends Integration implements ISystemHealthMoni
|
|||||||
cpuModel: serverInfo.cpu.model,
|
cpuModel: serverInfo.cpu.model,
|
||||||
operatingSystemVersion: `${serverInfo.os.distro} ${serverInfo.os.release} (${serverInfo.os.kernel})`,
|
operatingSystemVersion: `${serverInfo.os.distro} ${serverInfo.os.release} (${serverInfo.os.kernel})`,
|
||||||
uptime: serverInfo.os.uptime,
|
uptime: serverInfo.os.uptime,
|
||||||
gpuNames: serverInfo.gpu.map((gpu) => gpu.brand),
|
gpuNames: serverInfo.gpu.layout.map((gpu) => gpu.brand),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +161,14 @@ export class DashDotIntegration extends Integration implements ISystemHealthMoni
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async getCurrentGpuLoadAsync() {
|
private async getCurrentGpuLoadAsync() {
|
||||||
const response = await fetchWithTrustedCertificatesAsync(this.url("/load/gpu"));
|
try {
|
||||||
const result = await response.text();
|
const response = await fetchWithTrustedCertificatesAsync(this.url("/load/gpu"));
|
||||||
|
const result = await response.json();
|
||||||
// response is either valid json or empty if gpu widget is disabled.
|
const data = await gpuLoadApi.parseAsync(result);
|
||||||
if (result.length === 0) return [];
|
return data.layout;
|
||||||
|
} catch {
|
||||||
const data = await gpuLoadApi.parseAsync(JSON.parse(result));
|
return [];
|
||||||
return data.layout;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getChannel() {
|
private getChannel() {
|
||||||
@@ -219,14 +219,16 @@ const internalServerInfoApi = z.object({
|
|||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
gpu: z
|
gpu: z.object({
|
||||||
.array(
|
layout: z
|
||||||
z.object({
|
.array(
|
||||||
brand: z.string(),
|
z.object({
|
||||||
model: z.string().optional(),
|
brand: z.string(),
|
||||||
}),
|
model: z.string().optional(),
|
||||||
)
|
}),
|
||||||
.default([]),
|
)
|
||||||
|
.default([]),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const cpuLoadPerCoreApiList = z.array(cpuLoadPerCoreApi);
|
const cpuLoadPerCoreApiList = z.array(cpuLoadPerCoreApi);
|
||||||
|
|||||||
Reference in new issue
Block a user