aboutsummaryrefslogtreecommitdiffstats
path: root/teal-src
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-11-30 12:41:26 +0000
committerMatthew Wild <mwild1@gmail.com>2023-11-30 12:41:26 +0000
commit56d45091bdcc75292a73a789a017b36721efa2e6 (patch)
tree4acd22a75311aa832376d42bf0ff47d549d025d5 /teal-src
parent090f4830bb067206adb51ce73cf1195642cfe168 (diff)
downloadprosody-56d45091bdcc75292a73a789a017b36721efa2e6.tar.gz
prosody-56d45091bdcc75292a73a789a017b36721efa2e6.zip
mod_cron: Update Teal source and rebuild
Diffstat (limited to 'teal-src')
-rw-r--r--teal-src/prosody/plugins/mod_cron.tl26
1 files changed, 26 insertions, 0 deletions
diff --git a/teal-src/prosody/plugins/mod_cron.tl b/teal-src/prosody/plugins/mod_cron.tl
index c5a02cc9..9c6f1601 100644
--- a/teal-src/prosody/plugins/mod_cron.tl
+++ b/teal-src/prosody/plugins/mod_cron.tl
@@ -105,3 +105,29 @@ scheduled = module:add_timer(1, function() : integer
end);
-- TODO measure load, pick a good time to do stuff
+
+module:add_item("shell-command", {
+ section = "cron";
+ section_desc = "View and manage recurring tasks";
+ name = "tasks";
+ desc = "View registered tasks";
+ args = {};
+ handler = function (self, filter_host : string)
+ local format_table = require "prosody.util.human.io".table;
+ local it = require "util.iterators";
+ local row = format_table({
+ { title = "Host", width = "2p" };
+ { title = "Task", width = "3p" };
+ { title = "Desc", width = "3p" };
+ { title = "When", width = "1p" };
+ { title = "Last run", width = "20" };
+ }, self.session.width);
+ local print = self.session.print;
+ print(row());
+ for host in it.sorted_pairs(filter_host and { [filter_host]=true } or active_hosts) do
+ for _, task in ipairs(module:context(host):get_host_items("task")) do
+ print(row { host, task.id, task.name, task.when, task.last and os.date("%Y-%m-%d %R:%S", task.last) or "never" });
+ end
+ end
+ end;
+});