fix: calculate available space correctly and filter unmounted drives (#2885)

This commit is contained in:
Jacob Hemming
2025-04-18 12:49:59 +02:00
committed by GitHub
parent 9570abb2c3
commit cfca0ba583

View File

@@ -30,13 +30,15 @@ export class DashDotIntegration extends Integration {
cpuUtilization: cpuLoad.sumLoad, cpuUtilization: cpuLoad.sumLoad,
memUsed: `${memoryLoad.loadInBytes}`, memUsed: `${memoryLoad.loadInBytes}`,
memAvailable: `${info.maxAvailableMemoryBytes - memoryLoad.loadInBytes}`, memAvailable: `${info.maxAvailableMemoryBytes - memoryLoad.loadInBytes}`,
fileSystem: info.storage.map((storage, index) => ({ fileSystem: info.storage
deviceName: `Storage ${index + 1}: (${storage.disks.map((disk) => disk.device).join(", ")})`, .filter((_, index) => storageLoad[index] !== -1) // filter out undermoutned drives, they display as -1 in the load API
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion .map((storage, index) => ({
used: humanFileSize(storageLoad[index]!), deviceName: `Storage ${index + 1}: (${storage.disks.map((disk) => disk.device).join(", ")})`,
available: `${storage.size}`, // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
percentage: storageLoad[index] ? (storageLoad[index] / storage.size) * 100 : 0, used: humanFileSize(storageLoad[index]!),
})), available: storageLoad[index] ? `${storage.size - storageLoad[index]}` : `${storage.size}`,
percentage: storageLoad[index] ? (storageLoad[index] / storage.size) * 100 : 0,
})),
cpuModelName: info.cpuModel === "" ? `Unknown Model (${info.cpuBrand})` : `${info.cpuModel} (${info.cpuBrand})`, cpuModelName: info.cpuModel === "" ? `Unknown Model (${info.cpuBrand})` : `${info.cpuModel} (${info.cpuBrand})`,
cpuTemp: cpuLoad.averageTemperature, cpuTemp: cpuLoad.averageTemperature,
availablePkgUpdates: 0, availablePkgUpdates: 0,