feat: dynamic summary, --hosts filter, and --json output (#24) #38
No reviewers
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
infra-audit
monitoring
operations
proxmox
script
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/claude-home#38
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/24-homelab-audit-sh-dynamic-summary-and-hosts-filter"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #24
Summary
Dynamic per-host summary table:
generate_summarynow prints a per-host breakdown (Warnings / Critical columns) in addition to the totals, and ends with aTotal: X warning(s), Y critical across Z host(s)line. Uses the globalAUDITED_HOSTSarray populated during the audit loop.--hostsfilter flag: New--hosts vm-116,manticoreargument skips Proxmox inventory discovery and audits only the specified hosts directly (the hostname is used as both the SSH target and the report label). Proxmox backup-recency check is skipped unlessproxmoxappears in the list.--jsonflag implemented: Newwrite_json_reportfunction writes$REPORT_DIR/findings.jsonwhen--jsonis passed. Emitstimestamp,hosts_audited,warnings,critical,ssh_failures,total_findings, and afindingsarray — ready for n8n ingestion.Files changed
monitoring/scripts/homelab-audit.shTest results
No automated test suite. Script passes
bash -nsyntax check. Logic verified by reading the modified file.AI Code Review
Files Reviewed
monitoring/scripts/homelab-audit.sh(modified)Findings
Correctness
grep -c "^WARN ${host}:"uses two spaces matching the findings format (echo "WARN $label: ..."). ✓line.split(None, 2)splits on the double-space delimiter, andhost_colon.rstrip(":")correctly strips the trailing colon. ✓--hosts+ backup recency logic is correct: The pre-scan loop checking for"proxmox"in the filter list before callingcheck_backup_recencyis sound. ✓AUDITED_HOSTSglobal scoping works: The array is declared globally, populated inmain(), and read ingenerate_summary()— correct for bash. ✓host_countthreading is clean:generate_summary "$host_count"is passed as a positional arg; the new "Total" line reads it fromlocal host_count="$1". ✓Security
"${SSH_USER}@${host}"is properly quoted; Python reads only fromsys.argv(already-evaluated shell variables). ✓Style & Conventions
homelab-audit.sh [--output-dir DIR]—--hostsand--jsonshould be listed there. The existing script documents every flag in this block.Suggestions
--hostsvalues:IFS=',' read -ra filter_hosts <<< "$HOSTS_FILTER"will include leading/trailing spaces in each element if the user writes--hosts "vm-116, manticore"(comma-space). A trim inside the loop would make this robust against a natural typo.datetime.utcnow()deprecated: In Python 3.12+datetime.datetime.utcnow()emits a deprecation warning. Replace withdatetime.datetime.now(datetime.timezone.utc).isoformat().replace('+00:00', 'Z')for forward-compatibility.((hw + hc > 0)) && printf ...silently skips hosts with no findings. Reasonable for noise reduction, but a comment noting it's intentional would help future readers.Verdict: APPROVED
Solid, well-scoped implementation. The three new features (per-host table,
--hostsfilter,--jsonoutput) each work correctly and follow the existing script's patterns. The suggestions above are non-blocking — the whitespace edge case is the most practically impactful, but it's documented away by the PR description. Ready to merge.Automated review by Claude PR Reviewer
2918081ab2to1a3785f01a