aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_telnet.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-11-25 15:34:54 +0100
committerKim Alvefur <zash@zash.se>2015-11-25 15:34:54 +0100
commit237847b4d5a439a19d128f14f898f224a97bdf6e (patch)
tree095ca32040d08241b94779133b3afbc106e3a5af /plugins/mod_admin_telnet.lua
parent425f0ca2293d0778fea1060049e5b77f791a7ce5 (diff)
downloadprosody-237847b4d5a439a19d128f14f898f224a97bdf6e.tar.gz
prosody-237847b4d5a439a19d128f14f898f224a97bdf6e.zip
mod_admin_telnet: Add timer:info() which shows some basic info about util.timer
Diffstat (limited to 'plugins/mod_admin_telnet.lua')
-rw-r--r--plugins/mod_admin_telnet.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index e2aaa7bc..7aea28ba 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -334,6 +334,38 @@ function def_env.server:memory()
return true, "OK";
end
+def_env.timer = {};
+
+function def_env.timer:info()
+ local print = self.session.print;
+ local add_task = require"util.timer".add_task;
+ local h, params = add_task.h, add_task.params;
+ print("-- util.timer");
+ for i, id in ipairs(h.ids) do
+ if not params[id] then
+ print(os.date("%F %T", h.priorities[i]), h.items[id]);
+ elseif not params[id].callback then
+ print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id]));
+ else
+ print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id]));
+ end
+ end
+ if server.event_base then
+ local count = 0;
+ for k, v in pairs(debug.getregistry()) do
+ if type(v) == "function" and v.callback == add_task._on_timer then
+ count = count + 1;
+ end
+ end
+ print(count .. " libevent callbacks");
+ end
+ local next_time = h:peek();
+ if next_time then
+ return true, os.date("Next event at %F %T", next_time);
+ end
+ return true;
+end
+
def_env.module = {};
local function get_hosts_set(hosts, module)