From 31ad1ceb30852bb87ae64b058dc711011db6754b Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Wed, 23 Oct 2024 00:54:15 +0300 Subject: [PATCH] Fix not to display stats history in proxy mode unless there is data collected https://forum.virtualmin.com/t/realtime-stats-do-not-work-on-guest-dashboard-using-link-cgi/128895/9?u=ilia --- authentic-lib.pl | 3 ++- stats-lib-funcs.pl | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/authentic-lib.pl b/authentic-lib.pl index 202649114..ed7638cad 100644 --- a/authentic-lib.pl +++ b/authentic-lib.pl @@ -21,7 +21,7 @@ $current_theme, $root_directory, $config_directory, $var_directory, %theme_text, %module_text_full, %theme_config, $theme_info, $get_user_level, $theme_webprefix, $http_x_url, - $has_virtualmin, $has_cloudmin, + $has_virtualmin, $has_cloudmin, $theme_server_webprefix, $has_usermin, $has_usermin_version, $has_usermin_root_dir, $has_usermin_conf_dir, $has_usermin_var_dir); init_type(); @@ -238,6 +238,7 @@ sub get_extended_sysinfo if (&webmin_user_is_admin() && $theme_config{'settings_sysinfo_hidden_panels_user'} !~ /\'live_stats\'/ && $theme_config{'settings_sysinfo_real_time_status'} ne '0' && + (!$theme_server_webprefix || $theme_server_webprefix && -r get_stats_history_file()) && (acl_system_status('cpu') || acl_system_status('mem') || acl_system_status('load'))) { my $data = '
diff --git a/stats-lib-funcs.pl b/stats-lib-funcs.pl index b066f4257..0ccbab7fb 100644 --- a/stats-lib-funcs.pl +++ b/stats-lib-funcs.pl @@ -179,11 +179,15 @@ sub get_stats_now return \%data; } +sub get_stats_history_file +{ + return "$var_directory/modules/$current_theme/real-time-monitoring.json"; +} + sub get_stats_history { my ($noempty) = @_; - my $file = "$var_directory/modules/$current_theme". - "/real-time-monitoring.json"; + my $file = get_stats_history_file(); my $graphs = jsonify(read_file_contents($file)); # No data yet if (!keys %{$graphs}) {