Changeset

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
parents 13581:c71feb7686c0
children 13583:e77ef9a4604f
files plugins/mod_admin_shell.lua
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_shell.lua	Fri Dec 20 14:22:25 2024 +0000
+++ b/plugins/mod_admin_shell.lua	Sat Dec 28 18:35:24 2024 +0000
@@ -2431,12 +2431,15 @@
 -- Undocumented currently, you can append :histogram() or :cfgraph() to stats:show() for rendered graphs.
 function def_env.stats:show(name_filter)
 	local statsman = require "prosody.core.statsmanager"
+	local metric_registry = statsman.get_metric_registry();
+	if not metric_registry then
+		return nil, [[Statistics disabled. Try `statistics = "internal"` in the global section of the config file and restart.]];
+	end
 	local collect = statsman.collect
 	if collect then
 		-- force collection if in manual mode
 		collect()
 	end
-	local metric_registry = statsman.get_metric_registry();
 	local displayed_stats = new_stats_context(self);
 	for family_name, metric_family in iterators.sorted_pairs(metric_registry:get_metric_families()) do
 		if not name_filter or family_name:match(name_filter) then