annotate teal-src/prosody/plugins/mod_cron.tl @ 14229:ce31fdde0ad1 default tip

net.unbound: Simplify conditional
author Kim Alvefur <zash@zash.se>
date Sat, 13 Jun 2026 11:35:18 +0200
parents 8b05340a94d3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 module:set_global();
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
12979
fbbf4f0db8f0 teal: Move into prosody namespace
Kim Alvefur <zash@zash.se>
parents: 12503
diff changeset
3 local async = require "prosody.util.async";
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
13442
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
5 local cron_initial_delay = module:get_option_number("cron_initial_delay", 1);
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
6 local cron_check_delay = module:get_option_number("cron_check_delay", 3600);
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
7 local cron_spread_factor = module:get_option_number("cron_spread_factor", 0);
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
8
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
9 local record map_store<K,V>
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 -- TODO move to somewhere sensible
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11 get : function (map_store<K,V>, string, K) : V
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
12 set : function (map_store<K,V>, string, K, V)
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 local enum frequency
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 "hourly"
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 "daily"
12002
cbed7d8d8f35 mod_cron: Add a 'weekly' job frequency
Kim Alvefur <zash@zash.se>
parents: 12001
diff changeset
18 "weekly"
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 local record task_spec
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 id : string -- unique id
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
23 name : string -- name or short description
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
24 when : frequency
13284
ffd3dadf6247 mod_cron: Make task frequencies configurable in overly generic manner
Kim Alvefur <zash@zash.se>
parents: 13283
diff changeset
25 period : number
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
26 last : integer
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 run : function (task_spec, integer)
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 save : function (task_spec, integer)
13283
1c63b8c3cd9d mod_cron: Fix missing restore method in Teal record definition
Kim Alvefur <zash@zash.se>
parents: 13269
diff changeset
29 restore : function (task_spec, integer)
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
31
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
32 local record task_event
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
33 source : module
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
34 item : task_spec
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
35 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
36
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
37 local active_hosts : { string : boolean } = { }
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
38
13884
8b05340a94d3 mod_cron: Move changes to Teal source
Kim Alvefur <zash@zash.se>
parents: 13878
diff changeset
39 if prosody.process_type == "prosodyctl" then
8b05340a94d3 mod_cron: Move changes to Teal source
Kim Alvefur <zash@zash.se>
parents: 13878
diff changeset
40 return -- Yes, it happens...
8b05340a94d3 mod_cron: Move changes to Teal source
Kim Alvefur <zash@zash.se>
parents: 13878
diff changeset
41 end
8b05340a94d3 mod_cron: Move changes to Teal source
Kim Alvefur <zash@zash.se>
parents: 13878
diff changeset
42
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
43 function module.add_host(host_module : moduleapi)
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
44
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
45 local last_run_times = host_module:open_store("cron", "map") as map_store<string,integer>;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
46 active_hosts[host_module.host] = true;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
47
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
48 local function save_task(task : task_spec, started_at : integer)
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
49 last_run_times:set(nil, task.id, started_at);
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
50 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
51
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
52 local function restore_task(task : task_spec)
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
53 if task.last == nil then
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
54 task.last = last_run_times:get(nil, task.id);
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
55 end
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
56 end
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
57
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
58 local function task_added(event : task_event) : boolean
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
59 local task = event.item;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
60 if task.name == nil then
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
61 task.name = task.when;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
62 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
63 if task.id == nil then
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
64 task.id = event.source.name .. "/" .. task.name:gsub("%W", "_"):lower();
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
65 end
13284
ffd3dadf6247 mod_cron: Make task frequencies configurable in overly generic manner
Kim Alvefur <zash@zash.se>
parents: 13283
diff changeset
66 task.period = host_module:get_option_period(task.id:gsub("/", "_") .. "_period", "1" .. task.when, 60, 86400*7*53);
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
67 task.restore = restore_task;
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
68 task.save = save_task;
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
69 module:log("debug", "%s task %s added", task.when, task.id);
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
70 return true
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
71 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
72
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
73 local function task_removed(event : task_event) : boolean
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
74 local task = event.item;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
75 host_module:log("debug", "Task %s removed", task.id);
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
76 return true
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
77 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
78
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
79 host_module:handle_items("task", task_added, task_removed, true);
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
80
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
81 function host_module.unload()
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
82 active_hosts[host_module.host]=nil;
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
83 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
84 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
85
13284
ffd3dadf6247 mod_cron: Make task frequencies configurable in overly generic manner
Kim Alvefur <zash@zash.se>
parents: 13283
diff changeset
86 local function should_run(task : task_spec, last : integer) : boolean
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
87 return not last or last + task.period * 0.995 <= os.time()
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
88 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
89
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
90 local function run_task(task : task_spec)
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
91 task:restore();
13284
ffd3dadf6247 mod_cron: Make task frequencies configurable in overly generic manner
Kim Alvefur <zash@zash.se>
parents: 13283
diff changeset
92 if not should_run(task, task.last) then
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
93 return
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
94 end
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
95 local started_at = os.time();
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
96 task:run(started_at);
12489
8b42575738f0 mod_cron: Fix recording last task run time #1751
Kim Alvefur <zash@zash.se>
parents: 12186
diff changeset
97 task.last = started_at;
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
98 task:save(started_at);
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
99 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
100
13442
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
101 local function spread(t : number, factor : number) : number
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
102 return t * (1 - factor + 2*factor*math.random())
13442
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
103 end
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
104
12498
c3e47a5dd30d util.async: Add Teal description file
Kim Alvefur <zash@zash.se>
parents: 12489
diff changeset
105 local task_runner : async.runner_t<task_spec> = async.runner(run_task);
13442
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
106 scheduled = module:add_timer(cron_initial_delay, function() : number
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
107 module:log("info", "Running periodic tasks");
13442
eb0fab7e5d32 mod_cron: Sync Teal source with 92301fa7a673
Kim Alvefur <zash@zash.se>
parents: 13366
diff changeset
108 local delay = spread(cron_check_delay, cron_spread_factor);
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
109 for host in pairs(active_hosts) do
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
110 module:log("debug", "Running periodic tasks for host %s", host);
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
111 for _, task in ipairs(module:context(host):get_host_items("task") as { task_spec } ) do
13265
6ac5ad578565 mod_cron: Load last task run time inside task runner to fix async
Kim Alvefur <zash@zash.se>
parents: 13264
diff changeset
112 task_runner:run(task);
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
113 end
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
114 end
13443
98a6ec4ce140 mod_cron: Fix log format to account for float that was integer before
Kim Alvefur <zash@zash.se>
parents: 13442
diff changeset
115 module:log("debug", "Wait %gs", delay);
13878
9ec961173b1c teal: Remove trailing semicolons after return
Kim Alvefur <zash@zash.se>
parents: 13443
diff changeset
116 return delay
11986
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
117 end);
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
118
3d5135e8a2a7 mod_cron: Initial commit of periodic task runner
Kim Alvefur <zash@zash.se>
parents:
diff changeset
119 -- TODO measure load, pick a good time to do stuff
13366
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
120
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
121 module:add_item("shell-command", {
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
122 section = "cron";
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
123 section_desc = "View and manage recurring tasks";
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
124 name = "tasks";
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
125 desc = "View registered tasks";
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
126 args = {};
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
127 handler = function (self, filter_host : string)
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
128 local format_table = require "prosody.util.human.io".table;
13884
8b05340a94d3 mod_cron: Move changes to Teal source
Kim Alvefur <zash@zash.se>
parents: 13878
diff changeset
129 local it = require "prosody.util.iterators";
13366
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
130 local row = format_table({
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
131 { title = "Host", width = "2p" };
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
132 { title = "Task", width = "3p" };
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
133 { title = "Desc", width = "3p" };
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
134 { title = "When", width = "1p" };
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
135 { title = "Last run", width = "20" };
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
136 }, self.session.width);
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
137 local print = self.session.print;
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
138 print(row());
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
139 for host in it.sorted_pairs(filter_host and { [filter_host]=true } or active_hosts) do
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
140 for _, task in ipairs(module:context(host):get_host_items("task")) do
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
141 print(row { host, task.id, task.name, task.when, task.last and os.date("%Y-%m-%d %R:%S", task.last) or "never" });
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
142 end
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
143 end
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
144 end;
9f1f1e7afdbd mod_cron: Update Teal source and rebuild
Matthew Wild <mwild1@gmail.com>
parents: 13284
diff changeset
145 });