Introduction:
This bash script monitors your system's CPU, memory, and disk usage to ensure that your system is performing optimally. It provides a quick snapshot of your resource consumption.
Instructions:
Run the script using the following commands:
Example Output:
This bash script monitors your system's CPU, memory, and disk usage to ensure that your system is performing optimally. It provides a quick snapshot of your resource consumption.
Bash:
#!/bin/bash
# Check CPU usage
cpu_usage=$(top -bn1 | grep 'Cpu(s)' | \
awk '{print 100 - $8}')
# Check Memory usage
memory_usage=$(free -m | awk 'NR==2 {printf "%.2f", $3*100/$2 }')
# Check Disk usage
disk_usage=$(df -h | awk '$NF=="/"{printf "%s", $5}')
echo "CPU Usage: $cpu_usage%"
echo "Memory Usage: $memory_usage%"
echo "Disk Usage: $disk_usage"
Instructions:
Run the script using the following commands:
Code:
chmod +x health_checker.sh
./health_checker.sh
Example Output:
Code:
CPU Usage: 23.4%
Memory Usage: 54.32%
Disk Usage: 40%