From 3de2b7cb8b14a024a89447b3211c3d658fcbea2e Mon Sep 17 00:00:00 2001 From: Guy Davis Date: Thu, 2 Nov 2023 15:43:01 -0600 Subject: [PATCH] Ensure disk usage/free lines up for path. Limit to 20 to control chart size. --- web/actions/stats.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/web/actions/stats.py b/web/actions/stats.py index c15c8212..c7b1b75e 100644 --- a/web/actions/stats.py +++ b/web/actions/stats.py @@ -38,7 +38,7 @@ StatPlottingDiskFree, ] -# Don't overload the bar chart with tons of plots paths, randomly sample only this amount +# Don't overload the bar chart with tons of plots paths, show only the first X paths MAX_ALLOWED_PATHS_ON_BAR_CHART = 20 # Ignore disk stats that are older than this many minutes ago @@ -280,9 +280,11 @@ def load_current_disk_usage(disk_type, hostname=None): free.append(free_row.value) # Leave at GB continue if len(paths): - if len(paths) > MAX_ALLOWED_PATHS_ON_BAR_CHART: - paths = sorted(random.sample(paths, MAX_ALLOWED_PATHS_ON_BAR_CHART)) - summary_by_worker[host.hostname] = { "paths": paths, "used": used, "free": free} + summary_by_worker[host.hostname] = { + "paths": paths[:MAX_ALLOWED_PATHS_ON_BAR_CHART], + "used": used[:MAX_ALLOWED_PATHS_ON_BAR_CHART], + "free": free[:MAX_ALLOWED_PATHS_ON_BAR_CHART] + } #app.logger.debug(summary_by_worker.keys()) return summary_by_worker