comparison mod_stats39/mod_stats39.lua @ 3839:a4b05f34a790

mod_stats39: Provides statsmanager stats via XEP-0039 The @name attrs are just Prosodys internal names for stats.
author Kim Alvefur <zash@zash.se>
date Wed, 08 Jan 2020 20:53:57 +0100
parents
children 054898e84a04
comparison
equal deleted inserted replaced
3838:9f0c10bd4633 3839:a4b05f34a790
1 local statsman = require "core.statsmanager";
2 local st = require "util.stanza";
3
4 module:hook("iq/host/http://jabber.org/protocol/stats:query", function (event)
5 local origin, stanza = event.origin, event.stanza;
6 local stats, _, extra = statsman.get_stats();
7 local reply = st.reply(event.stanza);
8 reply:tag("query", { xmlns = "http://jabber.org/protocol/stats" });
9 for stat, value in pairs(stats) do
10 local unit = extra[stat] and extra[stat].units;
11 reply:tag("stat", { name = stat, unit = unit, value = tostring(value) }):up();
12 end
13 origin.send(reply);
14 return true;
15 end)