|
@@ -25,6 +25,11 @@ local main_domain = string.gsub(module.host, muc_domain_prefix..'.', '');
|
25
|
25
|
|
26
|
26
|
local NICK_NS = 'http://jabber.org/protocol/nick';
|
27
|
27
|
|
|
28
|
+-- we send stats for the total number of rooms, total number of participants and total number of visitors
|
|
29
|
+local measure_rooms = module:measure("vnode-rooms", "amount");
|
|
30
|
+local measure_participants = module:measure("vnode-participants", "amount");
|
|
31
|
+local measure_visitors = module:measure("vnode-visitors", "amount");
|
|
32
|
+
|
28
|
33
|
-- This is the domain of the main prosody that is federating with us;
|
29
|
34
|
local fmuc_main_domain;
|
30
|
35
|
|
|
@@ -294,3 +299,28 @@ module:hook('muc-private-message', function(event)
|
294
|
299
|
"Private messaging is disabled on visitor nodes"));
|
295
|
300
|
return true;
|
296
|
301
|
end, 10);
|
|
302
|
+
|
|
303
|
+-- we calculate the stats on the configured interval (60 seconds by default)
|
|
304
|
+module:hook_global("stats-update", function ()
|
|
305
|
+ local participants_count, rooms_count, visitors_count = 0, 0, 0;
|
|
306
|
+
|
|
307
|
+ -- iterate over all rooms
|
|
308
|
+ for room in prosody.hosts[module.host].modules.muc.each_room() do
|
|
309
|
+ rooms_count = rooms_count + 1;
|
|
310
|
+ for _, o in room:each_occupant() do
|
|
311
|
+ if jid.host(o.bare_jid) == main_domain then
|
|
312
|
+ visitors_count = visitors_count + 1;
|
|
313
|
+ else
|
|
314
|
+ participants_count = participants_count + 1;
|
|
315
|
+ end
|
|
316
|
+ end
|
|
317
|
+ -- do not count jicofo
|
|
318
|
+ participants_count = participants_count - 1;
|
|
319
|
+ end
|
|
320
|
+
|
|
321
|
+ measure_rooms(rooms_count);
|
|
322
|
+ measure_visitors(visitors_count);
|
|
323
|
+ measure_participants(participants_count);
|
|
324
|
+end);
|
|
325
|
+
|
|
326
|
+
|