home-hosted 0.7.13 → 0.7.14
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/dist/cli.js +29 -2
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/uis/stock/dist/ui.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14103,9 +14103,34 @@ var init_control_server = __esmMin((() => {
|
|
|
14103
14103
|
}));
|
|
14104
14104
|
//#endregion
|
|
14105
14105
|
//#region src/providers/host.ts
|
|
14106
|
+
/**
|
|
14107
|
+
* Whether a cached reading may be reused.
|
|
14108
|
+
*
|
|
14109
|
+
* Separate from the reading itself so the rule can be tested anywhere — the read is
|
|
14110
|
+
* `sysctl`/PowerShell, which no CI runner but macOS and Windows can perform, and a bug here
|
|
14111
|
+
* would be one that only shows up as either a stale alert or a spawn storm.
|
|
14112
|
+
*
|
|
14113
|
+
* A stamp in the future (a backwards wall-clock step) counts as stale: with a plain
|
|
14114
|
+
* `now - at < ttl` it computes a negative age, which is "fresh", and the reading would stick
|
|
14115
|
+
* until wall time caught back up — potentially hours after an NTP correction.
|
|
14116
|
+
*/
|
|
14117
|
+
function isSwapCacheFresh(cache, now, ttlMs = SWAP_CACHE_MS) {
|
|
14118
|
+
if (cache === null) return false;
|
|
14119
|
+
const age = now - cache.at;
|
|
14120
|
+
return age >= 0 && age < ttlMs;
|
|
14121
|
+
}
|
|
14106
14122
|
/** Swap usage per platform: /proc on Linux, sysctl on macOS, CIM on Windows. */
|
|
14107
|
-
async function swapUsedPercent() {
|
|
14123
|
+
async function swapUsedPercent(now = Date.now()) {
|
|
14108
14124
|
if (process.platform === "linux") return 0;
|
|
14125
|
+
if (isSwapCacheFresh(swapCache, now)) return swapCache.percent;
|
|
14126
|
+
const percent = await readSwapUsedPercent();
|
|
14127
|
+
swapCache = {
|
|
14128
|
+
at: now,
|
|
14129
|
+
percent
|
|
14130
|
+
};
|
|
14131
|
+
return percent;
|
|
14132
|
+
}
|
|
14133
|
+
async function readSwapUsedPercent() {
|
|
14109
14134
|
if (process.platform === "darwin") try {
|
|
14110
14135
|
const { stdout } = await execFileAsync("sysctl", ["-n", "vm.swapusage"], { timeout: 3e3 });
|
|
14111
14136
|
const total = /total\s*=\s*([\d.]+)M/.exec(stdout)?.[1];
|
|
@@ -14325,9 +14350,11 @@ function emptyHostView(config) {
|
|
|
14325
14350
|
sampledAt: null
|
|
14326
14351
|
};
|
|
14327
14352
|
}
|
|
14328
|
-
var execFileAsync;
|
|
14353
|
+
var execFileAsync, SWAP_CACHE_MS, swapCache;
|
|
14329
14354
|
var init_host = __esmMin((() => {
|
|
14330
14355
|
execFileAsync = promisify(execFile);
|
|
14356
|
+
SWAP_CACHE_MS = 6e4;
|
|
14357
|
+
swapCache = null;
|
|
14331
14358
|
}));
|
|
14332
14359
|
//#endregion
|
|
14333
14360
|
//#region src/services/host-monitor.ts
|