Skip to content

Commit

Permalink
Ensure disk usage/free lines up for path. Limit to 20 to control char…
Browse files Browse the repository at this point in the history
…t size.
  • Loading branch information
guydavis committed Nov 2, 2023
1 parent 8aa4e82 commit 3de2b7c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions web/actions/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 3de2b7c

Please sign in to comment.