Experiment with realtime stats of connection load

This commit is contained in:
calzoneman 2013-08-19 23:53:33 -05:00
parent 779bdb4067
commit e748d79349
6 changed files with 172 additions and 41 deletions

View file

@ -46,6 +46,7 @@
<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>
@ -249,6 +250,21 @@
<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,6 +147,13 @@ 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"));
@ -548,6 +555,50 @@ 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");
}
}
});
}
/* cookie util */