From 7c801f6c3b5d050932e609445d5c87771c74237c Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Thu, 2 Apr 2026 20:41:40 -0500 Subject: [PATCH] fix: guard --output-dir arg and use configurable ZOMBIE_WARN threshold - Validate --output-dir has a following argument before accessing $2 (prevents unbound variable crash under set -u) - Add ZOMBIE_WARN config variable (default: 1) and use it in the zombie check instead of hardcoding 0 Co-Authored-By: Claude Opus 4.6 (1M context) --- monitoring/scripts/homelab-audit.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/monitoring/scripts/homelab-audit.sh b/monitoring/scripts/homelab-audit.sh index 9199fba..308f508 100755 --- a/monitoring/scripts/homelab-audit.sh +++ b/monitoring/scripts/homelab-audit.sh @@ -27,10 +27,15 @@ DISK_WARN=80 DISK_CRIT=90 LOAD_WARN=2.0 MEM_WARN=85 +ZOMBIE_WARN=1 while [[ $# -gt 0 ]]; do case "$1" in --output-dir) + if [[ $# -lt 2 ]]; then + echo "Error: --output-dir requires an argument" >&2 + exit 1 + fi REPORT_DIR="$2" shift 2 ;; @@ -179,7 +184,7 @@ parse_and_report() { ;; ZOMBIES=*) local zombies="${line#ZOMBIES=}" - if [[ -n "$zombies" ]] && ((zombies > 0)); then + if [[ -n "$zombies" ]] && ((zombies >= ZOMBIE_WARN)); then echo "WARN $label: ${zombies} zombie process(es)" >>"$FINDINGS_FILE" fi ;;