spark: add system health check script
This commit is contained in:
1 parent
ca8e2b77ab
commit
15b5cd2a1e
1 file changed
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Quick system health check script."""
|
||||
import os
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
def get_disk_usage():
|
||||
result = subprocess.run(['df', '-h', '/'], capture_output=True, text=True)
|
||||
lines = result.stdout.strip().split('\n')
|
||||
if len(lines) >= 2:
|
||||
parts = lines[1].split()
|
||||
return {'total': parts[1], 'used': parts[2], 'avail': parts[3], 'use%': parts[4]}
|
||||
return None
|
||||
|
||||
def get_memory_usage():
|
||||
try:
|
||||
with open('/proc/meminfo') as f:
|
||||
lines = f.readlines()
|
||||
mem = {}
|
||||
for line in lines[:3]:
|
||||
parts = line.split()
|
||||
key = parts[0].rstrip(':')
|
||||
val = parts[1]
|
||||
if key in ['MemTotal', 'MemFree', 'MemAvailable']:
|
||||
mem[key] = val
|
||||
return mem
|
||||
except:
|
||||
return None
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("=== System Health Check ===")
|
||||
print(f"Platform: {platform.system()} {platform.release()}")
|
||||
print(f"Python: {platform.python_version()}")
|
||||
print(f"User: {os.getenv('USER', 'unknown')}")
|
||||
|
||||
disk = get_disk_usage()
|
||||
if disk:
|
||||
print(f"Disk /: {disk['total']} total, {disk['used']} used, {disk['avail']} avail ({disk['use%']})")
|
||||
|
||||
mem = get_memory_usage()
|
||||
if mem:
|
||||
print(f"Memory: {mem['MemTotal']} total, {mem['MemAvailable']} available")
|
||||
|
||||
print("Status: OK")
|
||||
Reference in new issue
Block a user