18 lines
476 B
Python
18 lines
476 B
Python
#!/usr/bin/env python3
|
|
"""Disk usage reporter - outputs JSON format."""
|
|
import shutil
|
|
import json
|
|
|
|
def main():
|
|
total, used, free = shutil.disk_usage('/')
|
|
report = {
|
|
"path": "/",
|
|
"total_gb": round(total / (1024**3), 3),
|
|
"used_gb": round(used / (1024**3), 3),
|
|
"free_gb": round(free / (1024**3), 3),
|
|
"percent_used": round((used / total) * 100, 1)
|
|
}
|
|
print(json.dumps(report, indent=2))
|
|
|
|
if __name__ == "__main__":
|
|
main() |