Check for statsLine not blockDevice

This commit is contained in:
Johannes Zellner
2025-10-14 15:22:57 +02:00
parent b2fc7df06d
commit 25d6ec157f
+1 -1
View File
@@ -112,7 +112,7 @@ async function readDiskMetrics() {
const diskstats = await fs.promises.readFile('/proc/diskstats', { encoding: 'utf8' });
const statsLine = diskstats.split('\n').find(l => l.includes(` ${blockDevice} `));
if (!blockDevice) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get disk stats');
if (!statsLine) throw new BoxError(BoxError.EXTERNAL_ERROR, 'Could not get disk stats');
const parts = statsLine.trim().split(/\s+/);
const sectorsRead = parseInt(parts[5], 10); // field 6 . one sectiro is 512 bytes