Initial commit: homelab configuration and documentation

This commit is contained in:
2025-11-29 19:03:14 +00:00
commit 0769ca6888
72 changed files with 7806 additions and 0 deletions

132
scripts/quick_status.sh Executable file
View File

@@ -0,0 +1,132 @@
#!/bin/bash
# quick_status.sh - Quick health check of all homelab components
# Run this anytime to get a fast overview of system status
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
clear
echo -e "${BLUE}╔════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Home Lab Quick Status Check ║${NC}"
echo -e "${BLUE}╚════════════════════════════════════════╝${NC}"
echo ""
# System Info
echo -e "${YELLOW}📊 System Information${NC}"
echo " Hostname: $(hostname)"
echo " Uptime: $(uptime -p)"
echo " Load: $(uptime | awk -F'load average:' '{print $2}')"
echo ""
# Docker Swarm
echo -e "${YELLOW}🐳 Docker Swarm${NC}"
if docker node ls &>/dev/null; then
TOTAL_NODES=$(docker node ls | grep -c Ready || echo "0")
echo -e " ${GREEN}${NC} Swarm active ($TOTAL_NODES nodes)"
docker service ls --format "table {{.Name}}\t{{.Replicas}}" | head -10
else
echo -e " ${RED}${NC} Not a swarm manager"
fi
echo ""
# Services Health
echo -e "${YELLOW}🏥 Container Health${NC}"
HEALTHY=$(docker ps --filter "health=healthy" --format "{{.Names}}" | wc -l 2>/dev/null || echo "0")
UNHEALTHY=$(docker ps --filter "health=unhealthy" --format "{{.Names}}" | wc -l 2>/dev/null || echo "0")
TOTAL=$(docker ps --format "{{.Names}}" | wc -l 2>/dev/null || echo "0")
echo -e " Healthy: ${GREEN}$HEALTHY${NC}"
echo -e " Unhealthy: ${RED}$UNHEALTHY${NC}"
echo -e " Total: $TOTAL"
if [[ $UNHEALTHY -gt 0 ]]; then
echo -e " ${RED}⚠ Unhealthy containers:${NC}"
docker ps --filter "health=unhealthy" --format " - {{.Names}}"
fi
echo ""
# Storage
echo -e "${YELLOW}💾 Storage${NC}"
df -h / /mnt/nas 2>/dev/null | tail -n +2 | awk '{printf " %-20s %5s used of %5s\n", $6, $3, $2}'
if command -v zpool &>/dev/null && zpool list tank &>/dev/null; then
HEALTH=$(zpool list -H -o health tank)
if [[ "$HEALTH" == "ONLINE" ]]; then
echo -e " ZFS tank: ${GREEN}$HEALTH${NC}"
else
echo -e " ZFS tank: ${RED}$HEALTH${NC}"
fi
fi
echo ""
# Network
echo -e "${YELLOW}🌐 Network${NC}"
IP=$(hostname -I | awk '{print $1}')
echo " IP: $IP"
if command -v ethtool &>/dev/null; then
SPEED=$(ethtool eth0 2>/dev/null | grep Speed | awk '{print $2}' || echo "Unknown")
echo " Speed: $SPEED"
fi
if ping -c 1 8.8.8.8 &>/dev/null; then
echo -e " Internet: ${GREEN}✓ Connected${NC}"
else
echo -e " Internet: ${RED}✗ Disconnected${NC}"
fi
echo ""
# Security
echo -e "${YELLOW}🔒 Security${NC}"
if systemctl is-active --quiet fail2ban 2>/dev/null; then
BANNED=$(sudo fail2ban-client status sshd 2>/dev/null | grep "Currently banned" | awk '{print $4}' || echo "0")
echo -e " fail2ban: ${GREEN}✓ Active${NC} ($BANNED IPs banned)"
else
echo -e " fail2ban: ${YELLOW}⚠ Not running${NC}"
fi
echo ""
# Backups
echo -e "${YELLOW}💾 Backups${NC}"
if systemctl is-active --quiet restic-backup.timer 2>/dev/null; then
NEXT=$(systemctl list-timers | grep restic-backup | awk '{print $1, $2}')
echo -e " Restic timer: ${GREEN}✓ Active${NC}"
echo " Next backup: $NEXT"
else
echo -e " Restic timer: ${YELLOW}⚠ Not configured${NC}"
fi
echo ""
# Monitoring
echo -e "${YELLOW}📈 Monitoring${NC}"
if curl -s http://localhost:9100/metrics &>/dev/null; then
echo -e " node-exporter: ${GREEN}✓ Running${NC}"
else
echo -e " node-exporter: ${YELLOW}⚠ Not accessible${NC}"
fi
if curl -s http://192.168.1.196:3000 &>/dev/null; then
echo -e " Grafana: ${GREEN}✓ Accessible${NC}"
else
echo -e " Grafana: ${YELLOW}⚠ Not accessible${NC}"
fi
echo ""
# Quick recommendations
echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
if [[ $UNHEALTHY -gt 0 ]]; then
echo -e "${YELLOW}⚠ Action needed: $UNHEALTHY unhealthy containers${NC}"
fi
DISK_USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [[ $DISK_USAGE -gt 80 ]]; then
echo -e "${YELLOW}⚠ Warning: Disk usage at ${DISK_USAGE}%${NC}"
fi
echo ""
echo "For detailed validation: bash /workspace/homelab/scripts/validate_deployment.sh"
echo ""