Add Process/enig start ingress/egress bytes stats
This commit is contained in:
parent
044cc24418
commit
715202680e
|
@ -276,6 +276,8 @@
|
||||||
mainInfoFormat21: "|00|10{totalPosts:>7}"
|
mainInfoFormat21: "|00|10{totalPosts:>7}"
|
||||||
mainInfoFormat22: "|00|10{totalUsers:>5}"
|
mainInfoFormat22: "|00|10{totalUsers:>5}"
|
||||||
mainInfoFormat23: "|00|10{totalFiles:>4} |08/ |10{totalFileBytes!sizeWithoutAbbr:>4} |02{totalFileBytes!sizeAbbr}"
|
mainInfoFormat23: "|00|10{totalFiles:>4} |08/ |10{totalFileBytes!sizeWithoutAbbr:>4} |02{totalFileBytes!sizeAbbr}"
|
||||||
|
mainInfoFormat24: "|00|10{processBytesIngress!sizeWithoutAbbr:>5} |02{processBytesIngress!sizeAbbr}"
|
||||||
|
mainInfoFormat25: "|00|10{processBytesEgress!sizeWithoutAbbr:>5} |02{processBytesEgress!sizeAbbr}"
|
||||||
|
|
||||||
quickLogLevel: info
|
quickLogLevel: info
|
||||||
quickLogLevelIndicators: {
|
quickLogLevelIndicators: {
|
||||||
|
|
Binary file not shown.
|
@ -122,6 +122,15 @@ function addNewClient(client, clientSock) {
|
||||||
moment().valueOf(),
|
moment().valueOf(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// kludge to refresh process update stats at first client
|
||||||
|
if (clientConnections.length < 1) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const StatLog = require('./stat_log');
|
||||||
|
const SysProps = require('./system_property');
|
||||||
|
StatLog.getSystemStat(SysProps.ProcessTrafficStats);
|
||||||
|
}, 3000); // slight pause to wait for updates
|
||||||
|
}
|
||||||
|
|
||||||
clientConnections.push(client);
|
clientConnections.push(client);
|
||||||
clientConnections.sort((c1, c2) => c1.session.id - c2.session.id);
|
clientConnections.sort((c1, c2) => c1.session.id - c2.session.id);
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ module.exports = class LoginServerModule extends ServerModule {
|
||||||
client.session = {};
|
client.session = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.rawSocket = clientSock;
|
||||||
client.session.serverName = modInfo.name;
|
client.session.serverName = modInfo.name;
|
||||||
client.session.isSecure = _.isBoolean(client.isSecure)
|
client.session.isSecure = _.isBoolean(client.isSecure)
|
||||||
? client.isSecure
|
? client.isSecure
|
||||||
|
|
|
@ -385,6 +385,19 @@ const PREDEFINED_MCI_GENERATORS = {
|
||||||
return StatLog.getSystemStat(SysProps.LoginsToday).toLocaleString();
|
return StatLog.getSystemStat(SysProps.LoginsToday).toLocaleString();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
PI: function processBytesIngress() {
|
||||||
|
const stats = StatLog.getSystemStat(SysProps.ProcessTrafficStats) || {
|
||||||
|
ingress: 0,
|
||||||
|
};
|
||||||
|
return stats.ingress.toLocaleString();
|
||||||
|
},
|
||||||
|
PE: function processBytesEgress() {
|
||||||
|
const stats = StatLog.getSystemStat(SysProps.ProcessTrafficStats) || {
|
||||||
|
egress: 0,
|
||||||
|
};
|
||||||
|
return stats.ingress.toLocaleString();
|
||||||
|
},
|
||||||
|
|
||||||
RR: function randomRumor() {
|
RR: function randomRumor() {
|
||||||
// start the process of picking another random one
|
// start the process of picking another random one
|
||||||
setNextRandomRumor();
|
setNextRandomRumor();
|
||||||
|
|
|
@ -7,6 +7,7 @@ const Errors = require('./enig_error.js');
|
||||||
const SysProps = require('./system_property.js');
|
const SysProps = require('./system_property.js');
|
||||||
const UserProps = require('./user_property');
|
const UserProps = require('./user_property');
|
||||||
const Message = require('./message');
|
const Message = require('./message');
|
||||||
|
const { getActiveConnections, AllConnections } = require('./client_connections');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
@ -360,6 +361,9 @@ class StatLog {
|
||||||
case SysProps.SystemLoadStats:
|
case SysProps.SystemLoadStats:
|
||||||
case SysProps.SystemMemoryStats:
|
case SysProps.SystemMemoryStats:
|
||||||
return this._refreshSysInfoStats();
|
return this._refreshSysInfoStats();
|
||||||
|
|
||||||
|
case SysProps.ProcessTrafficStats:
|
||||||
|
return this._refreshProcessTrafficStats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,6 +406,19 @@ class StatLog {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_refreshProcessTrafficStats() {
|
||||||
|
const trafficStats = getActiveConnections(AllConnections).reduce(
|
||||||
|
(stats, conn) => {
|
||||||
|
stats.ingress += conn.rawSocket.bytesRead;
|
||||||
|
stats.egress += conn.rawSocket.bytesWritten;
|
||||||
|
return stats;
|
||||||
|
},
|
||||||
|
{ ingress: 0, egress: 0 }
|
||||||
|
);
|
||||||
|
|
||||||
|
this.setNonPersistentSystemStat(SysProps.ProcessTrafficStats, trafficStats);
|
||||||
|
}
|
||||||
|
|
||||||
_refreshUserStat(client, statName, ttlSeconds) {
|
_refreshUserStat(client, statName, ttlSeconds) {
|
||||||
switch (statName) {
|
switch (statName) {
|
||||||
case UserProps.NewPrivateMailCount:
|
case UserProps.NewPrivateMailCount:
|
||||||
|
|
|
@ -37,6 +37,7 @@ module.exports = {
|
||||||
|
|
||||||
SystemMemoryStats: 'system_memory_stats', // object { totalBytes, freeBytes }; non-persistent
|
SystemMemoryStats: 'system_memory_stats', // object { totalBytes, freeBytes }; non-persistent
|
||||||
SystemLoadStats: 'system_load_stats', // object { average, current }; non-persistent
|
SystemLoadStats: 'system_load_stats', // object { average, current }; non-persistent
|
||||||
|
ProcessTrafficStats: 'system_traffic_bytes_ingress', // object { ingress, egress }; non-persistent
|
||||||
|
|
||||||
TotalUserCount: 'user_total_count', // non-persistent
|
TotalUserCount: 'user_total_count', // non-persistent
|
||||||
NewUsersTodayCount: 'user_new_today_count', // non-persistent
|
NewUsersTodayCount: 'user_new_today_count', // non-persistent
|
||||||
|
|
|
@ -413,6 +413,8 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
const sysMemStats = StatLog.getSystemStat(SysProps.SystemMemoryStats) || {};
|
const sysMemStats = StatLog.getSystemStat(SysProps.SystemMemoryStats) || {};
|
||||||
const sysLoadStats = StatLog.getSystemStat(SysProps.SystemLoadStats) || {};
|
const sysLoadStats = StatLog.getSystemStat(SysProps.SystemLoadStats) || {};
|
||||||
const lastLoginStats = StatLog.getSystemStat(SysProps.LastLogin);
|
const lastLoginStats = StatLog.getSystemStat(SysProps.LastLogin);
|
||||||
|
const processTrafficStats =
|
||||||
|
StatLog.getSystemStat(SysProps.ProcessTrafficStats) || {};
|
||||||
|
|
||||||
const now = moment();
|
const now = moment();
|
||||||
|
|
||||||
|
@ -479,6 +481,8 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||||
UserProps.NewAddressedToMessageCount,
|
UserProps.NewAddressedToMessageCount,
|
||||||
MailCountTTLSeconds
|
MailCountTTLSeconds
|
||||||
),
|
),
|
||||||
|
processBytesIngress: processTrafficStats.ingress || 0,
|
||||||
|
processBytesEgress: processTrafficStats.egress || 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
return cb(null);
|
return cb(null);
|
||||||
|
|
|
@ -109,6 +109,8 @@ There are many predefined MCI codes that can be used anywhere on the system (pla
|
||||||
| `NP` | Count of new private mail to the current user |
|
| `NP` | Count of new private mail to the current user |
|
||||||
| `IA` | Indicator as to rather the current user is **available** or not. See also `getStatusAvailIndicators()` in [Themes](themes.md) |
|
| `IA` | Indicator as to rather the current user is **available** or not. See also `getStatusAvailIndicators()` in [Themes](themes.md) |
|
||||||
| `IV` | Indicator as to rather the curent user is **visible** or not. See also `getStatusVisibleIndicators()` in [Themes](themes.md) |
|
| `IV` | Indicator as to rather the curent user is **visible** or not. See also `getStatusVisibleIndicators()` in [Themes](themes.md) |
|
||||||
|
| `PI` | Ingress bytes for the current process (since ENiGMA started up) |
|
||||||
|
| `PE` | Egress bytes for the current process (since ENiGMA started up) |
|
||||||
|
|
||||||
Some additional special case codes also exist:
|
Some additional special case codes also exist:
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,8 @@ The following MCI codes are available:
|
||||||
* `newMessagesAddrTo`: Number of new messages **addressed to the current user**.
|
* `newMessagesAddrTo`: Number of new messages **addressed to the current user**.
|
||||||
* `availIndicator`: Is the current user availalbe? Displayed via `statusAvailableIndicators` or system theme. See also [Themes](../art/themes.md).
|
* `availIndicator`: Is the current user availalbe? Displayed via `statusAvailableIndicators` or system theme. See also [Themes](../art/themes.md).
|
||||||
* `visIndicator`: Is the current user visible? Displayed via `statusVisibleIndicators` or system theme. See also [Themes](../art/themes.md).
|
* `visIndicator`: Is the current user visible? Displayed via `statusVisibleIndicators` or system theme. See also [Themes](../art/themes.md).
|
||||||
|
* `processBytesIngress`: Ingress bytes since ENiGMA started.
|
||||||
|
* `processBytesEgress`: Egress bytes since ENiGMA started.
|
||||||
|
|
||||||
|
|
||||||
> :information_source: While [Standard MCI](../art/mci.md) codes work on any menu, they will **not** refresh. For values that may change over time, please use the custom format values above.
|
> :information_source: While [Standard MCI](../art/mci.md) codes work on any menu, they will **not** refresh. For values that may change over time, please use the custom format values above.
|
Loading…
Reference in New Issue