From 1ac4aed7cde1aec722542199e488bc537423adbf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 24 Nov 2021 20:03:38 +0100 Subject: mod_admin_shell: List collected metrics in module:info Lets you know what to look for with stats:show() --- plugins/mod_admin_shell.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'plugins/mod_admin_shell.lua') 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 -- cgit v1.2.3