feat: right-size VM 115 (docker-sba) 16→8 vCPUs #44
@ -5,7 +5,7 @@
|
|||||||
# to collect system metrics, then generates a summary report.
|
# to collect system metrics, then generates a summary report.
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# homelab-audit.sh [--output-dir DIR]
|
# homelab-audit.sh [--output-dir DIR] [--hosts label:ip,label:ip,...]
|
||||||
#
|
#
|
||||||
# Environment overrides:
|
# Environment overrides:
|
||||||
# STUCK_PROC_CPU_WARN CPU% at which a D-state process is flagged (default: 10)
|
# STUCK_PROC_CPU_WARN CPU% at which a D-state process is flagged (default: 10)
|
||||||
@ -45,7 +45,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
;;
|
;;
|
||||||
--hosts)
|
--hosts)
|
||||||
if [[ $# -lt 2 ]]; then
|
if [[ $# -lt 2 ]]; then
|
||||||
echo "Error: --hosts requires an argument" >&2
|
echo "Error: --hosts requires an argument (label:ip,label:ip,...)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
HOSTS_FILTER="$2"
|
HOSTS_FILTER="$2"
|
||||||
@ -493,20 +493,24 @@ main() {
|
|||||||
|
|
||||||
if [[ -n "$HOSTS_FILTER" ]]; then
|
if [[ -n "$HOSTS_FILTER" ]]; then
|
||||||
# --hosts mode: audit specified hosts directly, skip Proxmox inventory
|
# --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
|
local check_proxmox=0
|
||||||
IFS=',' read -ra filter_hosts <<<"$HOSTS_FILTER"
|
IFS=',' read -ra filter_hosts <<<"$HOSTS_FILTER"
|
||||||
for host in "${filter_hosts[@]}"; do
|
for entry in "${filter_hosts[@]}"; do
|
||||||
[[ "$host" == "proxmox" ]] && check_proxmox=1
|
local label="${entry%%:*}"
|
||||||
|
[[ "$label" == "proxmox" ]] && check_proxmox=1
|
||||||
done
|
done
|
||||||
if ((check_proxmox)); then
|
if ((check_proxmox)); then
|
||||||
echo " Checking Proxmox backup recency..."
|
echo " Checking Proxmox backup recency..."
|
||||||
check_backup_recency
|
check_backup_recency
|
||||||
fi
|
fi
|
||||||
for host in "${filter_hosts[@]}"; do
|
for entry in "${filter_hosts[@]}"; do
|
||||||
echo " Auditing $host..."
|
local label="${entry%%:*}"
|
||||||
parse_and_report "$host" "$host"
|
local addr="${entry#*:}"
|
||||||
check_cert_expiry "$host" "$host"
|
echo " Auditing $label ($addr)..."
|
||||||
AUDITED_HOSTS+=("$host")
|
parse_and_report "$label" "$addr"
|
||||||
|
check_cert_expiry "$label" "$addr"
|
||||||
|
AUDITED_HOSTS+=("$label")
|
||||||
((host_count++)) || true
|
((host_count++)) || true
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
|||||||
@ -93,6 +93,34 @@ else
|
|||||||
fail "disk_usage" "expected 'N /path', got: '$result'"
|
fail "disk_usage" "expected 'N /path', got: '$result'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# --- --hosts flag parsing ---
|
||||||
|
echo ""
|
||||||
|
echo "=== --hosts argument parsing tests ==="
|
||||||
|
|
||||||
|
# Single host
|
||||||
|
input="vm-115:10.10.0.88"
|
||||||
|
IFS=',' read -ra entries <<<"$input"
|
||||||
|
label="${entries[0]%%:*}"
|
||||||
|
addr="${entries[0]#*:}"
|
||||||
|
if [[ "$label" == "vm-115" && "$addr" == "10.10.0.88" ]]; then
|
||||||
|
pass "--hosts single entry parsed: $label $addr"
|
||||||
|
else
|
||||||
|
fail "--hosts single" "expected 'vm-115 10.10.0.88', got: '$label $addr'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Multiple hosts
|
||||||
|
input="vm-115:10.10.0.88,lxc-225:10.10.0.225"
|
||||||
|
IFS=',' read -ra entries <<<"$input"
|
||||||
|
label1="${entries[0]%%:*}"
|
||||||
|
addr1="${entries[0]#*:}"
|
||||||
|
label2="${entries[1]%%:*}"
|
||||||
|
addr2="${entries[1]#*:}"
|
||||||
|
if [[ "$label1" == "vm-115" && "$addr1" == "10.10.0.88" && "$label2" == "lxc-225" && "$addr2" == "10.10.0.225" ]]; then
|
||||||
|
pass "--hosts multi entry parsed: $label1 $addr1, $label2 $addr2"
|
||||||
|
else
|
||||||
|
fail "--hosts multi" "unexpected parse result"
|
||||||
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Results: $PASS passed, $FAIL failed ==="
|
echo "=== Results: $PASS passed, $FAIL failed ==="
|
||||||
((FAIL == 0))
|
((FAIL == 0))
|
||||||
|
|||||||
@ -12,5 +12,5 @@ ostype: l26
|
|||||||
scsi0: local-lvm:vm-115-disk-0,size=256G
|
scsi0: local-lvm:vm-115-disk-0,size=256G
|
||||||
scsihw: virtio-scsi-pci
|
scsihw: virtio-scsi-pci
|
||||||
smbios1: uuid=19be98ee-f60d-473d-acd2-9164717fcd11
|
smbios1: uuid=19be98ee-f60d-473d-acd2-9164717fcd11
|
||||||
sockets: 2
|
sockets: 1
|
||||||
vmgenid: 682dfeab-8c63-4f0b-8ed2-8828c2f808ef
|
vmgenid: 682dfeab-8c63-4f0b-8ed2-8828c2f808ef
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user