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

@ -1,3 +1,8 @@
Thu Sep 26 23:08 2013 CDT
* lib/acp.js, lib/api.js, lib/server.js, lib/stats.js, www/acp.html,
www/assets/js/acp.js: Remove the [realtime] 'connection stats'
tracking that was pretty worthless anyways.
Thu Sep 26 21:42 2013 CDT
* www/assets/js/player.js: Keep track of the duration of the current
video and use this information to prevent the player restarting when

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;
}
};
}

View file

@ -46,7 +46,6 @@
<li id="li_chanloaded"><a href="javascript:void(0)" id="show_chanloaded">Loaded Channels</a></li>
<li id="li_actionlog"><a href="javascript:void(0)" id="show_actionlog">Action Log</a></li>
<li id="li_stats"><a href="javascript:void(0)" id="show_stats">Server Stats</a></li>
<li id="li_connstats"><a href="javascript:void(0)" id="show_connstats">Connection Stats</a></li>
</ul>
</li>
</ul>
@ -250,21 +249,6 @@
<h3>Memory Usage (MB)</h3>
<canvas id="stat_mem" width="1170" height="400"></canvas>
</div>
<div class="span12" id="connstats">
<h3>Connection Stats</h3>
<strong>Note: </strong>Data points for which the frequency average is 0 are not displayed.
<br>
<button class="btn" id="connstats_refresh">Refresh</button>
<table class="table table-bordered table-striped" id="connstats">
<thead>
<tr>
<th>Type</th>
<th>Param</th>
<th>Frequency</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>

View file

@ -147,13 +147,6 @@ menuHandler("#show_stats", "#stats");
$("#show_stats").click(function () {
socket.emit("acp-view-stats");
});
menuHandler("#show_connstats", "#connstats");
$("#show_connstats").click(function () {
socket.emit("acp-view-connstats");
});
$("#connstats_refresh").click(function () {
socket.emit("acp-view-connstats");
});
function reverseLog() {
$("#log").text($("#log").text().split("\n").reverse().join("\n"));
@ -555,48 +548,4 @@ function setupCallbacks() {
$("<option/>").text(a).val(a).appendTo($("#actionlog_filter"));
});
});
socket.on("acp-view-connstats", function (data) {
var tbl = $("#connstats table");
tbl.find("tbody").remove();
var flat = [];
for(var key in data) {
var d = data[key];
for(var k in d) {
flat.push({
type: key,
param: k,
freq: d[k]
});
}
}
flat.sort(function (a, b) {
var x = a.freq, y = b.freq;
if(x == y) {
var c = a.type + a.param;
var d = b.type + b.param;
return c == d ? 0 : (c < d ? -1 : 1);
}
return y - x;
});
for(var i in flat) {
i = flat[i];
if(i.freq == 0)
return;
var tr = $("<tr/>").appendTo(tbl);
$("<td/>").text(i.type).appendTo(tr);
$("<td/>").text(i.param).appendTo(tr);
$("<td/>").text(i.freq + " hits/sec average").appendTo(tr);
if(i.freq > 50) {
tr.addClass("error");
} else if(i.freq > 10) {
tr.addClass("warning");
}
}
});
}