Files
troupe-standup/wizard-work/spark/disk_usage.py
T

20 lines
671 B
Python

#!/usr/bin/env python3
"""Quick disk usage checker - returns JSON for easy parsing."""
import json
import shutil
def get_disk_usage():
"""Get disk usage for root partition."""
total, used, free = shutil.disk_usage("/")
return {
"partition": "/",
"total_gb": round(total / (1024**3), 2),
"used_gb": round(used / (1024**3), 2),
"free_gb": round(free / (1024**3), 2),
"percent_used": round((used / total) * 100, 1),
"status": "ok" if (used / total) < 0.8 else "warning" if (used / total) < 0.9 else "critical"
}
if __name__ == "__main__":
result = get_disk_usage()
print(json.dumps(result, indent=2))