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) <noreply@anthropic.com>
This commit is contained in:
parent
9a39abd64c
commit
7c801f6c3b
@ -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
|
||||
;;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user