From 965a81eb6374077f8657066761f8808c7e7d08f3 Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Mon, 11 Nov 2024 10:52:54 -0600 Subject: [PATCH] Initial report --- .github/manifests/disk-usage-report-job.yaml | 2 +- .github/scripts/du.py | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/manifests/disk-usage-report-job.yaml b/.github/manifests/disk-usage-report-job.yaml index adf966e..488735e 100644 --- a/.github/manifests/disk-usage-report-job.yaml +++ b/.github/manifests/disk-usage-report-job.yaml @@ -14,7 +14,7 @@ spec: - name: disk-usage-report image: IMAGE_PLACEHOLDER args: - - "/home/asmacdo" + - "/home/" volumeMounts: - name: persistent-storage mountPath: "/home" diff --git a/.github/scripts/du.py b/.github/scripts/du.py index 05043ef..e626769 100755 --- a/.github/scripts/du.py +++ b/.github/scripts/du.py @@ -42,12 +42,11 @@ def prepare_report(directory): for user, data in report.items(): data["disk_usage_human_readable"] = bytes_to_human_readable(data["disk_usage_bytes"]) - # os.makedirs(os.path.dirname(OUTPUT_FILE), exist_ok=True) - # output_file = - # with open(OUTPUT_FILE, 'w') as f: - # json.dump(report, f, indent=4) - # - # print(f"Disk usage report generated at {os.path.abspath(OUTPUT_FILE)}") + os.makedirs(os.path.dirname(OUTPUT_DIR), exist_ok=True) + current_date = date.today().strftime('%Y-%m-%d') + with open(f"{OUTPUT_DIR}/{current_date}.json", "w") as f: + json.dump(report, f, indent=4) + print(f"Disk usage report generated at {os.path.abspath(OUTPUT_FILE)}") if __name__ == "__main__": @@ -55,10 +54,4 @@ def prepare_report(directory): print("Usage: du.py ") else: path = sys.argv[1] - directories = [d for d in os.listdir(path) if os.path.isdir(os.path.join(path, d))] - - os.makedirs(os.path.dirname(OUTPUT_DIR), exist_ok=True) - current_date = date.today().strftime('%Y-%m-%d') - with open(f"{OUTPUT_DIR}/{current_date}.json", "w") as f: - f.write("\n".join(directories)) - # prepare_report(directory) + prepare_report(path)