Software /
code /
prosody-modules
Comparison
mod_stats39/mod_stats39.lua @ 3840:054898e84a04
mod_stats39: Use a more local reference (silence luacheck warning)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 08 Jan 2020 21:02:47 +0100 |
parent | 3839:a4b05f34a790 |
child | 3846:3941768916f1 |
comparison
equal
deleted
inserted
replaced
3839:a4b05f34a790 | 3840:054898e84a04 |
---|---|
2 local st = require "util.stanza"; | 2 local st = require "util.stanza"; |
3 | 3 |
4 module:hook("iq/host/http://jabber.org/protocol/stats:query", function (event) | 4 module:hook("iq/host/http://jabber.org/protocol/stats:query", function (event) |
5 local origin, stanza = event.origin, event.stanza; | 5 local origin, stanza = event.origin, event.stanza; |
6 local stats, _, extra = statsman.get_stats(); | 6 local stats, _, extra = statsman.get_stats(); |
7 local reply = st.reply(event.stanza); | 7 local reply = st.reply(stanza); |
8 reply:tag("query", { xmlns = "http://jabber.org/protocol/stats" }); | 8 reply:tag("query", { xmlns = "http://jabber.org/protocol/stats" }); |
9 for stat, value in pairs(stats) do | 9 for stat, value in pairs(stats) do |
10 local unit = extra[stat] and extra[stat].units; | 10 local unit = extra[stat] and extra[stat].units; |
11 reply:tag("stat", { name = stat, unit = unit, value = tostring(value) }):up(); | 11 reply:tag("stat", { name = stat, unit = unit, value = tostring(value) }):up(); |
12 end | 12 end |