1
0
mirror of https://git.fuwafuwa.moe/SMLoadrDev/SMLoadr synced 2024-11-15 03:34:32 +01:00
SMLoadr/libs/node-memory-stats/platforms/linux.js

16 lines
458 B
JavaScript
Raw Normal View History

const exec = require('child_process').execSync;
module.exports = class Linux {
static getTotalMemory() {
return parseInt(exec('free -b | grep "Mem:" | awk \'{print $2}\'', {'encoding': 'utf8'}), 10);
}
static getUsedMemory() {
return parseInt(exec('free -b | grep "Mem:" | awk \'{print $7}\'', {'encoding': 'utf8'}), 10);
}
static getFreeMemory() {
return this.getTotalMemory() - this.getUsedMemory();
}
};