changeset 1263:fe29627a5ed8

mod_http_user_count: HTTP module to report the current number of online users or sessions
author Matthew Wild <mwild1@gmail.com>
date Fri, 03 Jan 2014 16:24:11 -0500
parents 1e84eebf3f46
children 2db2c03dfb95
files mod_http_user_count/mod_http_user_count.lua
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mod_http_user_count/mod_http_user_count.lua	Fri Jan 03 16:24:11 2014 -0500
@@ -0,0 +1,10 @@
+local it = require "util.iterators";
+
+module:depends("http");
+
+module:provides("http", {
+    route = {
+        ["GET /sessions"] = function () return tostring(it.count(it.keys(prosody.full_sessions))); end;
+        ["GET /users"] = function () return tostring(it.count(it.keys(prosody.bare_sessions))); end;
+    };
+});