Files

28 lines
912 B
Bash
Executable File

#!/bin/bash
# System Health Checker - Verifiable artifact
# Outputs CPU, memory, and top process stats
echo "=== System Health Report ==="
echo "Timestamp: $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo ""
echo "--- CPU Info ---"
grep -m1 'model name' /proc/cpuinfo | cut -d':' -f2 | sed 's/^ //'
echo "Load Average: $(cat /proc/loadavg | cut -d' ' -f1-3)"
echo ""
echo "--- Memory Usage ---"
free -h | awk '/^Mem:/ {printf "Total: %s, Used: %s, Free: %s (%.1f%% used)\n", $2, $3, $4, ($3/$2)*100}'
echo ""
echo "--- Top 5 Processes by Memory ---"
ps aux --sort=-%mem | head -6 | awk 'NR==1 {print $0} NR>1 {printf "%-10s %-8s %6s RAM %s\n", $1, $2, $6/1024 "MB", $11}'
echo ""
echo "--- Disk Usage (/ - root) ---"
df -h / | awk 'NR==1 || /on \/ / {print $1, $2, $3, $4, $5, $6}'
echo ""
echo "Network: $(ip -4 addr show scope global | grep inet | awk '{print $2}' | head -1)"
echo ""
echo "=== End Report ==="