dsh-ensp 0.2.0 → 0.2.1
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/package.json +1 -1
- package/src/core/doctor.mjs +33 -14
package/package.json
CHANGED
package/src/core/doctor.mjs
CHANGED
|
@@ -109,20 +109,32 @@ export function probeInputInjection({ timeoutMs = 30000 } = {}) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
/**
|
|
112
|
+
/**
|
|
113
|
+
* Free physical memory in MB, or null when it cannot be read.
|
|
114
|
+
*
|
|
115
|
+
* On Windows Win32_OperatingSystem is the accurate number, but it needs
|
|
116
|
+
* PowerShell. Everything else (and any Windows box where PowerShell is not on
|
|
117
|
+
* PATH) falls back to os.freemem(), so the check still says something useful
|
|
118
|
+
* instead of giving up on the platform it happens to run on.
|
|
119
|
+
*/
|
|
113
120
|
export function freeMemoryMb() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
if (process.platform === 'win32') {
|
|
122
|
+
const r = spawnSync(
|
|
123
|
+
'powershell',
|
|
124
|
+
[
|
|
125
|
+
'-NoProfile',
|
|
126
|
+
'-Command',
|
|
127
|
+
"Get-CimInstance Win32_OperatingSystem | ForEach-Object { [int]($_.FreePhysicalMemory / 1024) }",
|
|
128
|
+
],
|
|
129
|
+
{ encoding: 'utf8', windowsHide: true, timeout: 20000 },
|
|
130
|
+
)
|
|
131
|
+
if (r.status === 0) {
|
|
132
|
+
const n = Number((r.stdout || '').trim())
|
|
133
|
+
if (Number.isFinite(n) && n > 0) return n
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const fallback = Math.floor(os.freemem() / (1024 * 1024))
|
|
137
|
+
return Number.isFinite(fallback) && fallback > 0 ? fallback : null
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
/** Ports in eNSP's console range that are already listening. */
|
|
@@ -244,7 +256,14 @@ export function doctor(options = {}) {
|
|
|
244
256
|
// 6. Memory headroom: each AR_Base needs 256 MB, WLAN images 530-650 MB
|
|
245
257
|
const free = freeMemoryMb()
|
|
246
258
|
if (free === null) {
|
|
247
|
-
checks.push(
|
|
259
|
+
checks.push(
|
|
260
|
+
check(
|
|
261
|
+
'memory',
|
|
262
|
+
'warn',
|
|
263
|
+
'could not read free physical memory',
|
|
264
|
+
'Check free memory yourself (Task Manager on Windows) and keep at least 1 GB spare; a device needs ~256 MB to boot.',
|
|
265
|
+
),
|
|
266
|
+
)
|
|
248
267
|
} else {
|
|
249
268
|
const okMem = free >= MIN_FREE_MEMORY_MB
|
|
250
269
|
checks.push(
|