Comparison

plugins/mod_admin_shell.lua @ 13582:67c9fc643873

mod_admin_shell: stats:show(): Friendlier error message when statistics disabled
author Matthew Wild <mwild1@gmail.com>
date Sat, 28 Dec 2024 18:35:24 +0000
parent 13562:f77c247258cc
child 13591:382d1a92006f
comparison
equal deleted inserted replaced
13581:c71feb7686c0 13582:67c9fc643873
2429 2429
2430 describe_command [[stats:show(pattern) - Show internal statistics, optionally filtering by name with a pattern.]] 2430 describe_command [[stats:show(pattern) - Show internal statistics, optionally filtering by name with a pattern.]]
2431 -- Undocumented currently, you can append :histogram() or :cfgraph() to stats:show() for rendered graphs. 2431 -- Undocumented currently, you can append :histogram() or :cfgraph() to stats:show() for rendered graphs.
2432 function def_env.stats:show(name_filter) 2432 function def_env.stats:show(name_filter)
2433 local statsman = require "prosody.core.statsmanager" 2433 local statsman = require "prosody.core.statsmanager"
2434 local metric_registry = statsman.get_metric_registry();
2435 if not metric_registry then
2436 return nil, [[Statistics disabled. Try `statistics = "internal"` in the global section of the config file and restart.]];
2437 end
2434 local collect = statsman.collect 2438 local collect = statsman.collect
2435 if collect then 2439 if collect then
2436 -- force collection if in manual mode 2440 -- force collection if in manual mode
2437 collect() 2441 collect()
2438 end 2442 end
2439 local metric_registry = statsman.get_metric_registry();
2440 local displayed_stats = new_stats_context(self); 2443 local displayed_stats = new_stats_context(self);
2441 for family_name, metric_family in iterators.sorted_pairs(metric_registry:get_metric_families()) do 2444 for family_name, metric_family in iterators.sorted_pairs(metric_registry:get_metric_families()) do
2442 if not name_filter or family_name:match(name_filter) then 2445 if not name_filter or family_name:match(name_filter) then
2443 table.insert(displayed_stats, { 2446 table.insert(displayed_stats, {
2444 family_name, 2447 family_name,