A production-ready DevOps Bash script designed to monitor the health and security of multiple remote servers simultaneously over SSH. It automates system audits and generates unique log files for easy troubleshooting.
- Strict Bash Mode (
-euo pipefail): Ensures high reliability and safe execution. - Automated Cleanup: Uses Bash
trapto safely delete temporary files upon exit or interruption. - Comprehensive Metrics: Checks uptime, root disk capacity, RAM usage, and records SSH brute-force failures.
- Safe Input Parsing: Implements secure argument parsing with
getoptsand handles configuration validation efficiently.
Before running the script, ensure you have:
- Public-private SSH key pairs configured for passwordless access to your remote servers.
- Active SSH access with appropriate user privileges.
-
Clone the repository:
git clone https://github.com cd automated-server-health-checker -
Make the script executable:
chmod +x server_health_check.sh
-
Create a server list file (
test_servers.txt): Add your server IPs or domains (one per line). Comments starting with#are supported.# Production Servers 192.168.1.50 10.0.0.12 -
Run the health check:
./server_health_check.sh -f test_servers.txt -u ubuntu
-f: Path to the file containing the list of servers.-u: The remote SSH username.-h: Display the help message.