Comparison

plugins/mod_admin_shell.lua @ 12537:74418f8096b0

mod_admin_shell: Show bound ports in module:info I.e. the subset of port:list() relevant to the specified module.
author Kim Alvefur <zash@zash.se>
date Tue, 31 May 2022 00:31:56 +0200
parent 12536:a8cb1d7a98db
child 12538:0f56587bb37f
comparison
equal deleted inserted replaced
12536:a8cb1d7a98db 12537:74418f8096b0
511 ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end, 511 ["identity"] = function(ident) return ident.type .. "/" .. ident.category; end,
512 ["adhoc-provider"] = item_name, 512 ["adhoc-provider"] = item_name,
513 ["auth-provider"] = item_name, 513 ["auth-provider"] = item_name,
514 ["storage-provider"] = item_name, 514 ["storage-provider"] = item_name,
515 ["http-provider"] = function(item, mod) return mod:http_url(item.name, item.default_path); end, 515 ["http-provider"] = function(item, mod) return mod:http_url(item.name, item.default_path); end,
516 ["net-provider"] = item_name, 516 ["net-provider"] = function(item, mod)
517 local service_name = item.name;
518 local ports_list = {};
519 for _, interface, port in portmanager.get_active_services():iter(service_name, nil, nil) do
520 table.insert(ports_list, "["..interface.."]:"..port);
521 end
522 if not ports_list[1] then
523 return service_name..": not listening on any ports";
524 end
525 return service_name..": "..table.concat(ports_list, ", ");
526 end,
517 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end, 527 ["measure"] = function(item) return item.name .. " (" .. suf(item.conf and item.conf.unit, " ") .. item.type .. ")"; end,
518 ["metric"] = function(item) 528 ["metric"] = function(item)
519 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description)); 529 return ("%s (%s%s)%s"):format(item.name, suf(item.mf.unit, " "), item.mf.type_, pre(": ", item.mf.description));
520 end, 530 end,
521 ["task"] = function (item) return string.format("%s (%s)", item.name or item.id, item.when); end 531 ["task"] = function (item) return string.format("%s (%s)", item.name or item.id, item.when); end