Comparison

mod_pubsub_stats/mod_pubsub_stats.lua @ 3407:26ae3b6a8a57

mod_pubsub_stats: Generate a textual summary for notifications
author Kim Alvefur <zash@zash.se>
date Sat, 22 Dec 2018 16:34:51 +0100
parent 3175:44c5d7310c33
child 3408:b2ce818ec19c
comparison
equal deleted inserted replaced
3406:4cbb1e381431 3407:26ae3b6a8a57
38 end); 38 end);
39 39
40 function module.unload() 40 function module.unload()
41 pubsub.service:delete(node, true); 41 pubsub.service:delete(node, true);
42 end 42 end
43
44 module:hook("pubsub-summary/http://jabber.org/protocol/stats", function (event)
45 local payload = event.payload;
46 local summary = {};
47 for stat in payload:childtags("stat") do
48 if stat.attr.name and stat.attr.value then
49 table.insert(summary, string.format("%s: %g %s", stat.attr.name, tonumber(stat.attr.value), stat.attr.units or ""));
50 end
51 end
52 return table.concat(summary, "\n");
53 end);
54