Add Process/enig start ingress/egress bytes stats

This commit is contained in:
Bryan Ashby
2022-08-01 23:09:18 -06:00
parent 044cc24418
commit 715202680e
10 changed files with 51 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ const Errors = require('./enig_error.js');
const SysProps = require('./system_property.js');
const UserProps = require('./user_property');
const Message = require('./message');
const { getActiveConnections, AllConnections } = require('./client_connections');
// deps
const _ = require('lodash');
@@ -360,6 +361,9 @@ class StatLog {
case SysProps.SystemLoadStats:
case SysProps.SystemMemoryStats:
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) {
switch (statName) {
case UserProps.NewPrivateMailCount: