Checkpoint

This commit is contained in:
Bryan Ashby
2020-11-22 12:25:19 -07:00
parent f4e25a76b3
commit 58c577c4bb
4 changed files with 87 additions and 35 deletions

28
core/stat_log_system.js Normal file
View File

@@ -0,0 +1,28 @@
// deps
const SysInfo = require('systeminformation');
const _ = require('lodash');
exports.getSystemInfoStats = getSystemInfoStats;
function getSystemInfoStats(cb) {
const basicSysInfo = {
mem : 'total, free',
currentLoad : 'avgload, currentLoad',
};
SysInfo.get(basicSysInfo)
.then(sysInfo => {
return cb(null, {
totalMemoryBytes : sysInfo.mem.total,
freeMemoryBytes : sysInfo.mem.free,
// Not avail on BSD, yet.
systemAvgLoad : _.get(sysInfo, 'currentLoad.avgload', 0),
systemCurrentLoad : _.get(sysInfo, 'currentLoad.currentLoad', 0),
});
})
.catch(err => {
return cb(err);
});
}