Automated System Health Checker
Project Information
- Category: Linux Administration / DevOps
- Client: Personal Project
- Project date: November 2025
- Technologies: Bash, Linux, System Monitoring
Project Overview
Enterprise-grade bash script for automated system health monitoring, performance analysis, and security log auditing. This tool provides comprehensive reporting capabilities for proactive Linux server management, helping identify potential issues before they impact system performance or security.
Key Features
- CPU Monitoring: Real-time CPU usage tracking with threshold alerts and top process identification
- Memory Analysis: Comprehensive RAM usage monitoring with detailed breakdown and memory-intensive process detection
- Disk Management: Filesystem usage monitoring with automatic alerts for critical storage levels
- Process Tracking: Running process analysis with zombie process detection and resource usage reports
- Security Logs: Authentication log analysis, failed login tracking, and sudo command auditing
- Network Status: Active connection monitoring and listening port identification
- Email Reports: Automated email delivery of health reports to system administrators
- Detailed Logging: Timestamped reports with color-coded status indicators for easy analysis
Technologies & Skills
CPU Usage Analysis Function
check_cpu() {
echo -e "${BLUE}[CPU USAGE]${NC}"
cpu_usage=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}')
echo "Current CPU Usage: ${cpu_usage}%"
if (( $(echo "$cpu_usage > $CPU_THRESHOLD" | bc -l) )); then
echo -e "${RED}WARNING: CPU usage is above ${CPU_THRESHOLD}%${NC}"
else
echo -e "${GREEN}Status: Normal${NC}"
fi
echo "Top 5 CPU-consuming processes:"
ps aux --sort=-%cpu | head -6
}
Memory Monitoring Function
check_memory() {
echo -e "${BLUE}[MEMORY USAGE]${NC}"
memory_usage=$(free | grep Mem | awk '{print ($3/$2) * 100.0}')
echo "Current Memory Usage: ${memory_usage}%"
if (( $(echo "$memory_usage > $MEMORY_THRESHOLD" | bc -l) )); then
echo -e "${RED}WARNING: Memory usage is above ${MEMORY_THRESHOLD}%${NC}"
fi
free -h
ps aux --sort=-%mem | head -6
}
Security Log Analysis Function
check_security_logs() {
echo -e "${BLUE}[SECURITY LOG ANALYSIS]${NC}"
failed_logins=$(grep "Failed password" /var/log/auth.log | grep "$(date +%b' '%d)" | wc -l)
echo "Failed login attempts today: $failed_logins"
if [ "$failed_logins" -gt 10 ]; then
echo -e "${RED}WARNING: High number of failed login attempts${NC}"
fi
echo "Recent sudo commands (last 10):"
grep "sudo" /var/log/auth.log | tail -10
}
Installation & Usage
Setup Commands
# 1. Download the script
wget https://example.com/system_health_checker.sh
# 2. Make it executable
chmod +x system_health_checker.sh
# 3. Run the health check
./system_health_checker.sh
# 4. Schedule automatic checks (every 6 hours)
crontab -e
# Add: 0 */6 * * * /path/to/system_health_checker.sh
Configuration
Edit the configuration variables at the top of the script to adjust thresholds and email settings:
Configuration Variables
CPU_THRESHOLD=80 # Alert when CPU exceeds 80%
MEMORY_THRESHOLD=80 # Alert when memory exceeds 80%
DISK_THRESHOLD=85 # Alert when disk usage exceeds 85%
EMAIL_RECIPIENT="" # Optional email notifications
Business Value & Impact
Proactive Monitoring
Identifies potential issues before they impact users, reducing downtime and improving system reliability.
Cost Savings
Automated monitoring reduces manual oversight needs and prevents costly system failures through early detection.
Security Enhancement
Regular security log analysis helps detect unauthorized access attempts and maintain compliance standards.
Skills Demonstrated
System Administration
- Linux system monitoring and diagnostics
- Process management and analysis
- Resource utilization tracking
- Performance optimization
Scripting & Automation
- Advanced Bash scripting
- Automated reporting systems
- Error handling and logging
- Schedule automation with cron
Security & Compliance
- Authentication log analysis
- Security event monitoring
- Intrusion detection awareness
- Audit trail management
DevOps Practices
- Proactive monitoring strategies
- Alert threshold configuration
- Documentation and reporting
- Incident prevention