diff --git a/monitoring/scripts/homelab-audit.sh b/monitoring/scripts/homelab-audit.sh index 55c8c1c..6477304 100755 --- a/monitoring/scripts/homelab-audit.sh +++ b/monitoring/scripts/homelab-audit.sh @@ -44,7 +44,7 @@ while [[ $# -gt 0 ]]; do ;; --hosts) if [[ $# -lt 2 ]]; then - echo "Error: --hosts requires an argument" >&2 + echo "Error: --hosts requires an argument (label:ip,label:ip,...)" >&2 exit 1 fi HOSTS_FILTER="$2" @@ -492,20 +492,24 @@ main() { if [[ -n "$HOSTS_FILTER" ]]; then # --hosts mode: audit specified hosts directly, skip Proxmox inventory + # Accepts comma-separated entries; each entry may be plain hostname or label:ip local check_proxmox=0 IFS=',' read -ra filter_hosts <<<"$HOSTS_FILTER" - for host in "${filter_hosts[@]}"; do - [[ "$host" == "proxmox" ]] && check_proxmox=1 + for entry in "${filter_hosts[@]}"; do + local label="${entry%%:*}" + [[ "$label" == "proxmox" ]] && check_proxmox=1 done if ((check_proxmox)); then echo " Checking Proxmox backup recency..." check_backup_recency fi - for host in "${filter_hosts[@]}"; do - echo " Auditing $host..." - parse_and_report "$host" "$host" - check_cert_expiry "$host" "$host" - AUDITED_HOSTS+=("$host") + for entry in "${filter_hosts[@]}"; do + local label="${entry%%:*}" + local addr="${entry#*:}" + echo " Auditing $label ($addr)..." + parse_and_report "$label" "$addr" + check_cert_expiry "$label" "$addr" + AUDITED_HOSTS+=("$label") ((host_count++)) || true done else