mirror of https://github.com/calzoneman/sync.git
ACP stats
This commit is contained in:
parent
002888a0de
commit
27834e1211
|
@ -285,6 +285,12 @@ function handleForceUnload(user, data) {
|
||||||
Logger.eventlog.log("[acp] " + eventUsername(user) + " forced unload of " + name);
|
Logger.eventlog.log("[acp] " + eventUsername(user) + " forced unload of " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleListStats(user) {
|
||||||
|
db.listStats(function (err, rows) {
|
||||||
|
user.socket.emit("acp-list-stats", rows);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function init(user) {
|
function init(user) {
|
||||||
var s = user.socket;
|
var s = user.socket;
|
||||||
s.on("acp-announce", handleAnnounce.bind(this, user));
|
s.on("acp-announce", handleAnnounce.bind(this, user));
|
||||||
|
@ -298,6 +304,7 @@ function init(user) {
|
||||||
s.on("acp-delete-channel", handleDeleteChannel.bind(this, user));
|
s.on("acp-delete-channel", handleDeleteChannel.bind(this, user));
|
||||||
s.on("acp-list-activechannels", handleListActiveChannels.bind(this, user));
|
s.on("acp-list-activechannels", handleListActiveChannels.bind(this, user));
|
||||||
s.on("acp-force-unload", handleForceUnload.bind(this, user));
|
s.on("acp-force-unload", handleForceUnload.bind(this, user));
|
||||||
|
s.on("acp-list-stats", handleListStats.bind(this, user));
|
||||||
|
|
||||||
db.listGlobalBans(function (err, bans) {
|
db.listGlobalBans(function (err, bans) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -118,11 +118,11 @@ html(lang="en")
|
||||||
pre#acp-eventlog-text
|
pre#acp-eventlog-text
|
||||||
#acp-stats.acp-panel.col-md-12(style="display: none")
|
#acp-stats.acp-panel.col-md-12(style="display: none")
|
||||||
h3 User Count
|
h3 User Count
|
||||||
canvas#stat_users(width="100%", height="400")
|
canvas#stat_users(width="1140", height="400")
|
||||||
h3 Channel Count
|
h3 Channel Count
|
||||||
canvas#stat_channels(width="100%", height="400")
|
canvas#stat_channels(width="1140", height="400")
|
||||||
h3 Memory Usage
|
h3 Memory Usage
|
||||||
canvas#stat_mem(width="100%", height="400")
|
canvas#stat_mem(width="1140", height="400")
|
||||||
|
|
||||||
include footer
|
include footer
|
||||||
mixin footer()
|
mixin footer()
|
||||||
|
@ -132,4 +132,5 @@ html(lang="en")
|
||||||
script(src="/sioconfig")
|
script(src="/sioconfig")
|
||||||
script(src="/assets/js/util.js")
|
script(src="/assets/js/util.js")
|
||||||
script(src="/assets/js/paginator.js")
|
script(src="/assets/js/paginator.js")
|
||||||
|
script(src="/assets/js/chart.js")
|
||||||
script(src="/js/acp.js")
|
script(src="/js/acp.js")
|
||||||
|
|
|
@ -441,6 +441,79 @@ function filterEventLog() {
|
||||||
$("#acp-eventlog-filter").change(filterEventLog);
|
$("#acp-eventlog-filter").change(filterEventLog);
|
||||||
$("#acp-eventlog-refresh").click(readEventlog);
|
$("#acp-eventlog-refresh").click(readEventlog);
|
||||||
|
|
||||||
|
/* Stats */
|
||||||
|
|
||||||
|
$("a:contains('Stats')").click(function () {
|
||||||
|
socket.emit("acp-list-stats");
|
||||||
|
});
|
||||||
|
|
||||||
|
socket.on("acp-list-stats", function (rows) {
|
||||||
|
var labels = [];
|
||||||
|
var ucounts = [];
|
||||||
|
var ccounts = [];
|
||||||
|
var mcounts = [];
|
||||||
|
var lastdate = "";
|
||||||
|
rows.forEach(function (r) {
|
||||||
|
var d = new Date(parseInt(r.time));
|
||||||
|
var t = "";
|
||||||
|
if (d.toDateString() !== lastdate) {
|
||||||
|
lastdate = d.toDateString();
|
||||||
|
t = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
|
||||||
|
t += " " + d.toTimeString().split(" ")[0];
|
||||||
|
} else {
|
||||||
|
t = d.toTimeString().split(" ")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
labels.push(t);
|
||||||
|
ucounts.push(r.usercount);
|
||||||
|
ccounts.push(r.chancount);
|
||||||
|
mcounts.push(r.mem / 1048576);
|
||||||
|
});
|
||||||
|
|
||||||
|
var userdata = {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
fillColor: "rgba(151, 187, 205, 0.5)",
|
||||||
|
strokeColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointStrokeColor: "#fff",
|
||||||
|
data: ucounts
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var channeldata = {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
fillColor: "rgba(151, 187, 205, 0.5)",
|
||||||
|
strokeColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointStrokeColor: "#fff",
|
||||||
|
data: ccounts
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var memdata = {
|
||||||
|
labels: labels,
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
fillColor: "rgba(151, 187, 205, 0.5)",
|
||||||
|
strokeColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointColor: "rgba(151, 187, 205, 1)",
|
||||||
|
pointStrokeColor: "#fff",
|
||||||
|
data: mcounts
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
new Chart($("#stat_users")[0].getContext("2d")).Line(userdata);
|
||||||
|
new Chart($("#stat_channels")[0].getContext("2d")).Line(channeldata);
|
||||||
|
new Chart($("#stat_mem")[0].getContext("2d")).Line(memdata);
|
||||||
|
});
|
||||||
|
|
||||||
/* Initialize keyed table sorts */
|
/* Initialize keyed table sorts */
|
||||||
$("table").each(function () {
|
$("table").each(function () {
|
||||||
var table = $(this);
|
var table = $(this);
|
||||||
|
|
Loading…
Reference in New Issue