diff --git a/examples/cuda-fanout/gpu-worker.lsp b/examples/cuda-fanout/gpu-worker.lsp index e6920ae..e057101 100644 --- a/examples/cuda-fanout/gpu-worker.lsp +++ b/examples/cuda-fanout/gpu-worker.lsp @@ -397,6 +397,22 @@ ((or (eq? line #f) (eof-object? line)) 0) (else (or (string->number (parse-trim line)) 0)))))))) +(define (health-dispatcher-procs) + ;; Count of bend-dispatcher processes on this host. <=1 = dispatcher + ;; functionally dead (only stale wrapper bash matched). Live + ;; multi-dispatcher = parent + 2 worker forks = ≥3 procs. + (let* ((pair (spawn-process-stdio "/usr/bin/pgrep" + '("-cf" "bend-dispatcher")))) + (cond + ((eq? pair #f) 0) + (else + (let ((line (read-line (cdr pair)))) + (close-port (car pair)) + (close-port (cdr pair)) + (cond + ((or (eq? line #f) (eof-object? line)) 0) + (else (or (string->number (parse-trim line)) 0)))))))) + (define (parse-trim s) ;; Strip leading/trailing whitespace from a single-line string. (let* ((n (string-length s)) @@ -439,6 +455,7 @@ (list 'vram-free-mb (health-vram-free-mb)) (list 'uptime-ms (current-time-ms)) (list 'pool-procs (health-pool-procs)) + (list 'dispatcher-procs (health-dispatcher-procs)) (list 'queue-ready (health-queue-count "ready")) (list 'queue-emitting (health-queue-count "emitting")) (list 'queue-done (health-queue-count "done"))))