dsh-nvtop-panel 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -7
- package/client.js +110 -31
- package/index.js +331 -48
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -18,10 +18,10 @@ GPU monitor 2 GPUs
|
|
|
18
18
|
└─────────────────────────────────┘
|
|
19
19
|
|
|
20
20
|
Processes
|
|
21
|
-
PID USER
|
|
22
|
-
10124 alice 0 C 62% 9.4 GiB 3.1%
|
|
23
|
-
10192 bob
|
|
24
|
-
10230 alice 2 C 89% 87.2 GiB 18.3%
|
|
21
|
+
PID USER DEV TYPE GPU GPU MEM CPU HOST MEM Command
|
|
22
|
+
10124 alice 0 C 62% 9.4 GiB 3.1% 1.8 GiB llama-server
|
|
23
|
+
10192 bob 1 C 47% 8.9 GiB 2.4% 1.6 GiB python train.py
|
|
24
|
+
10230 alice 2 C 89% 87.2 GiB 18.3% 2.6 GiB vllm serve …
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Features
|
|
@@ -74,11 +74,51 @@ Tunable in your profile's `cordis.patch.yml`:
|
|
|
74
74
|
```yaml
|
|
75
75
|
- id: dsh-nvtop-panel
|
|
76
76
|
config:
|
|
77
|
-
intervalMs: 2000 # client poll interval, 500
|
|
77
|
+
intervalMs: 2000 # client poll interval, 500-60000 ms
|
|
78
|
+
peers: # extra units sampled over SSH (see DGX Spark below)
|
|
79
|
+
- host: 192.0.2.11
|
|
80
|
+
title: 'Spark #2'
|
|
81
|
+
- host: 192.0.2.21
|
|
82
|
+
user: sparky
|
|
83
|
+
port: 22
|
|
78
84
|
```
|
|
79
85
|
|
|
80
|
-
Editing the interval restarts the plugin and the panel picks
|
|
81
|
-
next poll.
|
|
86
|
+
Editing the interval or the peer list restarts the plugin and the panel picks
|
|
87
|
+
up the new value on the next poll.
|
|
88
|
+
|
|
89
|
+
## DGX Spark (GB10) support
|
|
90
|
+
|
|
91
|
+
**Unified memory.** On a DGX Spark the GB10 GPU shares one LPDDR5X pool with
|
|
92
|
+
the CPU, and `nvidia-smi` reports `memory.used` / `memory.total` as `[N/A]`.
|
|
93
|
+
Following the [sparkDash](https://github.com/MiaAI-Lab/sparkDash) approach, the
|
|
94
|
+
card then shows:
|
|
95
|
+
|
|
96
|
+
- **Memory (unified pool)** - `used` is the GPU-allocated share (sum of
|
|
97
|
+
compute-apps), `total` is the OS-visible pool (`MemTotal`);
|
|
98
|
+
- **Pool** - a second bar with whole-pool occupancy (GPU + CPU), with
|
|
99
|
+
`MemAvailable` as the free figure;
|
|
100
|
+
- a `unified` chip marks such cards. Discrete GPUs keep using `nvidia-smi`
|
|
101
|
+
values unchanged.
|
|
102
|
+
|
|
103
|
+
**Daisy-chained units.** Spark clusters do not expose peer GPUs through local
|
|
104
|
+
`nvidia-smi`; each unit is its own machine. Add peers with the `peers` config
|
|
105
|
+
above and the plugin samples each one over SSH (BatchMode, key auth only -
|
|
106
|
+
`ssh <host>` must work without a password for the user dsh runs as).
|
|
107
|
+
Interconnect peers usually sit on `192.0.2.x` (the ConnectX subnet): check
|
|
108
|
+
`ip neigh`. Cards from every unit share one grid (side by side when width
|
|
109
|
+
allows) and one merged nvtop-style process table whose `DEV` column is the unit
|
|
110
|
+
index (`Spark #N` labels the cards). Peers are probed in the background, so a
|
|
111
|
+
down or slow peer never delays the panel: it keeps showing its last error
|
|
112
|
+
(`No route to host`, `Permission denied`, …) as a banner and retries every 10 s.
|
|
113
|
+
A peer without an NVIDIA GPU shows a note instead of silently disappearing.
|
|
114
|
+
|
|
115
|
+
Anyone who can open this DSH page can read the peer units' process tables;
|
|
116
|
+
peers are therefore exactly as visible as the dsh user's SSH keys allow.
|
|
117
|
+
|
|
118
|
+
Per-process GPU utilization and per-process unified-memory splits are
|
|
119
|
+
driver-level statistics that `nvidia-smi`'s query interface does not expose; the
|
|
120
|
+
`GPU` column shows device utilization and `GPU MEM` the compute-app allocation,
|
|
121
|
+
as nvtop does on this hardware.
|
|
82
122
|
|
|
83
123
|
## Verify
|
|
84
124
|
|
package/client.js
CHANGED
|
@@ -14,6 +14,8 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
panel: 'GPU monitor',
|
|
15
15
|
gpus: '{n} GPU',
|
|
16
16
|
gpusOther: '{n} GPUs',
|
|
17
|
+
units: '{n} unit',
|
|
18
|
+
unitsOther: '{n} units',
|
|
17
19
|
utilization: 'Utilization',
|
|
18
20
|
memory: 'Memory',
|
|
19
21
|
temperature: 'Temp',
|
|
@@ -23,6 +25,7 @@ window.__ModuleLoader__.load({
|
|
|
23
25
|
noProcesses: 'No GPU processes',
|
|
24
26
|
unavailable: 'GPU stats unavailable',
|
|
25
27
|
stale: 'Waiting for data…',
|
|
28
|
+
localUnit: 'This machine',
|
|
26
29
|
pid: 'PID',
|
|
27
30
|
user: 'USER',
|
|
28
31
|
dev: 'DEV',
|
|
@@ -70,8 +73,13 @@ window.__ModuleLoader__.load({
|
|
|
70
73
|
function Bar(props) {
|
|
71
74
|
const ratio = props.ratio;
|
|
72
75
|
const pct = ratio === null || ratio === undefined ? 0 : Math.max(0, Math.min(100, ratio * 100));
|
|
76
|
+
const otherPct = props.other === null || props.other === undefined
|
|
77
|
+
? 0 : Math.max(0, Math.min(100 - pct, props.other * 100));
|
|
73
78
|
return h('div', { className: 'nvtp-bar ' + levelClass(ratio) },
|
|
74
|
-
h('div', { className: 'nvtp-bar-fill', style: { width: pct + '%' } })
|
|
79
|
+
h('div', { className: 'nvtp-bar-fill', style: { width: pct + '%' } }),
|
|
80
|
+
props.other === null || props.other === undefined
|
|
81
|
+
? null
|
|
82
|
+
: h('div', { className: 'nvtp-bar-fill nvtp-bar-other', style: { width: otherPct + '%' } }));
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
function Stat(props) {
|
|
@@ -81,23 +89,39 @@ window.__ModuleLoader__.load({
|
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
function GpuCard(props) {
|
|
84
|
-
const { gpu, t } = props;
|
|
92
|
+
const { gpu, t, unitTitle } = props;
|
|
85
93
|
const memRatio = gpu.memoryUsed !== null && gpu.memoryTotal
|
|
86
94
|
? gpu.memoryUsed / gpu.memoryTotal : null;
|
|
87
95
|
const powerRatio = gpu.powerDraw !== null && gpu.powerLimit
|
|
88
96
|
? gpu.powerDraw / gpu.powerLimit : null;
|
|
97
|
+
// Unified pool: stacked bar — GPU-allocated share plus everything else
|
|
98
|
+
// (CPU, page cache) that eats the shared pool; free stays empty.
|
|
99
|
+
const unifiedPool = gpu.unified === true && gpu.memoryAvailable !== null && gpu.memoryTotal;
|
|
100
|
+
const otherRatio = unifiedPool
|
|
101
|
+
? Math.max(0, (gpu.memoryTotal - gpu.memoryAvailable) / gpu.memoryTotal
|
|
102
|
+
- (memRatio ?? 0))
|
|
103
|
+
: null;
|
|
104
|
+
const memTitle = unifiedPool
|
|
105
|
+
? `GPU ${fmtMemory(gpu.memoryUsed)} · other ${fmtMemory(Math.max(0, gpu.memoryTotal - gpu.memoryAvailable - gpu.memoryUsed))} · free ${fmtMemory(gpu.memoryAvailable)} of ${fmtMemory(gpu.memoryTotal)} unified pool`
|
|
106
|
+
: undefined;
|
|
89
107
|
return h('section', { className: 'nvtp-card' },
|
|
90
108
|
h('header', { className: 'nvtp-card-head' },
|
|
91
109
|
h('span', { className: 'nvtp-card-name' }, gpu.name),
|
|
92
|
-
|
|
110
|
+
gpu.unified === true
|
|
111
|
+
? h('span', { className: 'nvtp-chip' }, 'unified')
|
|
112
|
+
: null,
|
|
113
|
+
h('span', { className: 'nvtp-card-index' },
|
|
114
|
+
unitTitle !== null && unitTitle !== undefined
|
|
115
|
+
? `${unitTitle} · GPU ${gpu.index}`
|
|
116
|
+
: `GPU ${gpu.index}`)),
|
|
93
117
|
h('div', { className: 'nvtp-rows' },
|
|
94
118
|
h('div', { className: 'nvtp-row' },
|
|
95
119
|
h('span', { className: 'nvtp-row-label' }, t('utilization')),
|
|
96
120
|
h(Bar, { ratio: gpu.utilization === null ? null : gpu.utilization / 100 }),
|
|
97
121
|
h('span', { className: 'nvtp-row-value' }, fmtPercent(gpu.utilization))),
|
|
98
|
-
h('div', { className: 'nvtp-row' },
|
|
122
|
+
h('div', { className: 'nvtp-row', title: memTitle },
|
|
99
123
|
h('span', { className: 'nvtp-row-label' }, t('memory')),
|
|
100
|
-
h(Bar, { ratio: memRatio }),
|
|
124
|
+
h(Bar, { ratio: memRatio, other: otherRatio }),
|
|
101
125
|
h('span', { className: 'nvtp-row-value' },
|
|
102
126
|
`${fmtMemory(gpu.memoryUsed)} / ${fmtMemory(gpu.memoryTotal)}`)),
|
|
103
127
|
h('div', { className: 'nvtp-row' },
|
|
@@ -112,16 +136,21 @@ window.__ModuleLoader__.load({
|
|
|
112
136
|
}
|
|
113
137
|
|
|
114
138
|
function ProcessTable(props) {
|
|
115
|
-
const { processes, t } = props;
|
|
139
|
+
const { processes, t, multiUnit } = props;
|
|
116
140
|
if (processes.length === 0) {
|
|
117
141
|
return h('div', { className: 'nvtp-empty-note' }, t('noProcesses'));
|
|
118
142
|
}
|
|
119
|
-
|
|
143
|
+
const deviceText = (p) => {
|
|
144
|
+
const gpuIndex = p.device === null || p.device === undefined ? '—' : String(p.device);
|
|
145
|
+
return multiUnit ? String(p.unitIdx) : gpuIndex;
|
|
146
|
+
};
|
|
147
|
+
return h('div', { className: 'nvtp-scroll' },
|
|
148
|
+
h('table', { className: 'nvtp-table nvtp-procs-table' },
|
|
120
149
|
h('thead', null,
|
|
121
150
|
h('tr', null,
|
|
122
151
|
h('th', { className: 'nvtp-num' }, t('pid')),
|
|
123
152
|
h('th', null, t('user')),
|
|
124
|
-
h('th', { className: 'nvtp-num' }, t('dev')),
|
|
153
|
+
h('th', { className: 'nvtp-num', title: multiUnit ? 'unit index' : undefined }, t('dev')),
|
|
125
154
|
h('th', null, t('type')),
|
|
126
155
|
h('th', { className: 'nvtp-num' }, t('gpu')),
|
|
127
156
|
h('th', { className: 'nvtp-num' }, t('gpuMem')),
|
|
@@ -129,16 +158,16 @@ window.__ModuleLoader__.load({
|
|
|
129
158
|
h('th', { className: 'nvtp-num' }, t('hostMem')),
|
|
130
159
|
h('th', { className: 'nvtp-cmd' }, t('command')))),
|
|
131
160
|
h('tbody', null,
|
|
132
|
-
processes.map((p) => h('tr', { key: p.pid + ':' + (p.device ?? '') + ':' + p.command.slice(0, 24) },
|
|
161
|
+
processes.map((p) => h('tr', { key: p.unitIdx + ':' + p.pid + ':' + (p.device ?? '') + ':' + p.command.slice(0, 24) },
|
|
133
162
|
h('td', { className: 'nvtp-num' }, fmtInt(p.pid)),
|
|
134
163
|
h('td', { className: 'nvtp-user' }, p.user ?? '—'),
|
|
135
|
-
h('td', { className: 'nvtp-num' },
|
|
164
|
+
h('td', { className: 'nvtp-num' }, deviceText(p)),
|
|
136
165
|
h('td', { className: 'nvtp-type' }, p.type ?? '—'),
|
|
137
166
|
h('td', { className: 'nvtp-num' }, fmtPercent(p.gpuUtilization)),
|
|
138
167
|
h('td', { className: 'nvtp-num' }, fmtMemory(p.memoryUsed)),
|
|
139
168
|
h('td', { className: 'nvtp-num' }, p.cpuPercent === null || p.cpuPercent === undefined ? '—' : `${p.cpuPercent.toFixed(1)}%`),
|
|
140
169
|
h('td', { className: 'nvtp-num' }, fmtHostMemory(p.hostMemKib)),
|
|
141
|
-
h('td', { className: 'nvtp-cmd nvtp-name' }, p.command)))));
|
|
170
|
+
h('td', { className: 'nvtp-cmd nvtp-name' }, p.command))))));
|
|
142
171
|
}
|
|
143
172
|
|
|
144
173
|
const CSS = `
|
|
@@ -154,8 +183,9 @@ window.__ModuleLoader__.load({
|
|
|
154
183
|
.nvtp-row{display:grid;grid-template-columns:64px 1fr 130px;gap:10px;align-items:center;font-size:12px}
|
|
155
184
|
.nvtp-row-label{color:var(--dsw-alias-label-secondary)}
|
|
156
185
|
.nvtp-row-value{text-align:right;font-variant-numeric:tabular-nums}
|
|
157
|
-
.nvtp-bar{height:8px;border-radius:4px;background:var(--dsw-alias-bg-layer-2);overflow:hidden}
|
|
158
|
-
.nvtp-bar-fill{height:100%;
|
|
186
|
+
.nvtp-bar{height:8px;border-radius:4px;background:var(--dsw-alias-bg-layer-2);overflow:hidden;display:flex}
|
|
187
|
+
.nvtp-bar-fill{height:100%;background:var(--dsw-alias-brand-primary);transition:width .4s ease;flex:none}
|
|
188
|
+
.nvtp-bar-other{background:var(--dsw-alias-state-idle-primary);opacity:.7}
|
|
159
189
|
.nvtp-ok .nvtp-bar-fill{background:var(--dsw-alias-brand-primary)}
|
|
160
190
|
.nvtp-warm .nvtp-bar-fill{background:var(--dsw-alias-state-warn-primary)}
|
|
161
191
|
.nvtp-hot .nvtp-bar-fill{background:var(--dsw-alias-state-error-primary)}
|
|
@@ -165,15 +195,22 @@ window.__ModuleLoader__.load({
|
|
|
165
195
|
.nvtp-stat-value{font-size:14px;font-variant-numeric:tabular-nums}
|
|
166
196
|
.nvtp-procs{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);padding:14px 16px}
|
|
167
197
|
.nvtp-procs h2{margin:0 0 10px;font-size:14px;font-weight:600}
|
|
198
|
+
.nvtp-scroll{overflow-x:auto;overscroll-behavior-x:contain}
|
|
168
199
|
.nvtp-table{width:100%;border-collapse:collapse;font-size:13px}
|
|
200
|
+
.nvtp-procs-table{width:max-content;min-width:100%}
|
|
169
201
|
.nvtp-table th{color:var(--dsw-alias-label-secondary);font-weight:500;text-align:left;padding:4px 8px;border-bottom:1px solid var(--dsw-alias-border-l2);font-size:12px;white-space:nowrap}
|
|
170
202
|
.nvtp-table td{padding:5px 8px;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap}
|
|
171
203
|
.nvtp-num{text-align:right;font-variant-numeric:tabular-nums}
|
|
172
204
|
.nvtp-name{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
173
|
-
.nvtp-procs-table .nvtp-cmd{max-width:
|
|
205
|
+
.nvtp-procs-table .nvtp-cmd{max-width:none}
|
|
174
206
|
.nvtp-empty-note{color:var(--dsw-alias-label-secondary);font-size:13px}
|
|
175
207
|
.nvtp-error{border:1px solid var(--dsw-alias-state-error-primary);border-radius:10px;padding:14px 16px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1)}
|
|
176
208
|
.nvtp-error-label{color:var(--dsw-alias-state-error-primary);font-weight:600;margin-bottom:6px}
|
|
209
|
+
.nvtp-unit-error{display:flex;gap:10px;padding:8px 14px;font-size:12px;align-items:baseline}
|
|
210
|
+
.nvtp-unit-error .nvtp-error-label{margin-bottom:0;flex:none}
|
|
211
|
+
.nvtp-note{border:1px solid var(--dsw-alias-border-l2);border-radius:10px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1)}
|
|
212
|
+
.nvtp-note-label{font-weight:600;flex:none}
|
|
213
|
+
.nvtp-chip{border:1px solid var(--dsw-alias-border-l2);border-radius:999px;padding:1px 8px;font-size:11px;color:var(--dsw-alias-label-secondary);flex:none}
|
|
177
214
|
`;
|
|
178
215
|
|
|
179
216
|
function pluralize(template, other, count) {
|
|
@@ -199,10 +236,12 @@ window.__ModuleLoader__.load({
|
|
|
199
236
|
const tick = async () => {
|
|
200
237
|
try {
|
|
201
238
|
const response = await fetch('/api/nvtop', { credentials: 'same-origin' });
|
|
202
|
-
const
|
|
239
|
+
const text = await response.text();
|
|
240
|
+
let body = null;
|
|
241
|
+
try { body = JSON.parse(text); } catch { body = null; }
|
|
203
242
|
if (!alive.current) return;
|
|
204
|
-
if (!response.ok || body.ok === false) {
|
|
205
|
-
setError(body?.message || `HTTP ${response.status}`);
|
|
243
|
+
if (!response.ok || body === null || body.ok === false) {
|
|
244
|
+
setError(body?.message || `HTTP ${response.status}${body === null && text ? `: ${text.slice(0, 80)}` : ''}`);
|
|
206
245
|
setData(null);
|
|
207
246
|
} else {
|
|
208
247
|
setError(null);
|
|
@@ -224,34 +263,74 @@ window.__ModuleLoader__.load({
|
|
|
224
263
|
};
|
|
225
264
|
}, []);
|
|
226
265
|
|
|
227
|
-
const
|
|
266
|
+
const units = data !== null && Array.isArray(data.units) && data.units.length > 0
|
|
267
|
+
? data.units
|
|
268
|
+
: data !== null
|
|
269
|
+
? [{
|
|
270
|
+
id: 'local',
|
|
271
|
+
title: translate('localUnit'),
|
|
272
|
+
remote: false,
|
|
273
|
+
gpus: data.gpus ?? [],
|
|
274
|
+
processes: data.processes ?? [],
|
|
275
|
+
}]
|
|
276
|
+
: [];
|
|
277
|
+
const multiUnit = units.length > 1;
|
|
278
|
+
const numberedUnits = units.map((unit, unitIdx) => ({ ...unit, unitIdx }));
|
|
279
|
+
const liveUnits = numberedUnits.filter((unit) => !unit.error);
|
|
280
|
+
const totalGpus = liveUnits.reduce((sum, unit) => sum + (unit.gpus?.length ?? 0), 0);
|
|
281
|
+
// One nvtop-style table across every unit; DEV is the unit index.
|
|
282
|
+
const mergedProcesses = liveUnits
|
|
283
|
+
.flatMap((unit) => (unit.processes ?? []).map((p) => ({ ...p, unitIdx: unit.unitIdx })));
|
|
228
284
|
return h('div', { className: 'nvtp-page' },
|
|
229
285
|
h('style', null, CSS),
|
|
230
286
|
h('h1', { className: 'nvtp-title' }, translate('panel')),
|
|
231
287
|
h('div', { className: 'nvtp-sub' },
|
|
232
288
|
data === null && error === null ? translate('stale')
|
|
233
|
-
:
|
|
234
|
-
?
|
|
289
|
+
: totalGpus > 0
|
|
290
|
+
? (multiUnit
|
|
291
|
+
? `${pluralize(translate('units'), translate('unitsOther'), units.length)} · `
|
|
292
|
+
: '')
|
|
293
|
+
+ pluralize(translate('gpus'), translate('gpusOther'), totalGpus)
|
|
235
294
|
: ''),
|
|
236
295
|
error !== null
|
|
237
296
|
? h('div', { className: 'nvtp-error' },
|
|
238
297
|
h('div', { className: 'nvtp-error-label' }, translate('unavailable')),
|
|
239
298
|
h('div', null, error))
|
|
240
299
|
: null,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
300
|
+
numberedUnits
|
|
301
|
+
.filter((unit) => unit.error)
|
|
302
|
+
.map((unit) => h('div', { key: unit.id, className: 'nvtp-error nvtp-unit-error' },
|
|
303
|
+
h('span', { className: 'nvtp-error-label' }, `Spark #${unit.unitIdx}`),
|
|
304
|
+
h('span', null, unit.error))),
|
|
305
|
+
numberedUnits
|
|
306
|
+
.filter((unit) => !unit.error && unit.note)
|
|
307
|
+
.map((unit) => h('div', { key: unit.id + ':note', className: 'nvtp-note nvtp-unit-error' },
|
|
308
|
+
h('span', { className: 'nvtp-note-label' }, `Spark #${unit.unitIdx}`),
|
|
309
|
+
h('span', null, unit.note))),
|
|
310
|
+
h('div', { className: 'nvtp-grid' },
|
|
311
|
+
liveUnits.flatMap((unit) => (unit.gpus ?? []).map((gpu) => h(GpuCard, {
|
|
312
|
+
key: unit.id + ':' + gpu.index,
|
|
313
|
+
gpu,
|
|
314
|
+
t: translate,
|
|
315
|
+
unitTitle: multiUnit
|
|
316
|
+
? `Spark #${unit.unitIdx} · ${unit.remote === true ? 'SSH' : unit.title}`
|
|
317
|
+
: null,
|
|
318
|
+
})))),
|
|
319
|
+
h('section', { className: 'nvtp-procs' },
|
|
320
|
+
h('h2', null, translate('processes')),
|
|
321
|
+
h(ProcessTable, {
|
|
322
|
+
processes: mergedProcesses,
|
|
323
|
+
t: translate,
|
|
324
|
+
multiUnit,
|
|
325
|
+
})));
|
|
250
326
|
}
|
|
251
327
|
|
|
252
|
-
function PanelIcon() {
|
|
328
|
+
function PanelIcon(props) {
|
|
253
329
|
return h('svg', {
|
|
254
|
-
viewBox: '0 0 24 24',
|
|
330
|
+
viewBox: '0 0 24 24',
|
|
331
|
+
width: props?.size ?? 18,
|
|
332
|
+
height: props?.size ?? 18,
|
|
333
|
+
'aria-hidden': true,
|
|
255
334
|
style: { display: 'block' },
|
|
256
335
|
},
|
|
257
336
|
h('rect', { x: 2.5, y: 5.5, width: 19, height: 12, rx: 2,
|
package/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { execFile } from 'node:child_process';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { hostname } from 'node:os';
|
|
2
4
|
import Schema from '@deepseek-ai/schemastery';
|
|
3
5
|
|
|
4
6
|
const inject = ['connection', 'webServer'];
|
|
@@ -7,6 +9,17 @@ const inject = ['connection', 'webServer'];
|
|
|
7
9
|
const Config = Schema.object({
|
|
8
10
|
intervalMs: Schema.number().step(1).min(500).max(60000).default(2000)
|
|
9
11
|
.description('Recommended client poll interval in milliseconds (500-60000, default 2000)'),
|
|
12
|
+
peers: Schema.array(Schema.object({
|
|
13
|
+
host: Schema.string().required()
|
|
14
|
+
.description('SSH host of the peer unit (another DGX Spark or GPU host)'),
|
|
15
|
+
user: Schema.string()
|
|
16
|
+
.description('SSH user (default: the user dsh runs as)'),
|
|
17
|
+
port: Schema.number().default(22)
|
|
18
|
+
.description('SSH port'),
|
|
19
|
+
title: Schema.string()
|
|
20
|
+
.description('Display name for this unit (default: host)'),
|
|
21
|
+
})).default([])
|
|
22
|
+
.description('Peer units sampled over SSH; requires key-based auth (BatchMode)'),
|
|
10
23
|
});
|
|
11
24
|
|
|
12
25
|
const QUERY_FIELDS = [
|
|
@@ -28,20 +41,42 @@ const APP_FIELDS = ['pid', 'gpu_uuid', 'used_memory', 'process_name'].join(',');
|
|
|
28
41
|
const CACHE_MS = 1000;
|
|
29
42
|
/** nvidia-smi hard timeout per invocation. */
|
|
30
43
|
const SMI_TIMEOUT_MS = 5000;
|
|
44
|
+
/** SSH timeout per peer invocation (connect + command). */
|
|
45
|
+
const SSH_TIMEOUT_MS = 8000;
|
|
46
|
+
|
|
47
|
+
/** Marker names delimiting sections of the one-shot remote probe script. */
|
|
48
|
+
const REMOTE_SECTIONS = ['HOST', 'SMI', 'APPS', 'MEM'];
|
|
49
|
+
|
|
50
|
+
const REMOTE_PROBE = [
|
|
51
|
+
"printf '__NVTP_HOST__\\n'; hostname 2>/dev/null || echo unknown",
|
|
52
|
+
`printf '__NVTP_SMI__\\n'; nvidia-smi --query-gpu=${QUERY_FIELDS} --format=csv,noheader,nounits 2>/dev/null`,
|
|
53
|
+
`printf '__NVTP_APPS__\\n'; nvidia-smi --query-compute-apps=${APP_FIELDS} --format=csv,noheader,nounits 2>/dev/null`,
|
|
54
|
+
"printf '__NVTP_MEM__\\n'; grep -E 'MemTotal|MemAvailable' /proc/meminfo 2>/dev/null",
|
|
55
|
+
].join('; ');
|
|
31
56
|
|
|
32
57
|
let cached;
|
|
33
58
|
let cachedAt = 0;
|
|
34
59
|
let sampling;
|
|
60
|
+
let peerConfig = [];
|
|
61
|
+
/** Peer refresh cadence; tracks the configured client interval. */
|
|
62
|
+
let pollBudgetMs = 2000;
|
|
35
63
|
|
|
36
|
-
function run(command, args) {
|
|
64
|
+
function run(command, args, timeout = SMI_TIMEOUT_MS) {
|
|
37
65
|
return new Promise((resolve, reject) => {
|
|
38
66
|
execFile(
|
|
39
67
|
command,
|
|
40
68
|
args,
|
|
41
|
-
{ timeout
|
|
42
|
-
(error, stdout) => {
|
|
43
|
-
if (error)
|
|
44
|
-
|
|
69
|
+
{ timeout, maxBuffer: 4 * 1024 * 1024 },
|
|
70
|
+
(error, stdout, stderr) => {
|
|
71
|
+
if (error) {
|
|
72
|
+
// Keep ssh's own diagnostics ("No route to host", "Permission denied")
|
|
73
|
+
// instead of the raw "Command failed: ssh -o ..." command line.
|
|
74
|
+
const detail = String(stderr ?? '').trim().split('\n').filter(Boolean).pop();
|
|
75
|
+
error.message = detail !== undefined && detail !== ''
|
|
76
|
+
? detail.slice(0, 120)
|
|
77
|
+
: String(error.message ?? error).slice(0, 120);
|
|
78
|
+
reject(error);
|
|
79
|
+
} else resolve(stdout);
|
|
45
80
|
},
|
|
46
81
|
);
|
|
47
82
|
});
|
|
@@ -51,6 +86,21 @@ function runSmi(args) {
|
|
|
51
86
|
return run('nvidia-smi', args);
|
|
52
87
|
}
|
|
53
88
|
|
|
89
|
+
/** One SSH command on a peer; key auth only (BatchMode never prompts). */
|
|
90
|
+
function sshRun(peer, script) {
|
|
91
|
+
const destination = peer.user !== undefined && peer.user !== null && peer.user !== ''
|
|
92
|
+
? `${peer.user}@${peer.host}`
|
|
93
|
+
: peer.host;
|
|
94
|
+
return run('ssh', [
|
|
95
|
+
'-o', 'BatchMode=yes',
|
|
96
|
+
'-o', 'ConnectTimeout=5',
|
|
97
|
+
'-o', 'StrictHostKeyChecking=accept-new',
|
|
98
|
+
'-p', String(peer.port ?? 22),
|
|
99
|
+
destination,
|
|
100
|
+
script,
|
|
101
|
+
], SSH_TIMEOUT_MS);
|
|
102
|
+
}
|
|
103
|
+
|
|
54
104
|
function splitCsv(line) {
|
|
55
105
|
const out = [];
|
|
56
106
|
let current = '';
|
|
@@ -77,41 +127,12 @@ function numeric(value) {
|
|
|
77
127
|
return Number.isFinite(n) ? n : null;
|
|
78
128
|
}
|
|
79
129
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const text = await run('ps', [
|
|
87
|
-
'-o', 'pid=,user=,%cpu=,rss=,args=',
|
|
88
|
-
'-p', unique.join(','),
|
|
89
|
-
]);
|
|
90
|
-
for (const line of text.split('\n')) {
|
|
91
|
-
if (line.trim() === '') continue;
|
|
92
|
-
const match = line.trim().match(/^(\d+)\s+(\S+)\s+([\d.]+)\s+(\d+)\s+(.*)$/);
|
|
93
|
-
if (match === null) continue;
|
|
94
|
-
details.set(Number(match[1]), {
|
|
95
|
-
user: match[2],
|
|
96
|
-
cpu: Number(match[3]),
|
|
97
|
-
rssKib: Number(match[4]),
|
|
98
|
-
command: match[5],
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
} catch {
|
|
102
|
-
// A process may exit between nvidia-smi and ps; leave its details absent.
|
|
103
|
-
}
|
|
104
|
-
return details;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
async function sample() {
|
|
108
|
-
const [gpuText, appText] = await Promise.all([
|
|
109
|
-
runSmi(['--query-gpu', QUERY_FIELDS, '--format=csv,noheader,nounits']),
|
|
110
|
-
runSmi(['--query-compute-apps', APP_FIELDS, '--format=csv,noheader,nounits'])
|
|
111
|
-
.catch(() => ''),
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
|
-
const gpus = gpuText
|
|
130
|
+
/**
|
|
131
|
+
* Parse `--query-gpu` CSV lines into raw GPU rows (no memory fallback yet).
|
|
132
|
+
* @internal exported for tests.
|
|
133
|
+
*/
|
|
134
|
+
function parseGpuCsv(text) {
|
|
135
|
+
return String(text ?? '')
|
|
115
136
|
.split('\n')
|
|
116
137
|
.map((line) => line.trim())
|
|
117
138
|
.filter((line) => line !== '')
|
|
@@ -130,10 +151,14 @@ async function sample() {
|
|
|
130
151
|
uuid: f[9] ?? '',
|
|
131
152
|
};
|
|
132
153
|
});
|
|
154
|
+
}
|
|
133
155
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
156
|
+
/**
|
|
157
|
+
* Parse `--query-compute-apps` CSV lines: pid, gpu uuid, MiB, process name.
|
|
158
|
+
* @internal exported for tests.
|
|
159
|
+
*/
|
|
160
|
+
function parseAppsCsv(text) {
|
|
161
|
+
return String(text ?? '')
|
|
137
162
|
.split('\n')
|
|
138
163
|
.map((line) => line.trim())
|
|
139
164
|
.filter((line) => line !== '')
|
|
@@ -141,16 +166,136 @@ async function sample() {
|
|
|
141
166
|
const f = splitCsv(line);
|
|
142
167
|
return {
|
|
143
168
|
pid: numeric(f[0]) ?? 0,
|
|
144
|
-
|
|
169
|
+
uuid: f[1] ?? '',
|
|
145
170
|
memoryUsed: numeric(f[2]),
|
|
146
171
|
name: f[3] ?? '',
|
|
147
172
|
};
|
|
148
173
|
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Parse MemTotal / MemAvailable from /proc/meminfo text.
|
|
178
|
+
* @internal exported for tests.
|
|
179
|
+
*/
|
|
180
|
+
function parseMeminfo(text) {
|
|
181
|
+
const out = { totalKib: null, availKib: null };
|
|
182
|
+
for (const line of String(text ?? '').split('\n')) {
|
|
183
|
+
let match = line.match(/^MemTotal:\s+(\d+)\s+kB/);
|
|
184
|
+
if (match !== null) out.totalKib = Number(match[1]);
|
|
185
|
+
match = line.match(/^MemAvailable:\s+(\d+)\s+kB/);
|
|
186
|
+
if (match !== null) out.availKib = Number(match[1]);
|
|
187
|
+
}
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Parse `ps -o pid=,user=,%cpu=,rss=,args=` output into a pid → details map. */
|
|
192
|
+
function parsePs(text) {
|
|
193
|
+
const details = new Map();
|
|
194
|
+
for (const line of String(text ?? '').split('\n')) {
|
|
195
|
+
if (line.trim() === '') continue;
|
|
196
|
+
const match = line.trim().match(/^(\d+)\s+(\S+)\s+([\d.]+)\s+(\d+)\s+(.*)$/);
|
|
197
|
+
if (match === null) continue;
|
|
198
|
+
details.set(Number(match[1]), {
|
|
199
|
+
user: match[2],
|
|
200
|
+
cpu: Number(match[3]),
|
|
201
|
+
rssKib: Number(match[4]),
|
|
202
|
+
command: match[5],
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return details;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** One `ps` call for every listed PID, executed through `execList` (local or ssh). */
|
|
209
|
+
async function processDetails(execList, pids) {
|
|
210
|
+
const unique = [...new Set(pids)].filter((pid) => Number.isInteger(pid) && pid > 0);
|
|
211
|
+
if (unique.length === 0) return new Map();
|
|
212
|
+
try {
|
|
213
|
+
const text = await execList(unique.join(','));
|
|
214
|
+
return parsePs(text);
|
|
215
|
+
} catch {
|
|
216
|
+
// A process may exit between nvidia-smi and ps; leave its details absent.
|
|
217
|
+
return new Map();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
149
220
|
|
|
150
|
-
|
|
221
|
+
const PS_ARGS = ['-o', 'pid=,user=,%cpu=,rss=,args='];
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Fold raw samples into one unit: GPU rows with unified-memory fallback and the
|
|
225
|
+
* nvtop-style process table.
|
|
226
|
+
*
|
|
227
|
+
* Unified memory (DGX Spark GB10): nvidia-smi reports memory.used/total as
|
|
228
|
+
* [N/A] because the GPU shares the LPDDR5X pool with the CPU. Following the
|
|
229
|
+
* sparkDash approach, `used` then comes from the compute-apps sum and `total`
|
|
230
|
+
* from the OS-visible pool (MemTotal), with MemAvailable as the free figure.
|
|
231
|
+
* @internal exported for tests.
|
|
232
|
+
*/
|
|
233
|
+
function assembleUnit({ title, remote, gpusRaw, apps, mem, psDetails }) {
|
|
234
|
+
const poolTotalMib = mem.totalKib !== null ? mem.totalKib / 1024 : null;
|
|
235
|
+
const poolAvailMib = mem.availKib !== null ? mem.availKib / 1024 : null;
|
|
236
|
+
|
|
237
|
+
const appsByUuid = new Map();
|
|
238
|
+
let appsSumAll = 0;
|
|
239
|
+
for (const app of apps) {
|
|
240
|
+
appsByUuid.set(app.uuid, (appsByUuid.get(app.uuid) ?? 0) + (app.memoryUsed ?? 0));
|
|
241
|
+
appsSumAll += app.memoryUsed ?? 0;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const deviceOfUuid = new Map();
|
|
245
|
+
|
|
246
|
+
const gpus = gpusRaw.map((gpu) => {
|
|
247
|
+
const isSparkChip = /GB10|DGX\s*Spark/i.test(gpu.name ?? '');
|
|
248
|
+
let memoryUsed = gpu.memoryUsed;
|
|
249
|
+
let memoryTotal = gpu.memoryTotal;
|
|
250
|
+
let unified = false;
|
|
251
|
+
let memoryAvailable = null;
|
|
252
|
+
|
|
253
|
+
// GB10: nvidia-smi memory figures are N/A (or a misleading partial number
|
|
254
|
+
// on some driver builds) — the OS pool is the honest denominator.
|
|
255
|
+
if (isSparkChip || memoryTotal === null || memoryUsed === null) {
|
|
256
|
+
if (poolTotalMib !== null && (isSparkChip || memoryTotal === null)) {
|
|
257
|
+
unified = true;
|
|
258
|
+
memoryTotal = poolTotalMib;
|
|
259
|
+
memoryAvailable = poolAvailMib;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// GPU-allocated share of the pool: compute-apps sum (per device when the
|
|
263
|
+
// uuid maps, whole-box sum on a single-GPU unit without uuid match).
|
|
264
|
+
// Spark chips always prefer the sum: some driver builds report a
|
|
265
|
+
// misleading partial number instead of [N/A].
|
|
266
|
+
{
|
|
267
|
+
const perDevice = gpu.uuid !== '' ? appsByUuid.get(gpu.uuid) : undefined;
|
|
268
|
+
const appsForGpu = perDevice !== undefined
|
|
269
|
+
? perDevice
|
|
270
|
+
: (gpusRaw.length === 1 ? appsSumAll : 0);
|
|
271
|
+
if (memoryUsed === null || memoryUsed === 0
|
|
272
|
+
|| (isSparkChip && appsForGpu > 0 && appsForGpu !== memoryUsed)) {
|
|
273
|
+
memoryUsed = appsForGpu;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (gpu.uuid !== '') deviceOfUuid.set(gpu.uuid, gpu.index);
|
|
277
|
+
return {
|
|
278
|
+
...gpu,
|
|
279
|
+
memoryUsed,
|
|
280
|
+
memoryTotal,
|
|
281
|
+
unified,
|
|
282
|
+
memoryAvailable,
|
|
283
|
+
};
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Re-map app→device with the final uuid table (single-GPU Spark with an
|
|
287
|
+
// unmatched uuid still lands on device 0).
|
|
288
|
+
const entries = apps.map((app) => ({
|
|
289
|
+
pid: app.pid,
|
|
290
|
+
uuid: app.uuid,
|
|
291
|
+
device: deviceOfUuid.get(app.uuid)
|
|
292
|
+
?? (gpus.length === 1 ? gpus[0].index : null),
|
|
293
|
+
memoryUsed: app.memoryUsed,
|
|
294
|
+
name: app.name,
|
|
295
|
+
}));
|
|
151
296
|
|
|
152
297
|
const processes = entries.map((entry) => {
|
|
153
|
-
const extra =
|
|
298
|
+
const extra = psDetails.get(entry.pid);
|
|
154
299
|
const device = gpus.find((gpu) => gpu.index === entry.device);
|
|
155
300
|
return {
|
|
156
301
|
pid: entry.pid,
|
|
@@ -166,7 +311,128 @@ async function sample() {
|
|
|
166
311
|
};
|
|
167
312
|
});
|
|
168
313
|
|
|
169
|
-
return {
|
|
314
|
+
return { title, remote, gpus, processes, hostMem: mem };
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async function sampleLocal() {
|
|
318
|
+
const [gpuText, appText, memText] = await Promise.all([
|
|
319
|
+
runSmi(['--query-gpu', QUERY_FIELDS, '--format=csv,noheader,nounits']),
|
|
320
|
+
runSmi(['--query-compute-apps', APP_FIELDS, '--format=csv,noheader,nounits'])
|
|
321
|
+
.catch(() => ''),
|
|
322
|
+
readFile('/proc/meminfo', 'utf8').catch(() => ''),
|
|
323
|
+
]);
|
|
324
|
+
const apps = parseAppsCsv(appText);
|
|
325
|
+
const psDetails = await processDetails(
|
|
326
|
+
(list) => run('ps', [...PS_ARGS, '-p', list]),
|
|
327
|
+
apps.map((app) => app.pid),
|
|
328
|
+
);
|
|
329
|
+
return assembleUnit({
|
|
330
|
+
title: hostname(),
|
|
331
|
+
remote: false,
|
|
332
|
+
gpusRaw: parseGpuCsv(gpuText),
|
|
333
|
+
apps,
|
|
334
|
+
mem: parseMeminfo(memText),
|
|
335
|
+
psDetails,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/** Split the one-shot remote probe output into its marked sections. */
|
|
340
|
+
function splitRemoteSections(text) {
|
|
341
|
+
const sections = {};
|
|
342
|
+
let current = null;
|
|
343
|
+
for (const line of String(text ?? '').split('\n')) {
|
|
344
|
+
const match = line.match(/^__NVTP_([A-Z]+)__$/);
|
|
345
|
+
if (match !== null && REMOTE_SECTIONS.includes(match[1])) {
|
|
346
|
+
current = match[1].toLowerCase();
|
|
347
|
+
sections[current] = [];
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (current !== null) sections[current].push(line);
|
|
351
|
+
}
|
|
352
|
+
for (const key of Object.keys(sections)) sections[key] = sections[key].join('\n');
|
|
353
|
+
return sections;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** Probe one peer over SSH; throws on failure (never returns an error unit). */
|
|
357
|
+
async function probePeer(peer) {
|
|
358
|
+
const probe = await sshRun(peer, REMOTE_PROBE);
|
|
359
|
+
const sections = splitRemoteSections(probe);
|
|
360
|
+
if (sections.smi === undefined) throw new Error('probe returned no markers');
|
|
361
|
+
const apps = parseAppsCsv(sections.apps ?? '');
|
|
362
|
+
const psDetails = await processDetails(
|
|
363
|
+
(list) => sshRun(peer, `ps ${PS_ARGS[0]} ${PS_ARGS[1]} -p ${list}`),
|
|
364
|
+
apps.map((app) => app.pid),
|
|
365
|
+
);
|
|
366
|
+
const unit = assembleUnit({
|
|
367
|
+
title: peer.title ?? ((sections.host ?? '').trim() || peer.host),
|
|
368
|
+
remote: true,
|
|
369
|
+
gpusRaw: parseGpuCsv(sections.smi ?? ''),
|
|
370
|
+
apps,
|
|
371
|
+
mem: parseMeminfo(sections.mem ?? ''),
|
|
372
|
+
psDetails,
|
|
373
|
+
});
|
|
374
|
+
const complete = { id: peer.host, configuredTitle: peer.title ?? peer.host, ...unit };
|
|
375
|
+
if (complete.gpus.length === 0) {
|
|
376
|
+
complete.note = `no NVIDIA GPU detected on ${peer.host}`;
|
|
377
|
+
}
|
|
378
|
+
return complete;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Peer units never block the API response: each peer refreshes in the
|
|
383
|
+
* background on its own schedule, and every request reads the latest snapshot.
|
|
384
|
+
* A failed peer retries at most once per PEER_RETRY_MS.
|
|
385
|
+
*/
|
|
386
|
+
const peerState = new Map();
|
|
387
|
+
const peerRefreshing = new Set();
|
|
388
|
+
const PEER_RETRY_MS = 10000;
|
|
389
|
+
|
|
390
|
+
function refreshPeer(peer) {
|
|
391
|
+
const now = Date.now();
|
|
392
|
+
const state = peerState.get(peer.host);
|
|
393
|
+
if (state !== undefined && now < state.nextAt) return;
|
|
394
|
+
if (peerRefreshing.has(peer.host)) return;
|
|
395
|
+
peerRefreshing.add(peer.host);
|
|
396
|
+
probePeer(peer)
|
|
397
|
+
.then((unit) => {
|
|
398
|
+
peerState.set(peer.host, { unit, error: null, at: Date.now(), nextAt: Date.now() + pollBudgetMs });
|
|
399
|
+
})
|
|
400
|
+
.catch((error) => {
|
|
401
|
+
peerState.set(peer.host, {
|
|
402
|
+
unit: null,
|
|
403
|
+
error: `SSH ${peer.host}: ${error?.message ?? String(error)}`,
|
|
404
|
+
at: Date.now(),
|
|
405
|
+
nextAt: Date.now() + PEER_RETRY_MS,
|
|
406
|
+
});
|
|
407
|
+
})
|
|
408
|
+
.finally(() => peerRefreshing.delete(peer.host));
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** Latest view of one peer: last-good data, the last error, or a connecting note. */
|
|
412
|
+
function peerSnapshot(peer) {
|
|
413
|
+
refreshPeer(peer);
|
|
414
|
+
const state = peerState.get(peer.host);
|
|
415
|
+
const fallbackTitle = peer.title ?? peer.host;
|
|
416
|
+
if (state === undefined) {
|
|
417
|
+
return { id: peer.host, title: fallbackTitle, remote: true, error: `SSH ${peer.host}: connecting…` };
|
|
418
|
+
}
|
|
419
|
+
if (state.error !== null) {
|
|
420
|
+
return { id: peer.host, title: fallbackTitle, remote: true, error: state.error };
|
|
421
|
+
}
|
|
422
|
+
return state.unit;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
async function sample() {
|
|
426
|
+
const local = await sampleLocal();
|
|
427
|
+
const units = [{ id: 'local', ...local }, ...peerConfig.map((peer) => peerSnapshot(peer))];
|
|
428
|
+
return {
|
|
429
|
+
ok: true,
|
|
430
|
+
sampledAt: Date.now(),
|
|
431
|
+
units,
|
|
432
|
+
// Backwards-compatible top-level view of the local unit.
|
|
433
|
+
gpus: local.gpus,
|
|
434
|
+
processes: local.processes,
|
|
435
|
+
};
|
|
170
436
|
}
|
|
171
437
|
|
|
172
438
|
function jsonResponse(body) {
|
|
@@ -209,6 +475,13 @@ async function fetchStats() {
|
|
|
209
475
|
*/
|
|
210
476
|
function apply(ctx, config) {
|
|
211
477
|
const intervalMs = config?.intervalMs ?? 2000;
|
|
478
|
+
peerConfig = Array.isArray(config?.peers) ? config.peers : [];
|
|
479
|
+
pollBudgetMs = Math.max(1000, intervalMs);
|
|
480
|
+
// Drop cached state for peers that are no longer configured.
|
|
481
|
+
const configuredHosts = new Set(peerConfig.map((peer) => peer.host));
|
|
482
|
+
for (const host of peerState.keys()) {
|
|
483
|
+
if (!configuredHosts.has(host)) peerState.delete(host);
|
|
484
|
+
}
|
|
212
485
|
const dispose = ctx.connection.registerFetchRoute(ctx, {
|
|
213
486
|
path: '/api/nvtop',
|
|
214
487
|
methods: ['GET'],
|
|
@@ -230,4 +503,14 @@ function apply(ctx, config) {
|
|
|
230
503
|
ctx.effect(() => dispose, 'dsh-nvtop: /api/nvtop stats route');
|
|
231
504
|
}
|
|
232
505
|
|
|
233
|
-
export {
|
|
506
|
+
export {
|
|
507
|
+
Config,
|
|
508
|
+
apply,
|
|
509
|
+
inject,
|
|
510
|
+
// @internal test hooks
|
|
511
|
+
parseGpuCsv,
|
|
512
|
+
parseAppsCsv,
|
|
513
|
+
parseMeminfo,
|
|
514
|
+
assembleUnit,
|
|
515
|
+
splitRemoteSections,
|
|
516
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-nvtop-panel",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "nvtop-style live GPU dashboard panel for the DeepSeek Harness (DSH) Web UI: per-GPU utilization/memory/temperature/power cards plus a full nvtop-like process table (PID, USER, DEV, TYPE, GPU, GPU MEM, CPU, HOST MEM, Command).",
|
|
6
|
+
"description": "nvtop-style live GPU dashboard panel for the DeepSeek Harness (DSH) Web UI: per-GPU utilization/memory/temperature/power cards plus a full nvtop-like process table (PID, USER, DEV, TYPE, GPU, GPU MEM, CPU, HOST MEM, Command). DGX Spark (GB10) unified memory supported; daisy-chained units monitored over SSH.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@deepseek-ai/schemastery": "^3.19.0"
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
35
|
"dsh": {
|
|
36
|
-
"bundle": {
|
|
36
|
+
"bundle": {
|
|
37
|
+
"patch": "./cordis.patch.yml"
|
|
38
|
+
},
|
|
37
39
|
"client": {
|
|
38
40
|
"platform": "web",
|
|
39
41
|
"immediately": true,
|