mirror of https://github.com/calzoneman/sync.git
Fix socket.io counters
This commit is contained in:
parent
44745d86ac
commit
edcf17984f
|
@ -2,6 +2,7 @@ var Logger = require('./logger');
|
|||
var counterLog = new Logger.Logger('counters.log');
|
||||
import os from 'os';
|
||||
import io from 'socket.io';
|
||||
import Socket from 'socket.io/lib/socket';
|
||||
|
||||
var counters = {};
|
||||
|
||||
|
@ -17,11 +18,17 @@ exports.add = function (counter, value) {
|
|||
}
|
||||
};
|
||||
|
||||
Socket.prototype._packet = Socket.prototype.packet;
|
||||
Socket.prototype.packet = function () {
|
||||
this._packet.apply(this, arguments);
|
||||
exports.add('socket.io:packet');
|
||||
};
|
||||
|
||||
setInterval(function () {
|
||||
try {
|
||||
counters['memory:rss'] = process.memoryUsage().rss / 1048576;
|
||||
counters['load:1min'] = os.loadavg()[0];
|
||||
counters['socket.io:count'] = io.instance.sockets.length;
|
||||
counters['socket.io:count'] = io.instance.sockets.sockets.length;
|
||||
counterLog.log(JSON.stringify(counters));
|
||||
} catch (e) {
|
||||
Logger.errlog.log(e.stack);
|
||||
|
|
Loading…
Reference in New Issue