← All Scanning Guides
LXC Containers
Loop through all containers using pct list. Push the collector, run the scan, pull results.
scan-fleet.sh — LXC section
#!/usr/bin/env bash
set -euo pipefail

RESULTS=/tmp/vg-results
mkdir -p "$RESULTS"
VG_BIN=./version_gopher-linux-x64

echo "[*] Scanning LXC containers..."

pct list | awk 'NR > 1 {print $1}' | while read -r CTID; do
  echo "[*] CT $CTID"

  pct start "$CTID" 2>/dev/null || true
  pct exec "$CTID" -- mkdir -p \
    /opt/versiongopher /var/tmp/versiongopher

  pct push "$CTID" "$VG_BIN" \
    /opt/versiongopher/version_gopher \
    --perms 0755 --user 0 --group 0

  pct exec "$CTID" -- /bin/sh -lc \
    "/opt/versiongopher/version_gopher /usr/bin \
     -o /var/tmp/versiongopher/scan"

  pct pull "$CTID" \
    /var/tmp/versiongopher/scan.json \
    "$RESULTS/ct-${CTID}-scan.json"
done
QEMU/KVM Virtual Machines
Loop through VMs with qm list. Skip VMs without a working guest agent.
scan-fleet.sh — VM section
echo "[*] Scanning QEMU VMs..."

qm list | awk 'NR > 1 {print $1}' | while read -r VMID; do
  echo "[*] VM $VMID"

  qm start "$VMID" 2>/dev/null || true

  # Skip VMs without a working guest agent
  if ! qm agent "$VMID" ping >/dev/null 2>&1; then
    echo "[!] VM $VMID: no guest agent, skipping"
    continue
  fi

  qm guest exec "$VMID" -- /bin/sh -lc \
    "mkdir -p /opt/versiongopher /var/tmp/versiongopher"

  # Assumes collector is pre-staged in VM or template.
  # For injection options, see the Proxmox VM guide.

  qm guest exec "$VMID" --timeout 0 -- /bin/sh -lc \
    "/opt/versiongopher/version_gopher /usr/bin \
     -o /var/tmp/versiongopher/scan"

  qm guest exec "$VMID" -- /bin/sh -lc \
    "cat /var/tmp/versiongopher/scan.json" \
    | jq -r '."out-data"' \
    > "$RESULTS/vm-${VMID}-scan.json"
done

echo "[*] All results in $RESULTS/"
ls -la "$RESULTS/"
After scanning: Import all results into VersionGopher™ at once:
for f in /tmp/vg-results/*.json; do curl -F "file=@$f" http://localhost:5000/api/import; done
⚠️ Production note: For VMs, pre-bake the collector into your VM template image rather than injecting at runtime. The guest agent stdin channel has a ~1 MiB payload limit. See the Offline Image Injection guide.