spark: add disk usage checker script
This commit is contained in:
1 parent
cf17e7aefe
commit
e4b7eb8158
13 files changed
+22
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,22 @@
|
||||
#!/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))
|
||||
# Exit with special code based on status
|
||||
exit(0 if result["status"] == "ok" else 2 if result["status"] == "warning" else 3)
|
||||
Reference in new issue
Block a user