@daemonitor/plugins 1.1.50 → 1.1.51
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.
|
@@ -125,6 +125,34 @@ function availableMem() {
|
|
|
125
125
|
}
|
|
126
126
|
return freemem();
|
|
127
127
|
}
|
|
128
|
+
// Swap and page cache, in bytes. Swap in use on a box that still has RAM
|
|
129
|
+
// available is old pages pushed out, not pressure, so the card shows both.
|
|
130
|
+
// Linux reads /proc/meminfo; macOS has swap only (sysctl vm.swapusage).
|
|
131
|
+
function memDetail() {
|
|
132
|
+
if (platform() === "linux") {
|
|
133
|
+
try {
|
|
134
|
+
const info = readFileSync("/proc/meminfo", "utf8");
|
|
135
|
+
const kb = (key) => parseInt(info.match(new RegExp(`^${key}:\\s+(\\d+)\\s*kB`, "m"))?.[1] || "0", 10) * 1024;
|
|
136
|
+
const swapTotal = kb("SwapTotal");
|
|
137
|
+
return { swapTotal, swapUsed: swapTotal - kb("SwapFree"), cached: kb("Cached") + kb("Buffers") };
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (platform() === "darwin") {
|
|
144
|
+
try {
|
|
145
|
+
// "total = 2048.00M used = 1024.50M free = 1023.50M (encrypted)"
|
|
146
|
+
const out = execSync("sysctl -n vm.swapusage", { encoding: "utf8", timeout: 4000 });
|
|
147
|
+
const mb = (key) => parseFloat(out.match(new RegExp(`${key} = ([\\d.]+)M`))?.[1] || "0") * 1024 * 1024;
|
|
148
|
+
return { swapTotal: Math.round(mb("total")), swapUsed: Math.round(mb("used")) };
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return undefined;
|
|
155
|
+
}
|
|
128
156
|
// Cumulative rx/tx byte counters summed across real interfaces (Linux
|
|
129
157
|
// /proc/net/dev). Loopback and virtual bridges (docker/veth/lxc/br-) are skipped
|
|
130
158
|
// so the figure reflects actual host network traffic, not container-to-host
|
|
@@ -220,6 +248,7 @@ export function createOSPlugin() {
|
|
|
220
248
|
totalmem: totalmem(),
|
|
221
249
|
freemem: freemem(),
|
|
222
250
|
available: availableMem(),
|
|
251
|
+
memory: memDetail(),
|
|
223
252
|
disks: collectDisks(),
|
|
224
253
|
processes: collectProcesses(),
|
|
225
254
|
network,
|