@aidalinfo/aegis-agent 0.2.1 → 0.2.2
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/bin.js +15 -1
- package/dist/index.js +15 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -198,7 +198,15 @@ function diskIoRates(prev3, cur, dtSec) {
|
|
|
198
198
|
var prev = null;
|
|
199
199
|
async function collectCpu() {
|
|
200
200
|
const cur = parseProcStat(await readProc("stat"));
|
|
201
|
-
|
|
201
|
+
if (!prev) {
|
|
202
|
+
prev = cur;
|
|
203
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
204
|
+
const warm = parseProcStat(await readProc("stat"));
|
|
205
|
+
const usagePercent2 = cpuPercent(prev, warm);
|
|
206
|
+
prev = warm;
|
|
207
|
+
return { usagePercent: usagePercent2 };
|
|
208
|
+
}
|
|
209
|
+
const usagePercent = cpuPercent(prev, cur);
|
|
202
210
|
prev = cur;
|
|
203
211
|
return { usagePercent };
|
|
204
212
|
}
|
|
@@ -281,7 +289,13 @@ async function collectSwap() {
|
|
|
281
289
|
|
|
282
290
|
// src/metrics/processes.ts
|
|
283
291
|
import si from "systeminformation";
|
|
292
|
+
var initialized = false;
|
|
284
293
|
async function collectProcesses() {
|
|
294
|
+
if (!initialized) {
|
|
295
|
+
await si.processes();
|
|
296
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
297
|
+
initialized = true;
|
|
298
|
+
}
|
|
285
299
|
const { list } = await si.processes();
|
|
286
300
|
return list.sort((a, b) => b.cpu - a.cpu).slice(0, 5).map((p) => ({
|
|
287
301
|
pid: p.pid,
|
package/dist/index.js
CHANGED
|
@@ -154,7 +154,15 @@ function diskIoRates(prev3, cur, dtSec) {
|
|
|
154
154
|
var prev = null;
|
|
155
155
|
async function collectCpu() {
|
|
156
156
|
const cur = parseProcStat(await readProc("stat"));
|
|
157
|
-
|
|
157
|
+
if (!prev) {
|
|
158
|
+
prev = cur;
|
|
159
|
+
await new Promise((r) => setTimeout(r, 300));
|
|
160
|
+
const warm = parseProcStat(await readProc("stat"));
|
|
161
|
+
const usagePercent2 = cpuPercent(prev, warm);
|
|
162
|
+
prev = warm;
|
|
163
|
+
return { usagePercent: usagePercent2 };
|
|
164
|
+
}
|
|
165
|
+
const usagePercent = cpuPercent(prev, cur);
|
|
158
166
|
prev = cur;
|
|
159
167
|
return { usagePercent };
|
|
160
168
|
}
|
|
@@ -237,7 +245,13 @@ async function collectSwap() {
|
|
|
237
245
|
|
|
238
246
|
// src/metrics/processes.ts
|
|
239
247
|
import si from "systeminformation";
|
|
248
|
+
var initialized = false;
|
|
240
249
|
async function collectProcesses() {
|
|
250
|
+
if (!initialized) {
|
|
251
|
+
await si.processes();
|
|
252
|
+
await new Promise((r) => setTimeout(r, 500));
|
|
253
|
+
initialized = true;
|
|
254
|
+
}
|
|
241
255
|
const { list } = await si.processes();
|
|
242
256
|
return list.sort((a, b) => b.cpu - a.cpu).slice(0, 5).map((p) => ({
|
|
243
257
|
pid: p.pid,
|