Writing an Automated Daily Proxmox and Docker Health Audit Script That Logs Reports to Obsidian

Two mini-PC hypervisor nodes and container stacks scanned into a daily Markdown notebook report

Monitoring dashboards only help when someone remembers to look at them, and checking docker ps alone misses silent failures where a container stays Up even after its shared VPN network namespace detaches overnight. Writing a fast morning audit script that checks Proxmox cluster quorum, backup freshness, disk wear, DNS, and actual HTTP service ports, then appends a short Markdown summary directly into your Obsidian daily note, surfaces overnight drift right where you already plan your day.

In this tutorial, you will build a zero-dependency Python health patrol, serialize Git commits safely with flock, and schedule it with a systemd timer. For the story of how this morning briefing caught a detached media-stack network before breakfast, read Waking Up to an Automated Homelab Health Briefing in Obsidian Every Morning on Frizzle Tech Blog.

Prerequisites

Before setting up the timer, make sure you have non-interactive SSH key access from an audit runner container or Linux VM to your Proxmox VE hypervisor node(s), a Git-backed Obsidian vault (hosted on GitHub, GitLab, or self-hosted GitLab) cloned locally as a non-root user (UID 1000), and optionally an AI coding assistant such as Antigravity, Claude Code, or Codex to expand the JSON inventory across all your hosts.

  • Proxmox VE 8.x or 9.x node(s) reachable via BatchMode SSH key authentication (see Setting Up a Proxmox VE Homelab Cluster and Managing VMs with Terraform).
  • A Linux runner host or container with Python 3.11+, git, openssh-client, and util-linux (flock).
  • A local clone of your Obsidian vault at /path/to/vault owned by your non-root user (UID 1000).
  • Read-only access to the backup directory where Proxmox vzdump archives land (for example, /mnt/nas-backups/dump).

Step 1: Define a Declarative Homelab Audit Inventory

Keeping host targets in a standalone JSON file lets you add new containers or hypervisors without touching Python logic. Create /path/to/git/homelab-audit/targets.json:

{
  "proxmox_ssh_host": "root@<proxmox-node-ip>",
  "expected_quorate": true,
  "backup_dir": "/mnt/nas-backups/dump",
  "max_backup_age_hours": 26,
  "required_mounts": ["/mnt/nas-media", "/mnt/nas-backups"],
  "dns_check": {"server": "<pihole-ip>", "hostname": "proxmox.lan"},
  "http_services": [
    {"name": "Home Assistant", "url": "http://<ha-ip>:8123/manifest.json"},
    {"name": "Immich", "url": "http://<docker-ip>:2283/api/server/ping"},
    {"name": "VPN-Routed Indexer", "url": "http://<docker-ip>:9696/ping"}
  ]
}

Probing real HTTP endpoints on containers that share another container's network_mode: "service:vpn" is critical: if the VPN container restarts overnight, docker ps still reports the dependent containers as running, whereas an HTTP socket check immediately flags the broken namespace.

Step 2: Write the Proxmox, Storage, and HTTP Sweep Script

Create /path/to/git/homelab-audit/homelab_audit.py using only Python standard-library modules (subprocess, urllib.request, pathlib, json, and datetime):

#!/usr/bin/env python3
import datetime as dt
import json
import os
import pathlib
import subprocess
import sys
import time
import urllib.request

CONFIG_PATH = pathlib.Path(sys.argv[1]) if len(sys.argv) > 1 else pathlib.Path("/path/to/git/homelab-audit/targets.json")
VAULT_ROOT = pathlib.Path(os.environ.get("VAULT_ROOT", "/path/to/vault"))


def run_cmd(cmd: list[str], timeout: int = 15) -> tuple[int, str]:
    try:
        out = subprocess.check_output(cmd, stderr=subprocess.STDOUT, text=True, timeout=timeout)
        return 0, out.strip()
    except Exception as exc:
        return 1, str(exc)


def check_proxmox(ssh_host: str) -> list[str]:
    issues = []
    rc, out = run_cmd([
        "ssh", "-o", "BatchMode=yes", "-o", "ConnectTimeout=8",
        ssh_host, "pvecm status | grep -E 'Quorate:|Nodes:' && df -h / --output=pcent | tail -n1",
    ])
    if rc != 0:
        return [f"Proxmox SSH unreachable ({ssh_host}): {out}"]
    if "Quorate:          Yes" not in out and "Quorate: Yes" not in " ".join(out.split()):
        issues.append("Proxmox cluster is NOT quorate")
    pct_line = out.splitlines()[-1].strip().rstrip("%")
    if pct_line.isdigit() and int(pct_line) >= 85:
        issues.append(f"Proxmox root filesystem at {pct_line}%")
    return issues


def check_backups(backup_dir: str, max_age_hours: int) -> list[str]:
    p = pathlib.Path(backup_dir)
    if not p.is_dir():
        return [f"Backup directory missing or unmounted: {backup_dir}"]
    archives = list(p.glob("vzdump-*.*"))
    if not archives:
        return [f"No vzdump archives found in {backup_dir}"]
    newest_age_h = (time.time() - max(f.stat().st_mtime for f in archives)) / 3600.0
    if newest_age_h > max_age_hours:
        return [f"Stale Proxmox backups: newest archive is {newest_age_h:.1f}h old"]
    return []


def check_http(services: list[dict]) -> list[str]:
    failures = []
    for svc in services:
        req = urllib.request.Request(svc["url"], method="GET")
        try:
            with urllib.request.urlopen(req, timeout=8) as resp:
                if resp.status >= 400:
                    failures.append(f"{svc['name']} returned HTTP {resp.status}")
        except Exception as exc:
            failures.append(f"{svc['name']} unreachable ({svc['url']}): {exc}")
    return failures


def main() -> int:
    cfg = json.loads(CONFIG_PATH.read_text(encoding="utf-8"))
    findings: list[str] = []
    findings.extend(check_proxmox(cfg["proxmox_ssh_host"]))
    findings.extend(check_backups(cfg["backup_dir"], cfg["max_backup_age_hours"]))
    for mnt in cfg.get("required_mounts", []):
        if not os.path.ismount(mnt):
            findings.append(f"Required NAS mount inactive: {mnt}")
    findings.extend(check_http(cfg.get("http_services", [])))

    now = dt.datetime.now()
    daily_note = VAULT_ROOT / "Daily Notes" / f"{now:%Y-%m-%d}.md"
    daily_note.parent.mkdir(parents=True, exist_ok=True)

    status_badge = "PASS" if not findings else f"DEGRADED ({len(findings)} issue(s))"
    lines = [
        "",
        f"## Homelab Morning Health Audit ({now:%H:%M})",
        f"- **Overall Status**: `{status_badge}` | Checked `{len(cfg.get('http_services', []))}` HTTP endpoints + Proxmox quorum + NAS backups.",
    ]
    for item in findings:
        lines.append(f"- **Action Needed**: {item}")
    with daily_note.open("a", encoding="utf-8") as fh:
        fh.write("\n".join(lines) + "\n")
    return 0 if not findings else 2


if __name__ == "__main__":
    sys.exit(main())

Make the script executable with chmod +x /path/to/git/homelab-audit/homelab_audit.py.

Step 3: Serialize Obsidian Git Syncs with flock

When multiple scheduled jobs or local AI agents write to the same Git-backed Obsidian vault, concurrent git pull --rebase calls can collide on .git/index.lock. Wrap the pull, audit execution, commit, and push inside /path/to/git/homelab-audit/run_audit.sh using flock as your non-root user:

#!/usr/bin/env bash
set -euo pipefail

export VAULT_ROOT="/path/to/vault"
LOCK_FILE="/tmp/obsidian-vault-git.lock"
TODAY="$(date +%F)"

flock -w 60 "$LOCK_FILE" bash -c '
  git -C "$VAULT_ROOT" pull --rebase --autostash origin main
  python3 /path/to/git/homelab-audit/homelab_audit.py /path/to/git/homelab-audit/targets.json || true
  git -C "$VAULT_ROOT" add "Daily Notes/'"$TODAY"'.md"
  if ! git -C "$VAULT_ROOT" diff --cached --quiet; then
    git -C "$VAULT_ROOT" commit -m "chore(homelab): morning health audit '"$TODAY"'"
    git -C "$VAULT_ROOT" push origin main
  fi
'

Run chmod +x /path/to/git/homelab-audit/run_audit.sh and execute it once manually as your normal user (never via sudo) so file ownership inside /path/to/vault stays cleanly at UID 1000.

Step 4: Schedule the Morning Patrol with a User Systemd Timer

Create ~/.config/systemd/user/homelab-audit.service and ~/.config/systemd/user/homelab-audit.timer so the sweep runs automatically at 06:15 every morning under your non-root account:

# ~/.config/systemd/user/homelab-audit.service
[Unit]
Description=Daily Proxmox and Docker Health Audit to Obsidian

[Service]
Type=oneshot
ExecStart=/path/to/git/homelab-audit/run_audit.sh
# ~/.config/systemd/user/homelab-audit.timer
[Unit]
Description=Run Homelab Health Audit Daily at 06:15

[Timer]
OnCalendar=*-*-* 06:15:00
Persistent=true

[Install]
WantedBy=timers.target

Enable lingering and activate the timer:

loginctl enable-linger "$USER"
systemctl --user daemon-reload
systemctl --user enable --now homelab-audit.timer
systemctl --user list-timers homelab-audit.timer

Open /path/to/vault/Daily Notes/$(date +%F).md in Obsidian to confirm the ## Homelab Morning Health Audit block renders cleanly.

Hardware & Gear Used in This Guide

  • Hypervisor cluster: Two compact x86-64 Proxmox VE nodes paired with a low-power Corosync QDevice witness
  • Container runner: Lightweight Linux VM or LXC container with SSH BatchMode keys and local Obsidian Git clone
  • Backup target: Dedicated multi-bay NAS storing nightly zstd-compressed Proxmox vzdump snapshots
  • Local DNS: Redundant Pi-hole instances resolving internal .lan service hostnames

What You Can Do Next

Later,
     SteveO