spark: add environment status report script and output
This commit is contained in:
1 parent
df0348609f
commit
21ec60aec5
2 files changed
+61
No files matched your search
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"timestamp": "2026-10-30T13:12:30.396210+00:00",
|
||||||
|
"working_directory": "/root",
|
||||||
|
"user": "root",
|
||||||
|
"disk_usage": {
|
||||||
|
"total_gb": 153.94,
|
||||||
|
"used_gb": 120.22,
|
||||||
|
"free_gb": 33.71,
|
||||||
|
"percent_used": 78.1
|
||||||
|
},
|
||||||
|
"scratch_files": 0,
|
||||||
|
"python_version": "3.14.9",
|
||||||
|
"platform": "Linux"
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Generate environment status report as JSON."""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
def get_env_status():
|
||||||
|
"""Return environment status as dict."""
|
||||||
|
cwd = os.getcwd()
|
||||||
|
user = os.environ.get('USER', 'unknown')
|
||||||
|
|
||||||
|
# Get disk usage for root filesystem
|
||||||
|
total, used, free = shutil.disk_usage('/')
|
||||||
|
|
||||||
|
# Count files in scratch directory for hermes
|
||||||
|
scratch = os.environ.get('TMPDIR', '/tmp')
|
||||||
|
file_count = 0
|
||||||
|
for root, dirs, files in os.walk(scratch):
|
||||||
|
file_count += len(files)
|
||||||
|
if file_count > 100: # Limit for speed
|
||||||
|
break
|
||||||
|
|
||||||
|
status = {
|
||||||
|
'timestamp': datetime.now(timezone.utc).isoformat(),
|
||||||
|
'working_directory': cwd,
|
||||||
|
'user': user,
|
||||||
|
'disk_usage': {
|
||||||
|
'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)
|
||||||
|
},
|
||||||
|
'scratch_files': file_count,
|
||||||
|
'python_version': sys.version.split()[0],
|
||||||
|
'platform': os.uname().sysname if hasattr(os, 'uname') else 'unknown'
|
||||||
|
}
|
||||||
|
return status
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
status = get_env_status()
|
||||||
|
output_path = '/root/.hermes/wizard-outputs/spark/env_status.json'
|
||||||
|
with open(output_path, 'w') as f:
|
||||||
|
json.dump(status, f, indent=2)
|
||||||
|
print(f"Status written to {output_path}")
|
||||||
|
print(json.dumps(status, indent=2))
|
||||||
Reference in new issue
Block a user