Comparison

plugins/mod_admin_shell.lua @ 12540:0684506c99d3

mod_admin_shell: Include last (mod_cron) task run time in module:info() Don't think this is otherwise shown anywhere outside of debug logs
author Kim Alvefur <zash@zash.se>
date Wed, 01 Jun 2022 17:27:17 +0200
parent 12538:0f56587bb37f
child 12551:3b7e97e0a8ef
comparison
equal deleted inserted replaced
12539:cfdc8cca64d3 12540:0684506c99d3
494 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts"; 494 return false, "mod_" .. name .. " does not appear to be loaded on the specified hosts";
495 end 495 end
496 496
497 local function item_name(item) return item.name; end 497 local function item_name(item) return item.name; end
498 498
499 local function task_timefmt(t)
500 if not t then
501 return "no last run time"
502 elseif os.difftime(os.time(), t) < 86400 then
503 return os.date("last run today at %H:%M", t);
504 else
505 return os.date("last run %A at %H:%M", t);
506 end
507 end
508
499 local friendly_descriptions = { 509 local friendly_descriptions = {
500 ["adhoc-provider"] = "Ad-hoc commands", 510 ["adhoc-provider"] = "Ad-hoc commands",
501 ["auth-provider"] = "Authentication provider", 511 ["auth-provider"] = "Authentication provider",
502 ["http-provider"] = "HTTP services", 512 ["http-provider"] = "HTTP services",
503 ["net-provider"] = "Network service", 513 ["net-provider"] = "Network service",
526 end, 536 end,
527 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, 537 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end,
528 ["metric"] = function(item) 538 ["metric"] = function(item)
529 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); 539 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description));
530 end, 540 end,
531 ["task"] = function (item) return string.format("%s (%s)", item.name or item.id, item.when); end 541 ["task"] = function (item) return string.format("%s (%s, %s)", item.name or item.id, item.when, task_timefmt(item.last)); end
532 }; 542 };
533 543
534 for host in hosts do 544 for host in hosts do
535 local mod = modulemanager.get_module(host, name); 545 local mod = modulemanager.get_module(host, name);
536 if mod.module.host == "*" then 546 if mod.module.host == "*" then