Software /
code /
prosody
Comparison
plugins/mod_admin_telnet.lua @ 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 |
parent | 6928:02717098cbba |
child | 6988:329d5fb8a9d3 |
comparison
equal
deleted
inserted
replaced
6935:d12917643e65 | 6936:2ca1d54d4b92 |
---|---|
332 print(" Used: "..human(mem.used/1024).." ("..human(lua_mem).." by Lua)"); | 332 print(" Used: "..human(mem.used/1024).." ("..human(lua_mem).." by Lua)"); |
333 print(" Free: "..human(mem.unused/1024).." ("..human(mem.returnable/1024).." returnable)"); | 333 print(" Free: "..human(mem.unused/1024).." ("..human(mem.returnable/1024).." returnable)"); |
334 return true, "OK"; | 334 return true, "OK"; |
335 end | 335 end |
336 | 336 |
337 def_env.timer = {}; | |
338 | |
339 function def_env.timer:info() | |
340 local print = self.session.print; | |
341 local add_task = require"util.timer".add_task; | |
342 local h, params = add_task.h, add_task.params; | |
343 print("-- util.timer"); | |
344 for i, id in ipairs(h.ids) do | |
345 if not params[id] then | |
346 print(os.date("%F %T", h.priorities[i]), h.items[id]); | |
347 elseif not params[id].callback then | |
348 print(os.date("%F %T", h.priorities[i]), h.items[id], unpack(params[id])); | |
349 else | |
350 print(os.date("%F %T", h.priorities[i]), params[id].callback, unpack(params[id])); | |
351 end | |
352 end | |
353 if server.event_base then | |
354 local count = 0; | |
355 for k, v in pairs(debug.getregistry()) do | |
356 if type(v) == "function" and v.callback == add_task._on_timer then | |
357 count = count + 1; | |
358 end | |
359 end | |
360 print(count .. " libevent callbacks"); | |
361 end | |
362 local next_time = h:peek(); | |
363 if next_time then | |
364 return true, os.date("Next event at %F %T", next_time); | |
365 end | |
366 return true; | |
367 end | |
368 | |
337 def_env.module = {}; | 369 def_env.module = {}; |
338 | 370 |
339 local function get_hosts_set(hosts, module) | 371 local function get_hosts_set(hosts, module) |
340 if type(hosts) == "table" then | 372 if type(hosts) == "table" then |
341 if hosts[1] then | 373 if hosts[1] then |