# HG changeset patch # User Kim Alvefur # Date 1371326179 -3600 # Node ID 5616cab8b6d6e749157f6fd5c459456e6cc83f82 # Parent 164ed759b1d255b6d864e135ea08beedb72b4142 mod_statistics/stats.lib.lua: Better s2s session counting diff -r 164ed759b1d2 -r 5616cab8b6d6 mod_statistics/stats.lib.lua --- a/mod_statistics/stats.lib.lua Sat Jun 15 20:43:10 2013 +0100 +++ b/mod_statistics/stats.lib.lua Sat Jun 15 20:56:19 2013 +0100 @@ -5,6 +5,8 @@ local get_time = require "socket".gettime; local active_sessions, active_jids = {}, {}; +local s2s_sessions = module:shared"/*/s2s/sessions"; +local c2s_sessions = module:shared"/*/c2s/sessions"; local stats = { total_users = { @@ -14,16 +16,13 @@ get = function () return it.count(it.keys(full_sessions)); end }; total_s2sin = { - get = function () return it.count(it.keys(prosody.incoming_s2s)); end + get = function () local i = 0; for conn,sess in next,s2s_sessions do if sess.direction == "incoming" then i = i + 1 end end return i end }; total_s2sout = { - get = function () - local count = 0; - for host, host_session in pairs(hosts) do - count = count + it.count(it.keys(host_session.s2sout)); - end - return count; - end + get = function () local i = 0; for conn,sess in next,s2s_sessions do if sess.direction == "outgoing" then i = i + 1 end end return i end + }; + total_s2s = { + get = function () return it.count(it.keys(s2s_sessions)); end }; total_component = { get = function ()