Checkpoint
This commit is contained in:
parent
f4e25a76b3
commit
58c577c4bb
|
@ -24,12 +24,22 @@ const packageJson = require('../package.json');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const async = require('async');
|
||||||
|
|
||||||
exports.getPredefinedMCIValue = getPredefinedMCIValue;
|
exports.getPredefinedMCIValue = getPredefinedMCIValue;
|
||||||
exports.init = init;
|
exports.init = init;
|
||||||
|
|
||||||
function init(cb) {
|
function init(cb) {
|
||||||
setNextRandomRumor(cb);
|
async.series(
|
||||||
|
[
|
||||||
|
(callback) => {
|
||||||
|
return setNextRandomRumor(callback);
|
||||||
|
},
|
||||||
|
],
|
||||||
|
err => {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNextRandomRumor(cb) {
|
function setNextRandomRumor(cb) {
|
||||||
|
@ -65,10 +75,6 @@ function userStatAsCountString(client, statName, defaultValue) {
|
||||||
return toNumberWithCommas(value);
|
return toNumberWithCommas(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sysStatAsString(statName, defaultValue) {
|
|
||||||
return (StatLog.getSystemStat(statName) || defaultValue).toLocaleString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const PREDEFINED_MCI_GENERATORS = {
|
const PREDEFINED_MCI_GENERATORS = {
|
||||||
//
|
//
|
||||||
// Board
|
// Board
|
||||||
|
@ -212,11 +218,14 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
.trim();
|
.trim();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// :TODO: use new live stat
|
||||||
|
MB : function totalMemoryBytes() { return getTotalMemoryBytes(); },
|
||||||
|
MF : function totalMemoryFreeBytes() { return getTotalMemoryFreeBytes(); },
|
||||||
|
|
||||||
// :TODO: MCI for core count, e.g. os.cpus().length
|
// :TODO: MCI for core count, e.g. os.cpus().length
|
||||||
|
|
||||||
// :TODO: cpu load average (over N seconds): http://stackoverflow.com/questions/9565912/convert-the-output-of-os-cpus-in-node-js-to-percentage
|
// :TODO: cpu load average (over N seconds): http://stackoverflow.com/questions/9565912/convert-the-output-of-os-cpus-in-node-js-to-percentage
|
||||||
NV : function nodeVersion() { return process.version; },
|
NV : function nodeVersion() { return process.version; },
|
||||||
|
|
||||||
AN : function activeNodes() { return clientConnections.getActiveConnections().length.toString(); },
|
AN : function activeNodes() { return clientConnections.getActiveConnections().length.toString(); },
|
||||||
|
|
||||||
TC : function totalCalls() { return StatLog.getSystemStat(SysProps.LoginCount).toLocaleString(); },
|
TC : function totalCalls() { return StatLog.getSystemStat(SysProps.LoginCount).toLocaleString(); },
|
||||||
|
@ -236,12 +245,12 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
//
|
//
|
||||||
// :TODO: DD - Today's # of downloads (iNiQUiTY)
|
// :TODO: DD - Today's # of downloads (iNiQUiTY)
|
||||||
//
|
//
|
||||||
SD : function systemNumDownloads() { return sysStatAsString(SysProps.FileDlTotalCount, 0); },
|
SD : function systemNumDownloads() { return StatLog.getFriendlySystemStat(SysProps.FileDlTotalCount, 0); },
|
||||||
SO : function systemByteDownload() {
|
SO : function systemByteDownload() {
|
||||||
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTotalBytes);
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileDlTotalBytes);
|
||||||
return formatByteSize(byteSize, true); // true=withAbbr
|
return formatByteSize(byteSize, true); // true=withAbbr
|
||||||
},
|
},
|
||||||
SU : function systemNumUploads() { return sysStatAsString(SysProps.FileUlTotalCount, 0); },
|
SU : function systemNumUploads() { return StatLog.getFriendlySystemStat(SysProps.FileUlTotalCount, 0); },
|
||||||
SP : function systemByteUpload() {
|
SP : function systemByteUpload() {
|
||||||
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTotalBytes);
|
const byteSize = StatLog.getSystemStatNum(SysProps.FileUlTotalBytes);
|
||||||
return formatByteSize(byteSize, true); // true=withAbbr
|
return formatByteSize(byteSize, true); // true=withAbbr
|
||||||
|
@ -256,10 +265,10 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
return formatByteSize(totalBytes, true); // true=withAbbr
|
return formatByteSize(totalBytes, true); // true=withAbbr
|
||||||
},
|
},
|
||||||
PT : function messagesPostedToday() { // Obv/2
|
PT : function messagesPostedToday() { // Obv/2
|
||||||
return sysStatAsString(SysProps.MessagesToday, 0);
|
return StatLog.getFriendlySystemStat(SysProps.MessagesToday, 0);
|
||||||
},
|
},
|
||||||
TP : function totalMessagesOnSystem() { // Obv/2
|
TP : function totalMessagesOnSystem() { // Obv/2
|
||||||
return sysStatAsString(SysProps.MessageTotalCount, 0);
|
return StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
// :TODO: NT - New users today (Obv/2)
|
// :TODO: NT - New users today (Obv/2)
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
}
|
|
@ -30,4 +30,12 @@ module.exports = {
|
||||||
// end +op non-persistent
|
// end +op non-persistent
|
||||||
|
|
||||||
NextRandomRumor : 'random_rumor',
|
NextRandomRumor : 'random_rumor',
|
||||||
|
|
||||||
|
// begin system stat non-persistent...
|
||||||
|
TotalMemoryBytes : 'sys_total_memory_bytes',
|
||||||
|
FreeMemoryBytes : 'sys_free_memory_bytes',
|
||||||
|
AverageLoad : 'sys_average_load',
|
||||||
|
CurrentLoad : 'sys_current_load',
|
||||||
|
|
||||||
|
// end system stat non persistent
|
||||||
};
|
};
|
||||||
|
|
49
core/wfc.js
49
core/wfc.js
|
@ -4,9 +4,6 @@ const { MenuModule } = require('./menu_module');
|
||||||
const { getActiveConnectionList } = require('./client_connections');
|
const { getActiveConnectionList } = require('./client_connections');
|
||||||
const StatLog = require('./stat_log');
|
const StatLog = require('./stat_log');
|
||||||
const SysProps = require('./system_property');
|
const SysProps = require('./system_property');
|
||||||
const {
|
|
||||||
formatByteSize, formatByteSizeAbbr,
|
|
||||||
} = require('./string_util');
|
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
|
@ -81,8 +78,6 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
|
|
||||||
_refreshStats(cb) {
|
_refreshStats(cb) {
|
||||||
const fileAreaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
const fileAreaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
||||||
const totalFiles = fileAreaStats.totalFiles || 0;
|
|
||||||
const totalFileBytes = fileAreaStats.totalBytes || 0;
|
|
||||||
|
|
||||||
// Some stats we can just fill right away
|
// Some stats we can just fill right away
|
||||||
this.stats = {
|
this.stats = {
|
||||||
|
@ -92,23 +87,37 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
dateTime : moment().format(this.getDateTimeFormat()),
|
dateTime : moment().format(this.getDateTimeFormat()),
|
||||||
|
|
||||||
// Current process (our Node.js service)
|
// Current process (our Node.js service)
|
||||||
processUptime : moment.duration(process.uptime(), 'seconds').humanize(),
|
processUptimeSeconds : process.uptime(),
|
||||||
|
// processUptime : moment.duration(process.uptime(), 'seconds').humanize(),
|
||||||
|
|
||||||
// Totals
|
// Totals
|
||||||
totalCalls : StatLog.getFriendlySystemStat(SysProps.LoginCount, 0),
|
totalCalls : StatLog.getSystemStatNum(SysProps.LoginCount),
|
||||||
totalPosts : StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0),
|
totalPosts : StatLog.getSystemStatNum(SysProps.MessageTotalCount),
|
||||||
//totalUsers :
|
//totalUsers :
|
||||||
totalFiles : totalFiles.toLocaleString(),
|
totalFiles : fileAreaStats.totalFiles || 0,
|
||||||
totalFileBytes : formatByteSize(totalFileBytes, false),
|
totalFileBytes : fileAreaStats.totalFileBytes || 0,
|
||||||
totalFileBytesAbbr : formatByteSizeAbbr(totalFileBytes),
|
|
||||||
// :TODO: Most/All current user status should be predefined MCI
|
// totalUploads :
|
||||||
|
// totalUploadBytes :
|
||||||
|
// totalDownloads :
|
||||||
|
// totalDownloadBytes :
|
||||||
|
|
||||||
// :TODO: lastCaller
|
// :TODO: lastCaller
|
||||||
// :TODO: totalMemoryBytes, freeMemoryBytes
|
// :TODO: totalMemoryBytes, freeMemoryBytes
|
||||||
// :TODO: CPU info/averages/load
|
// :TODO: CPU info/averages/load
|
||||||
// :TODO: processUptime
|
|
||||||
// :TODO: 24 HOUR stats -
|
|
||||||
// callsToday, postsToday, uploadsToday, uploadBytesToday, ...
|
|
||||||
|
|
||||||
|
// Today's Stats
|
||||||
|
callsToday : StatLog.getSystemStatNum(SysProps.LoginsToday),
|
||||||
|
postsToday : StatLog.getSystemStatNum(SysProps.MessagesToday),
|
||||||
|
// uploadsToday :
|
||||||
|
// uploadBytesToday :
|
||||||
|
// downloadsToday :
|
||||||
|
// downloadBytesToday :
|
||||||
|
|
||||||
|
// Current
|
||||||
|
// lastCaller :
|
||||||
|
// lastCallerDate
|
||||||
|
// lastCallerTime
|
||||||
};
|
};
|
||||||
|
|
||||||
// Some async work required...
|
// Some async work required...
|
||||||
|
@ -119,14 +128,12 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
|
|
||||||
SysInfo.get(basicSysInfo)
|
SysInfo.get(basicSysInfo)
|
||||||
.then(sysInfo => {
|
.then(sysInfo => {
|
||||||
this.stats.totalMemoryBytes = formatByteSize(sysInfo.mem.total, false);
|
this.stats.totalMemoryBytes = sysInfo.mem.total;
|
||||||
this.stats.totalMemoryBytesAbbr = formatByteSizeAbbr(sysInfo.mem.total);
|
this.stats.freeMemoryBytes = sysInfo.mem.free;
|
||||||
this.stats.freeMemoryBytes = formatByteSize(sysInfo.mem.free, false);
|
|
||||||
this.stats.freeMemoryBytesAbbr = formatByteSizeAbbr(sysInfo.mem.free);
|
|
||||||
|
|
||||||
// Not avail on BSD, yet.
|
// Not avail on BSD, yet.
|
||||||
this.stats.systemAvgLoad = _.get(sysInfo, 'currentLoad.avgload', 0).toString();
|
this.stats.systemAvgLoad = _.get(sysInfo, 'currentLoad.avgload', 0);
|
||||||
this.stats.systemCurrentLoad = _.get(sysInfo, 'currentLoad.currentLoad', 0).toString();
|
this.stats.systemCurrentLoad = _.get(sysInfo, 'currentLoad.currentLoad', 0);
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
return cb(err);
|
return cb(err);
|
||||||
|
|
Loading…
Reference in New Issue