comparison mod_statistics/stats.lib.lua @ 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
comparison
equal deleted inserted replaced
1075:164ed759b1d2 1076:5616cab8b6d6
3 3
4 local last_cpu_wall, last_cpu_clock; 4 local last_cpu_wall, last_cpu_clock;
5 local get_time = require "socket".gettime; 5 local get_time = require "socket".gettime;
6 6
7 local active_sessions, active_jids = {}, {}; 7 local active_sessions, active_jids = {}, {};
8 local s2s_sessions = module:shared"/*/s2s/sessions";
9 local c2s_sessions = module:shared"/*/c2s/sessions";
8 10
9 local stats = { 11 local stats = {
10 total_users = { 12 total_users = {
11 get = function () return it.count(it.keys(bare_sessions)); end 13 get = function () return it.count(it.keys(bare_sessions)); end
12 }; 14 };
13 total_c2s = { 15 total_c2s = {
14 get = function () return it.count(it.keys(full_sessions)); end 16 get = function () return it.count(it.keys(full_sessions)); end
15 }; 17 };
16 total_s2sin = { 18 total_s2sin = {
17 get = function () return it.count(it.keys(prosody.incoming_s2s)); end 19 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
18 }; 20 };
19 total_s2sout = { 21 total_s2sout = {
20 get = function () 22 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
21 local count = 0; 23 };
22 for host, host_session in pairs(hosts) do 24 total_s2s = {
23 count = count + it.count(it.keys(host_session.s2sout)); 25 get = function () return it.count(it.keys(s2s_sessions)); end
24 end
25 return count;
26 end
27 }; 26 };
28 total_component = { 27 total_component = {
29 get = function () 28 get = function ()
30 local count = 0; 29 local count = 0;
31 for host, host_session in pairs(hosts) do 30 for host, host_session in pairs(hosts) do