Check for statsLine not blockDevice
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user