#!/usr/bin/env bash # # status-simple.sh # A very simple, readable script that runs a series of commands to check system status. # Each check is self-contained. # # --- Helper function for alignment --- # Prints a label padded to 25 characters, followed by the output of a command. print_check() { local label="$1" local command="$2" printf "%-25s: %s\n" "$label" "$(eval "$command")" } # --- Header --- echo "--- System Status: $(date) ---" echo # --- 0. IRC --- echo "--- IRC ---" /usr/local/bin/irc_stats.sh # --- 1. Radio --- # Checks if the stream mountpoint exists in the Icecast JSON status. echo echo "--- RADIO ---" print_check "Radio Stream" "curl -fs http://127.0.0.1:8000/status-json.xsl >/dev/null && echo 'UP' || echo 'DOWN'" # --- 2. Systemd Services --- # Loops through a list of services and checks if they are active. echo echo "--- Services ---" for service in nginx venusia phorum smbd apcupsd; do print_check "$service" "systemctl is-active --quiet $service && echo 'UP' || echo 'DOWN'" done # special case for mpd because it runs as user print_check mpd "pgrep -u baudrillard mpd >/dev/null && echo 'UP' || echo 'DOWN'" # --- 3. Counter-Strike 1.6 --- # Runs the dedicated stats script and pretty-prints the JSON output. echo echo "--- Counter-Strike 1.6 ---" # Pipe the JSON output to 'jq' to format it and 'sed' to indent it. /usr/local/bin/cs_stats.sh | jq . | sed 's/^/ /' # --- 4. Disk Usage --- echo echo "--- Storage ---" print_check "Disk Usage (Root)" "df -h / | awk 'NR==2 {print \$5}'" print_check "Disk Usage (BackupRAID)" "df -h /media/root/BackupRAID | awk 'NR==2 {print \$5}'" # --- 5. Restic Backups --- # Checks the logs for any sign of errors or warnings. echo echo "--- Restic Backups ---" # Check the backup log for errors. If found, print the whole log. if grep -q -E 'Warning|error|failed' /var/log/restic-backup.log; then printf "%-25s: %s\n" "Backup Status" "ERRORS FOUND (see log below)" echo "------------------------- Restic Backup Log -------------------------" sed 's/^/ /' /var/log/restic-backup.log echo "-------------------------------------------------------------------" else print_check "Backup Status" "echo 'OK'" fi # This command will print any error lines from the maintenance log, or 'No errors found' if none exist. print_check "Maintenance Status" "grep 'errors' /var/log/restic-maintain.log || echo 'No errors found'" echo echo "LAST BACKUP LOG, 3 LINES" echo tail -n 3 /var/log/restic-backup.log echo echo "MAINTENANCE LOG, 3 LINES" echo tail -n 3 /var/log/restic-maintain.log # --- 6. Hardware & System --- echo echo "--- Hardware & System ---" print_check "System Uptime" "uptime -p" print_check "Last UPS Event" "tail -n 1 /var/log/apcupsd.events" echo echo "UPS/BATTERY" apcaccess status echo inxi -SCGIDm -t cm5 echo echo "--- Report Complete ---"