Some more stats
This commit is contained in:
parent
52ae983cb4
commit
d6cc53c263
|
@ -689,4 +689,20 @@ exports.MenuModule = class MenuModule extends PluginModule {
|
||||||
|
|
||||||
return cb(good ? null : Errors.Invalid(`Invalid or missing config option "${firstBadKey}" (${badReason})`));
|
return cb(good ? null : Errors.Invalid(`Invalid or missing config option "${firstBadKey}" (${badReason})`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Various common helpers
|
||||||
|
getDateFormat(defaultStyle='short') {
|
||||||
|
return this.config.dateFormat ||
|
||||||
|
this.client.currentTheme.helpers.getDateFormat(defaultStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
getTimeFormat(defaultStyle='short') {
|
||||||
|
return this.config.timeFormat ||
|
||||||
|
this.client.currentTheme.helpers.getTimeFormat(defaultStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
getDateTimeFormat(defaultStyle='short') {
|
||||||
|
return this.config.dateTimeFormat ||
|
||||||
|
this.client.currentTheme.helpers.getDateTimeFormat(defaultStyle);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -267,6 +267,7 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
// :TODO: DD - Files downloaded *today* (iNiQUiTY)
|
// :TODO: DD - Files downloaded *today* (iNiQUiTY)
|
||||||
// :TODO: LC - name of last caller to system (Obv/2)
|
// :TODO: LC - name of last caller to system (Obv/2)
|
||||||
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)
|
// :TODO: TZ - Average *system* post/call ratio (iNiQUiTY)
|
||||||
|
// :TODO: ?? - Total users on system
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -337,7 +337,7 @@ function formatByteSizeAbbr(byteSize) {
|
||||||
|
|
||||||
function formatByteSize(byteSize, withAbbr = false, decimals = 2) {
|
function formatByteSize(byteSize, withAbbr = false, decimals = 2) {
|
||||||
const i = 0 === byteSize ? byteSize : Math.floor(Math.log(byteSize) / Math.log(1024));
|
const i = 0 === byteSize ? byteSize : Math.floor(Math.log(byteSize) / Math.log(1024));
|
||||||
let result = parseFloat((byteSize / Math.pow(1024, i)).toFixed(decimals));
|
let result = parseFloat((byteSize / Math.pow(1024, i)).toFixed(decimals)).toString();
|
||||||
if(withAbbr) {
|
if(withAbbr) {
|
||||||
result += ` ${BYTE_SIZE_ABBRS[i]}`;
|
result += ` ${BYTE_SIZE_ABBRS[i]}`;
|
||||||
}
|
}
|
||||||
|
|
40
core/wfc.js
40
core/wfc.js
|
@ -11,6 +11,8 @@ const {
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
const moment = require('moment');
|
||||||
|
const SysInfo = require('systeminformation');
|
||||||
|
|
||||||
exports.moduleInfo = {
|
exports.moduleInfo = {
|
||||||
name : 'WFC',
|
name : 'WFC',
|
||||||
|
@ -63,6 +65,9 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
// return this.validateMCIByViewIds('main', requiredCodes, callback);
|
// return this.validateMCIByViewIds('main', requiredCodes, callback);
|
||||||
return callback(null);
|
return callback(null);
|
||||||
},
|
},
|
||||||
|
(callback) => {
|
||||||
|
return this._refreshStats(callback);
|
||||||
|
},
|
||||||
(callback) => {
|
(callback) => {
|
||||||
return this._refreshNodeStatus(callback);
|
return this._refreshNodeStatus(callback);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +84,16 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
const totalFiles = fileAreaStats.totalFiles || 0;
|
const totalFiles = fileAreaStats.totalFiles || 0;
|
||||||
const totalFileBytes = fileAreaStats.totalBytes || 0;
|
const totalFileBytes = fileAreaStats.totalBytes || 0;
|
||||||
|
|
||||||
|
// Some stats we can just fill right away
|
||||||
this.stats = {
|
this.stats = {
|
||||||
|
// Date/Time
|
||||||
|
date : moment().format(this.getDateFormat()),
|
||||||
|
time : moment().format(this.getTimeFormat()),
|
||||||
|
dateTime : moment().format(this.getDateTimeFormat()),
|
||||||
|
|
||||||
|
// Current process (our Node.js service)
|
||||||
|
processUptime : moment.duration(process.uptime(), 'seconds').humanize(),
|
||||||
|
|
||||||
// Totals
|
// Totals
|
||||||
totalCalls : StatLog.getFriendlySystemStat(SysProps.LoginCount, 0),
|
totalCalls : StatLog.getFriendlySystemStat(SysProps.LoginCount, 0),
|
||||||
totalPosts : StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0),
|
totalPosts : StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0),
|
||||||
|
@ -87,18 +101,36 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
totalFiles : totalFiles.toLocaleString(),
|
totalFiles : totalFiles.toLocaleString(),
|
||||||
totalFileBytes : formatByteSize(totalFileBytes, false),
|
totalFileBytes : formatByteSize(totalFileBytes, false),
|
||||||
totalFileBytesAbbr : formatByteSizeAbbr(totalFileBytes),
|
totalFileBytesAbbr : formatByteSizeAbbr(totalFileBytes),
|
||||||
// :TODO: date, time - formatted as per config.dateTimeFormat and such
|
|
||||||
// :TODO: Most/All current user status should be predefined MCI
|
// :TODO: Most/All current user status should be predefined MCI
|
||||||
// :TODO: lastCaller
|
// :TODO: lastCaller
|
||||||
// :TODO: totalMemoryBytes, freeMemoryBytes
|
// :TODO: totalMemoryBytes, freeMemoryBytes
|
||||||
// :TODO: CPU info/averages/load
|
// :TODO: CPU info/averages/load
|
||||||
// :TODO: processUptime
|
// :TODO: processUptime
|
||||||
// :TODO: 24 HOUR stats -
|
// :TODO: 24 HOUR stats -
|
||||||
// calls24Hour, posts24Hour, uploadBytes24Hour, downloadBytes24Hour, ...
|
// callsToday, postsToday, uploadsToday, uploadBytesToday, ...
|
||||||
// :TODO: totals - most avail from MCI
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return cb(null);
|
// Some async work required...
|
||||||
|
const basicSysInfo = {
|
||||||
|
mem : 'total, free',
|
||||||
|
currentLoad : 'avgload, currentLoad',
|
||||||
|
};
|
||||||
|
|
||||||
|
SysInfo.get(basicSysInfo)
|
||||||
|
.then(sysInfo => {
|
||||||
|
this.stats.totalMemoryBytes = formatByteSize(sysInfo.mem.total, false);
|
||||||
|
this.stats.totalMemoryBytesAbbr = formatByteSizeAbbr(sysInfo.mem.total);
|
||||||
|
this.stats.freeMemoryBytes = formatByteSize(sysInfo.mem.free, false);
|
||||||
|
this.stats.freeMemoryBytesAbbr = formatByteSizeAbbr(sysInfo.mem.free);
|
||||||
|
|
||||||
|
// Not avail on BSD, yet.
|
||||||
|
this.stats.systemAvgLoad = _.get(sysInfo, 'currentLoad.avgload', 0).toString();
|
||||||
|
this.stats.systemCurrentLoad = _.get(sysInfo, 'currentLoad.currentLoad', 0).toString();
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
return cb(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_refreshNodeStatus(cb) {
|
_refreshNodeStatus(cb) {
|
||||||
|
|
|
@ -59,7 +59,8 @@
|
||||||
"uuid-parse": "1.1.0",
|
"uuid-parse": "1.1.0",
|
||||||
"ws": "^7.3.0",
|
"ws": "^7.3.0",
|
||||||
"xxhash": "^0.3.0",
|
"xxhash": "^0.3.0",
|
||||||
"yazl": "^2.5.1"
|
"yazl": "^2.5.1",
|
||||||
|
"systeminformation" : "^4.27.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.2.0"
|
"eslint": "^7.2.0"
|
||||||
|
|
|
@ -2306,6 +2306,11 @@ supports-color@^7.1.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
has-flag "^4.0.0"
|
has-flag "^4.0.0"
|
||||||
|
|
||||||
|
systeminformation@^4.27.5:
|
||||||
|
version "4.29.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/systeminformation/-/systeminformation-4.29.3.tgz#6dac4ff96479f1dd5df50582a965afb4c76178f2"
|
||||||
|
integrity sha512-C5+o6hit4BQpFdZKxXwRqgDpAkXCjxAUi5pB3UznjYPl3XQugwo1V46XltUt+53EaphlHA6j41mh++ksdOuBMA==
|
||||||
|
|
||||||
table@^5.2.3:
|
table@^5.2.3:
|
||||||
version "5.4.6"
|
version "5.4.6"
|
||||||
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
|
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
|
||||||
|
|
Loading…
Reference in New Issue