diff options
author | Kim Alvefur <zash@zash.se> | 2021-11-24 20:03:38 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-11-24 20:03:38 +0100 |
commit | 1ac4aed7cde1aec722542199e488bc537423adbf (patch) | |
tree | 7d947ced090cb7138ea3aabae40877afa1ca3e09 /plugins/mod_admin_shell.lua | |
parent | 2388b800b2370b7dae55d7f1e40420ab845b3b5a (diff) | |
download | prosody-1ac4aed7cde1aec722542199e488bc537423adbf.tar.gz prosody-1ac4aed7cde1aec722542199e488bc537423adbf.zip |
mod_admin_shell: List collected metrics in module:info
Lets you know what to look for with stats:show()
Diffstat (limited to 'plugins/mod_admin_shell.lua')
-rw-r--r-- | plugins/mod_admin_shell.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua index f8f56528..ab7fbb70 100644 --- a/plugins/mod_admin_shell.lua +++ b/plugins/mod_admin_shell.lua @@ -47,6 +47,16 @@ local function capitalize(s) return (s:gsub("^%a", string.upper):gsub("_", " ")); end +local function pre(prefix, str, alt) + if (str or "") == "" then return alt or ""; end + return prefix .. str; +end + +local function suf(str, suffix, alt) + if (str or "") == "" then return alt or ""; end + return str .. suffix; +end + local commands = module:shared("commands") local def_env = module:shared("env"); local default_env_mt = { __index = def_env }; @@ -422,6 +432,8 @@ function def_env.module:info(name, hosts) ["http-provider"] = "HTTP services", ["net-provider"] = "Network service", ["storage-provider"] = "Storage driver", + ["measure"] = "Legacy metrics", + ["metric"] = "Metrics", }; local item_formatters = { ["feature"] = tostring, @@ -431,6 +443,10 @@ function def_env.module:info(name, hosts) ["storage-provider"] = function(item) return item.name; end, ["http-provider"] = function(item, mod) return mod:http_url(item.name); end, ["net-provider"] = function(item) return item.name; end, + ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, + ["metric"] = function(item) + return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); + end, }; for host in hosts do |