diff --git a/src/counters.js b/src/counters.js index a708cfa6..e83a8cd7 100644 --- a/src/counters.js +++ b/src/counters.js @@ -8,6 +8,7 @@ import * as Metrics from 'cytube-common/lib/metrics/metrics'; import { JSONFileMetricsReporter } from 'cytube-common/lib/metrics/jsonfilemetricsreporter'; var counters = {}; +var server = null; exports.add = Metrics.incCounter; @@ -26,9 +27,32 @@ function getConnectedSockets() { } } +function setChannelCounts(metrics) { + if (server === null) { + server = require('./server').getServer(); + } + + try { + var publicCount = 0; + var allCount = 0; + server.channels.forEach(function (c) { + allCount++; + if (c.modules.options && c.modules.options.get("show_public")) { + publicCount++; + } + }); + + metrics.addProperty('channelCount:all', allCount); + metrics.addProperty('channelCount:public', publicCount); + } catch (error) { + Logger.errlog.log(error.stack); + } +} + const reporter = new JSONFileMetricsReporter('counters.log'); Metrics.setReporter(reporter); Metrics.setReportInterval(60000); Metrics.addReportHook((metrics) => { - metrics.incCounter('socket.io:count', getConnectedSockets()); + metrics.addProperty('socket.io:count', getConnectedSockets()); + setChannelCounts(metrics); }); diff --git a/www/js/callbacks.js b/www/js/callbacks.js index 67b2d6dc..f75ddb69 100644 --- a/www/js/callbacks.js +++ b/www/js/callbacks.js @@ -1121,7 +1121,7 @@ setupCallbacks = function() { var servers; if (socketConfig.alt && socketConfig.alt.length > 0 && - localStorage.useAltServer) { + localStorage.useAltServer === "true") { servers = socketConfig.alt; console.log("Using alt servers: " + JSON.stringify(servers)); } else {