diff --git a/wizard-work/spark/sys_check.py b/wizard-work/spark/sys_check.py new file mode 100644 index 0000000..50d05bf --- /dev/null +++ b/wizard-work/spark/sys_check.py @@ -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") \ No newline at end of file