changeset 1076:5616cab8b6d6

mod_statistics/stats.lib.lua: Better s2s session counting
author Kim Alvefur <zash@zash.se>
date Sat, 15 Jun 2013 20:56:19 +0100
parents 164ed759b1d2
children b73d44afdafa
files mod_statistics/stats.lib.lua
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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 ()