Software /
code /
prosody
Changeset
6936:2ca1d54d4b92
mod_admin_telnet: Add timer:info() which shows some basic info about util.timer
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 25 Nov 2015 15:34:54 +0100 |
parents | 6935:d12917643e65 |
children | 6947:032313f356c9 |
files | plugins/mod_admin_telnet.lua |
diffstat | 1 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua Tue Nov 24 10:45:48 2015 +0000 +++ b/plugins/mod_admin_telnet.lua Wed Nov 25 15:34:54 2015 +0100 @@ -334,6 +334,38 @@ 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)