diff --git a/audit/internal/webui/api.go b/audit/internal/webui/api.go index a1b090a..fe66958 100644 --- a/audit/internal/webui/api.go +++ b/audit/internal/webui/api.go @@ -667,6 +667,22 @@ func (h *handler) handleAPIInstallStream(w http.ResponseWriter, r *http.Request) // ── Metrics SSE ─────────────────────────────────────────────────────────────── +func (h *handler) handleAPIMetricsLatest(w http.ResponseWriter, r *http.Request) { + sample, ok := h.latestMetric() + if !ok { + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write([]byte("{}")) + return + } + b, err := json.Marshal(sample) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Header().Set("Content-Type", "application/json") + _, _ = w.Write(b) +} + func (h *handler) handleAPIMetricsStream(w http.ResponseWriter, r *http.Request) { if !sseStart(w) { return diff --git a/audit/internal/webui/pages.go b/audit/internal/webui/pages.go index 059edbd..8a8af9d 100644 --- a/audit/internal/webui/pages.go +++ b/audit/internal/webui/pages.go @@ -532,16 +532,10 @@ function refreshCharts() { } setInterval(refreshCharts, 3000); -const es = new EventSource('/api/metrics/stream'); -es.addEventListener('metrics', e => { - const d = JSON.parse(e.data); - - // Show/hide Fan RPM card based on data availability +fetch('/api/metrics/latest').then(r => r.json()).then(d => { const fanCard = document.getElementById('card-server-fans'); if (fanCard) fanCard.style.display = (d.fans && d.fans.length > 0) ? '' : 'none'; - -}); -es.onerror = () => {}; +}).catch(() => {}); ` } diff --git a/audit/internal/webui/server.go b/audit/internal/webui/server.go index 941ddbc..621be72 100644 --- a/audit/internal/webui/server.go +++ b/audit/internal/webui/server.go @@ -270,6 +270,7 @@ func NewHandler(opts HandlerOptions) http.Handler { // Metrics — SSE stream of live sensor data + server-side SVG charts + CSV export mux.HandleFunc("GET /api/metrics/stream", h.handleAPIMetricsStream) + mux.HandleFunc("GET /api/metrics/latest", h.handleAPIMetricsLatest) mux.HandleFunc("GET /api/metrics/chart/", h.handleMetricsChartSVG) mux.HandleFunc("GET /api/metrics/export.csv", h.handleAPIMetricsExportCSV) @@ -1230,13 +1231,6 @@ probe(); func (h *handler) handlePage(w http.ResponseWriter, r *http.Request) { page := strings.TrimPrefix(r.URL.Path, "/") if page == "" { - // Serve loading page until audit snapshot exists - if _, err := os.Stat(h.opts.AuditPath); err != nil { - w.Header().Set("Cache-Control", "no-store") - w.Header().Set("Content-Type", "text/html; charset=utf-8") - _, _ = w.Write([]byte(loadingPageHTML)) - return - } page = "dashboard" } // Redirect old routes to new names diff --git a/bible b/bible index 688b87e..456c1f0 160000 --- a/bible +++ b/bible @@ -1 +1 @@ -Subproject commit 688b87e98deed5fadd71e10e123073640d92c15a +Subproject commit 456c1f022c17499ab059ae753684174b2621d74c diff --git a/internal/chart b/internal/chart index 05db699..ac8120c 160000 --- a/internal/chart +++ b/internal/chart @@ -1 +1 @@ -Subproject commit 05db6994d4a77bc95cc9d96892f81875f2f9fa01 +Subproject commit ac8120c8ab800bb3067efcada50bc4272dc8f76a diff --git a/iso/builder/build.sh b/iso/builder/build.sh index 56f829e..c4e0b5e 100755 --- a/iso/builder/build.sh +++ b/iso/builder/build.sh @@ -245,7 +245,6 @@ rm -f \ "${OVERLAY_STAGE_DIR}/etc/bee-release" \ "${OVERLAY_STAGE_DIR}/root/.ssh/authorized_keys" \ "${OVERLAY_STAGE_DIR}/usr/local/bin/bee" \ - "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-gpu-stress" \ "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-nccl-gpu-stress" \ "${OVERLAY_STAGE_DIR}/usr/local/bin/john" \ "${OVERLAY_STAGE_DIR}/usr/local/lib/bee/bee-gpu-burn-worker" \ @@ -305,7 +304,6 @@ if [ "$BEE_GPU_VENDOR" = "nvidia" ] && [ -f "$GPU_BURN_WORKER_BIN" ]; then chmod +x "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-gpu-burn" 2>/dev/null || true chmod +x "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-john-gpu-stress" 2>/dev/null || true chmod +x "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-nccl-gpu-stress" 2>/dev/null || true - ln -sfn bee-gpu-burn "${OVERLAY_STAGE_DIR}/usr/local/bin/bee-gpu-stress" fi # --- inject smoketest into overlay so it runs directly on the live CD --- diff --git a/iso/overlay/etc/systemd/system/bee-audit.service b/iso/overlay/etc/systemd/system/bee-audit.service index aec5af9..4ca6b79 100644 --- a/iso/overlay/etc/systemd/system/bee-audit.service +++ b/iso/overlay/etc/systemd/system/bee-audit.service @@ -1,25 +1,9 @@ [Unit] -Description=Bee: schedule startup hardware audit via task queue -# Start AFTER bee-web, not before — bee-web must not wait for audit. -After=bee-web.service -Wants=bee-web.service +Description=Bee: on-demand hardware audit (not started automatically) [Service] Type=oneshot RemainAfterExit=yes -# Wait up to 90s for bee-web to respond on /healthz, then sleep 60s for -# the system to settle (GPU drivers, sensors), then enqueue the audit as -# a background task so it appears in the task list and logs. -ExecStart=/bin/sh -c '\ - i=0; \ - while [ $i -lt 90 ]; do \ - if curl -sf http://localhost/healthz >/dev/null 2>&1; then break; fi; \ - sleep 1; i=$((i+1)); \ - done; \ - sleep 60; \ - curl -sf -X POST http://localhost/api/audit/run >/dev/null' +ExecStart=/bin/sh -c 'curl -sf -X POST http://localhost/api/audit/run >/dev/null' StandardOutput=journal StandardError=journal - -[Install] -WantedBy=multi-user.target diff --git a/iso/overlay/usr/local/bin/bee-install b/iso/overlay/usr/local/bin/bee-install index f4c367a..ac30157 100755 --- a/iso/overlay/usr/local/bin/bee-install +++ b/iso/overlay/usr/local/bin/bee-install @@ -12,17 +12,55 @@ set -euo pipefail +usage() { + cat >&2 <<'EOF' +Usage: bee-install [logfile] + + Installs the live system to a local disk (WIPES the target). + + device Target block device, e.g. /dev/sda or /dev/nvme0n1 + Must be a hard disk or NVMe — NOT a CD-ROM (/dev/sr*) + logfile Optional path for progress log (default: /tmp/bee-install.log) + +Examples: + bee-install /dev/sda + bee-install /dev/nvme0n1 + bee-install /dev/sdb /tmp/my-install.log + +WARNING: ALL DATA ON WILL BE ERASED. + +Layout (UEFI): GPT — partition 1: EFI 512MB vfat, partition 2: root ext4 +Layout (BIOS): MBR — partition 1: root ext4 +EOF + exit 1 +} + DEVICE="${1:-}" LOGFILE="${2:-/tmp/bee-install.log}" -if [ -z "$DEVICE" ]; then - echo "Usage: bee-install [logfile]" >&2 - exit 1 +if [ -z "$DEVICE" ] || [ "$DEVICE" = "--help" ] || [ "$DEVICE" = "-h" ]; then + usage fi if [ ! -b "$DEVICE" ]; then echo "ERROR: $DEVICE is not a block device" >&2 + echo "Run 'lsblk' to list available disks." >&2 exit 1 fi +# Block CD-ROM devices +case "$DEVICE" in + /dev/sr*|/dev/scd*) + echo "ERROR: $DEVICE is a CD-ROM/optical device — cannot install to it." >&2 + echo "Run 'lsblk' to find the target disk (e.g. /dev/sda, /dev/nvme0n1)." >&2 + exit 1 + ;; +esac +# Check required tools +for tool in parted mkfs.vfat mkfs.ext4 unsquashfs grub-install update-grub; do + if ! command -v "$tool" >/dev/null 2>&1; then + echo "ERROR: required tool not found: $tool" >&2 + exit 1 + fi +done SQUASHFS="/run/live/medium/live/filesystem.squashfs" if [ ! -f "$SQUASHFS" ]; then diff --git a/iso/overlay/usr/local/bin/bee-john-gpu-stress b/iso/overlay/usr/local/bin/bee-john-gpu-stress index 938ca0d..66aa778 100644 --- a/iso/overlay/usr/local/bin/bee-john-gpu-stress +++ b/iso/overlay/usr/local/bin/bee-john-gpu-stress @@ -23,6 +23,62 @@ contains_csv() { echo ",${haystack}," | grep -q ",${needle}," } +show_opencl_diagnostics() { + if command -v clinfo >/dev/null 2>&1; then + echo "-- clinfo -l --" >&2 + clinfo -l >&2 || true + fi + echo "-- john --list=opencl-devices --" >&2 + ./john --list=opencl-devices >&2 || true +} + +ensure_nvidia_uvm() { + if lsmod 2>/dev/null | grep -q '^nvidia_uvm '; then + return 0 + fi + if [ "$(id -u)" != "0" ]; then + return 1 + fi + + ko="/usr/local/lib/nvidia/nvidia-uvm.ko" + [ -f "${ko}" ] || return 1 + + if ! insmod "${ko}" >/dev/null 2>&1; then + return 1 + fi + + uvm_major=$(grep -m1 ' nvidia-uvm$' /proc/devices | awk '{print $1}') + if [ -n "${uvm_major}" ]; then + mknod -m 666 /dev/nvidia-uvm c "${uvm_major}" 0 2>/dev/null || true + mknod -m 666 /dev/nvidia-uvm-tools c "${uvm_major}" 1 2>/dev/null || true + fi + return 0 +} + +ensure_opencl_ready() { + out=$(./john --list=opencl-devices 2>&1 || true) + if echo "${out}" | grep -q "Device #"; then + return 0 + fi + + if ensure_nvidia_uvm; then + out=$(./john --list=opencl-devices 2>&1 || true) + if echo "${out}" | grep -q "Device #"; then + return 0 + fi + fi + + echo "OpenCL devices are not available for John." >&2 + if ! lsmod 2>/dev/null | grep -q '^nvidia_uvm '; then + echo "nvidia_uvm is not loaded." >&2 + fi + if [ ! -e /dev/nvidia-uvm ]; then + echo "/dev/nvidia-uvm is missing." >&2 + fi + show_opencl_diagnostics + return 1 +} + while [ "$#" -gt 0 ]; do case "$1" in --seconds|-t) [ "$#" -ge 2 ] || usage; SECONDS="$2"; shift 2 ;; @@ -76,6 +132,8 @@ echo "john_devices=${JOHN_DEVICES}" cd "${JOHN_DIR}" +ensure_opencl_ready || exit 1 + choose_format() { if [ -n "${FORMAT}" ]; then echo "${FORMAT}"