Remove mostly useless realtime connection stats

This commit is contained in:
calzoneman 2013-09-26 23:10:00 -05:00
parent 08a39c8857
commit 2f813c1d11
7 changed files with 6 additions and 137 deletions

View file

@ -174,18 +174,6 @@ module.exports = function (Server) {
user.socket.emit("acp-view-stats", res);
});
});
user.socket.on("acp-view-connstats", function () {
var http = Server.stats.readAverages("http");
var sio = Server.stats.readAverages("socketio");
var api = Server.stats.readAverages("api");
user.socket.emit("acp-view-connstats", {
http: http,
sio: sio,
api: api
});
});
}
}
}

View file

@ -56,7 +56,6 @@ module.exports = function (Server) {
/* <https://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol> */
app.get("/api/coffee", function (req, res) {
Server.stats.record("api", "/api/coffee");
res.send(418); // 418 I'm a teapot
});
@ -64,7 +63,6 @@ module.exports = function (Server) {
/* data about a specific channel */
app.get("/api/channels/:channel", function (req, res) {
Server.stats.record("api", "/api/channels/:channel");
var name = req.params.channel;
if(!$util.isValidChannelName(name)) {
res.send(404);
@ -85,7 +83,6 @@ module.exports = function (Server) {
/* data about all channels (filter= public or all) */
app.get("/api/allchannels/:filter", function (req, res) {
Server.stats.record("api", "/api/allchannels/:filter");
var filter = req.params.filter;
if(filter !== "public" && filter !== "all") {
res.send(400);
@ -144,7 +141,6 @@ module.exports = function (Server) {
/* login */
app.post("/api/login", function (req, res) {
Server.stats.record("api", "/api/login");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
var name = req.body.name;
@ -186,7 +182,6 @@ module.exports = function (Server) {
/* register an account */
app.post("/api/register", function (req, res) {
Server.stats.record("api", "/api/register");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
var name = req.body.name;
@ -258,7 +253,6 @@ module.exports = function (Server) {
/* password change */
app.post("/api/account/passwordchange", function (req, res) {
Server.stats.record("api", "/api/account/passwordchange");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
@ -302,7 +296,6 @@ module.exports = function (Server) {
/* password reset */
app.post("/api/account/passwordreset", function (req, res) {
Server.stats.record("api", "/api/account/passwordreset");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
var name = req.body.name;
@ -372,7 +365,6 @@ module.exports = function (Server) {
/* password recovery */
app.get("/api/account/passwordrecover", function (req, res) {
Server.stats.record("api", "/api/account/passwordrecover");
res.type("application/jsonp");
var hash = req.query.hash;
var ip = getIP(req);
@ -397,7 +389,6 @@ module.exports = function (Server) {
/* profile retrieval */
app.get("/api/users/:user/profile", function (req, res) {
Server.stats.record("api", "/api/users/:user/profile");
res.type("application/jsonp");
var name = req.params.user;
@ -420,7 +411,6 @@ module.exports = function (Server) {
/* profile change */
app.post("/api/account/profile", function (req, res) {
Server.stats.record("api", "/api/account/profile");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
var name = req.body.name;
@ -468,7 +458,6 @@ module.exports = function (Server) {
/* set email */
app.post("/api/account/email", function (req, res) {
Server.stats.record("api", "/api/account/email");
res.type("application/jsonp");
res.setHeader("Access-Control-Allow-Origin", "*");
var name = req.body.name;
@ -519,7 +508,6 @@ module.exports = function (Server) {
/* my channels */
app.get("/api/account/mychannels", function (req, res) {
Server.stats.record("/api/account/mychannels");
res.type("application/jsonp");
var name = req.query.name;
var session = req.query.session;
@ -557,7 +545,6 @@ module.exports = function (Server) {
/* action log */
app.get("/api/logging/actionlog", function (req, res) {
Server.stats.record("api", "/api/logging/actionlog");
res.type("application/jsonp");
var name = req.query.name;
var session = req.query.session;
@ -608,7 +595,6 @@ module.exports = function (Server) {
}
app.get("/api/logging/syslog", function (req, res) {
Server.stats.record("api", "/api/logging/syslog");
res.type("text/plain");
res.setHeader("Access-Control-Allow-Origin", "*");
@ -636,7 +622,6 @@ module.exports = function (Server) {
});
app.get("/api/logging/errorlog", function (req, res) {
Server.stats.record("api", "/api/logging/errorlog");
res.type("text/plain");
res.setHeader("Access-Control-Allow-Origin", "*");
@ -664,7 +649,6 @@ module.exports = function (Server) {
});
app.get("/api/logging/channels/:channel", function (req, res) {
Server.stats.record("api", "/api/logging/channels/:channel");
res.type("text/plain");
res.setHeader("Access-Control-Allow-Origin", "*");

View file

@ -70,7 +70,6 @@ var Server = {
}
chan.dead = true;
},
stats: null,
app: null,
io: null,
httpserv: null,
@ -98,7 +97,6 @@ var Server = {
},
handleIOConnection: function (socket) {
var self = this;
self.stats.record("socketio", "socket");
var ip = getSocketIP(socket);
socket._ip = ip;
self.db.isGlobalIPBanned(ip, function (err, bant) {
@ -149,7 +147,6 @@ var Server = {
res.redirect("/" + c);
}
else {
self.stats.record("http", "/r/" + c);
self.logHTTP(req);
res.sendfile("channel.html", {
root: path.join(__dirname, "../www")
@ -162,7 +159,6 @@ var Server = {
self.app.get("/", function (req, res, next) {
self.logHTTP(req);
self.stats.record("http", "/");
res.sendfile("index.html", {
root: path.join(__dirname, "../www")
});
@ -193,7 +189,6 @@ var Server = {
}
}
else {
self.stats.record("http", req.params.thing);
self.logHTTP(req);
}
});
@ -247,7 +242,7 @@ var Server = {
self.acp = require("./acp")(self);
// init stats
self.stats = require("./stats")(self);
require("./stats")(self);
// init media retriever
self.infogetter = require("./get-info")(self);

View file

@ -30,40 +30,4 @@ module.exports = function (Server) {
db.pruneStats(Date.now() - STAT_EXPIRE);
});
}, STAT_INTERVAL);
return {
stores: {
"http": {},
"socketio": {},
"api": {}
},
record: function (type, key) {
var store;
if(!(type in this.stores))
return;
store = this.stores[type];
if(key in store) {
store[key].push(Date.now());
if(store[key].length > 100)
store[key].shift();
} else {
store[key] = [Date.now()];
}
},
readAverages: function (type) {
if(!(type in this.stores))
return;
var avg = {};
var store = this.stores[type];
for(var k in store) {
var time = Date.now() - store[k][0];
avg[k] = store[k].length / time;
avg[k] = parseInt(avg[k] * 1000);
}
return avg;
}
};
}