pyre-cli 8.2.0 → 9.1.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/dist/{anomaliesCmd-TO52YY2B.js → anomaliesCmd-25OFKYPK.js} +1 -1
- package/dist/{brewHealth-6NE37NAU.js → brewHealth-F2BXF5M6.js} +1 -1
- package/dist/{chunk-GLH7EKAX.js → chunk-FH5WDJBF.js} +1 -1
- package/dist/{chunk-KBKXU2ZV.js → chunk-QOLZ7T32.js} +35 -19
- package/dist/{collectors-4VYRJVRO.js → collectors-VACLPHRP.js} +2 -2
- package/dist/{doctor-LJQAABZ4.js → doctor-L6FZYA7F.js} +1 -1
- package/dist/{extensions-QCFSVCL5.js → extensions-DVA5YLGH.js} +1 -1
- package/dist/index.js +435 -92
- package/package.json +1 -1
- package/src/anomaliesCmd.ts +1 -1
- package/src/formatters/render.ts +127 -38
- package/src/formatters/types.ts +6 -0
- package/src/live/input.ts +149 -5
- package/src/live/render.ts +161 -11
- package/src/live/state.ts +7 -0
- package/src/live/types.ts +1 -1
- package/src/monitors/collectors.ts +33 -14
- package/src/monitors/run.ts +1 -1
- package/src/monitors/smc.ts +6 -9
- package/src/splash.ts +1 -1
|
@@ -13,7 +13,7 @@ function runAnomaliesDigest(opts = {}) {
|
|
|
13
13
|
console.log(chalk.dim(" Enable background logging with `pyre --log` to record history.\n"));
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
const files = fs.readdirSync(dir).filter((f) => f.startsWith("pyre-
|
|
16
|
+
const files = fs.readdirSync(dir).filter((f) => f.startsWith("pyre-") && f.endsWith(".csv"));
|
|
17
17
|
if (files.length === 0) {
|
|
18
18
|
console.log(chalk.yellow(` No CSV logs found for range '${sinceStr}' in ${dir}.`));
|
|
19
19
|
console.log(chalk.dim(" Enable background logging with `pyre --log` to record history.\n"));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { exec } from "child_process";
|
|
3
3
|
import { promisify } from "util";
|
|
4
4
|
var execAsync = promisify(exec);
|
|
5
|
-
async function run(cmd, fallback = "", timeout =
|
|
5
|
+
async function run(cmd, fallback = "", timeout = 3e3) {
|
|
6
6
|
try {
|
|
7
7
|
return (await execAsync(cmd, { encoding: "utf8", timeout })).stdout.trim();
|
|
8
8
|
} catch {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
run
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-FH5WDJBF.js";
|
|
4
4
|
|
|
5
5
|
// src/monitors/collectors.ts
|
|
6
6
|
import chalk from "chalk";
|
|
@@ -15,7 +15,8 @@ async function getSmcMetrics() {
|
|
|
15
15
|
try {
|
|
16
16
|
const pm = (await run(
|
|
17
17
|
"sudo -n powermetrics --samplers smc,cpu_power -n 1 --format text 2>/dev/null",
|
|
18
|
-
""
|
|
18
|
+
"",
|
|
19
|
+
2e3
|
|
19
20
|
)).trim();
|
|
20
21
|
if (pm) {
|
|
21
22
|
const cpuTemp = pm.match(/CPU die temperature:\s*([\d.]+)/i);
|
|
@@ -71,13 +72,9 @@ async function getSmcMetrics() {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
if (result.temps["cpu_die"] === void 0) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const m = top.match(/CPU usage:\s*[\d.]+\%\s*user,\s*[\d.]+\%\s*sys,\s*([\d.]+)\%\s*idle/);
|
|
78
|
-
if (m) loadUsage = Math.max(0, 100 - parseFloat(m[1]));
|
|
79
|
-
} catch {
|
|
80
|
-
}
|
|
75
|
+
const loadAvg = (await import("os")).loadavg();
|
|
76
|
+
const ncpus = (await import("os")).cpus().length || 1;
|
|
77
|
+
const loadUsage = Math.min(100, loadAvg[0] / ncpus * 100);
|
|
81
78
|
const estCpu = Math.round((38 + loadUsage * 0.42) * 10) / 10;
|
|
82
79
|
result.temps["cpu_die"] = estCpu;
|
|
83
80
|
if (result.temps["gpu_die"] === void 0) {
|
|
@@ -98,6 +95,7 @@ function parseSuffix(s) {
|
|
|
98
95
|
var SP_TTL_MS = 1e4;
|
|
99
96
|
var NETSTAT_TTL_MS = 1e3;
|
|
100
97
|
var prevCpuTimes = null;
|
|
98
|
+
var prevCpuTotal = { total: 0, idle: 0, ts: 0 };
|
|
101
99
|
var ROUTE_TTL_MS = 5e3;
|
|
102
100
|
var SYSCTL_TTL_MS = 6e4;
|
|
103
101
|
var spGpuCache = null;
|
|
@@ -239,7 +237,7 @@ async function collectGpu(detailed) {
|
|
|
239
237
|
if (spGpuCache && now - spGpuCache.ts < SP_TTL_MS) {
|
|
240
238
|
spRaw = spGpuCache.raw;
|
|
241
239
|
} else {
|
|
242
|
-
spRaw = (await run("system_profiler SPDisplaysDataType 2>/dev/null")).trim();
|
|
240
|
+
spRaw = (await run("system_profiler SPDisplaysDataType 2>/dev/null", "", 3e3)).trim();
|
|
243
241
|
spGpuCache = { raw: spRaw, ts: now };
|
|
244
242
|
}
|
|
245
243
|
let model = "Unknown";
|
|
@@ -374,14 +372,32 @@ async function collectCpu() {
|
|
|
374
372
|
} catch {
|
|
375
373
|
}
|
|
376
374
|
}
|
|
375
|
+
if (frequency === 0) {
|
|
376
|
+
try {
|
|
377
|
+
const cpus = os.cpus();
|
|
378
|
+
if (cpus && cpus.length > 0 && cpus[0].speed) {
|
|
379
|
+
frequency = cpus[0].speed;
|
|
380
|
+
}
|
|
381
|
+
} catch {
|
|
382
|
+
}
|
|
383
|
+
}
|
|
377
384
|
let usage = 0;
|
|
378
385
|
try {
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
386
|
+
const cpus = os.cpus();
|
|
387
|
+
let totalNow = 0;
|
|
388
|
+
let idleNow = 0;
|
|
389
|
+
for (const cpu of cpus) {
|
|
390
|
+
totalNow += cpu.times.user + cpu.times.nice + cpu.times.sys + cpu.times.idle + cpu.times.irq;
|
|
391
|
+
idleNow += cpu.times.idle;
|
|
392
|
+
}
|
|
393
|
+
if (prevCpuTotal.ts > 0) {
|
|
394
|
+
const totalDelta = totalNow - prevCpuTotal.total;
|
|
395
|
+
const idleDelta = idleNow - prevCpuTotal.idle;
|
|
396
|
+
if (totalDelta > 0) {
|
|
397
|
+
usage = Math.round((totalDelta - idleDelta) / totalDelta * 100);
|
|
398
|
+
}
|
|
384
399
|
}
|
|
400
|
+
prevCpuTotal = { total: totalNow, idle: idleNow, ts: Date.now() };
|
|
385
401
|
} catch {
|
|
386
402
|
}
|
|
387
403
|
const loadAvgStr = (await run("sysctl -n vm.loadavg", "0.00 0.00 0.00")).trim();
|
|
@@ -485,7 +501,7 @@ async function getDiskIoRates() {
|
|
|
485
501
|
return { readBytesSec: cachedDiskIo.readBytesSec, writeBytesSec: cachedDiskIo.writeBytesSec };
|
|
486
502
|
}
|
|
487
503
|
try {
|
|
488
|
-
const raw = (await run("iostat -d -c 2 1 2", "")).trim();
|
|
504
|
+
const raw = (await run("iostat -d -c 2 1 2", "", 3e3)).trim();
|
|
489
505
|
const blocks = raw.split(/\n\s*\n/).filter(Boolean);
|
|
490
506
|
const targetBlock = blocks.length > 1 ? blocks[1] : blocks[0];
|
|
491
507
|
if (targetBlock) {
|
|
@@ -547,7 +563,7 @@ async function collectBattery() {
|
|
|
547
563
|
if (spBatteryCache && now - spBatteryCache.ts < SP_TTL_MS) {
|
|
548
564
|
battInfo = spBatteryCache.raw;
|
|
549
565
|
} else {
|
|
550
|
-
battInfo = (await run("system_profiler SPPowerDataType 2>/dev/null")).trim();
|
|
566
|
+
battInfo = (await run("system_profiler SPPowerDataType 2>/dev/null", "", 3e3)).trim();
|
|
551
567
|
spBatteryCache = { raw: battInfo, ts: now };
|
|
552
568
|
}
|
|
553
569
|
const cycleMatch = battInfo.match(/Cycle Count:\s+(\d+)/);
|
|
@@ -723,7 +739,7 @@ async function collectPackets() {
|
|
|
723
739
|
}
|
|
724
740
|
let connections = 0;
|
|
725
741
|
try {
|
|
726
|
-
const tcpConns = (await run("netstat -an | grep ESTABLISHED | wc -l", "0")).trim();
|
|
742
|
+
const tcpConns = (await run("netstat -an | grep ESTABLISHED | wc -l", "0", 2e3)).trim();
|
|
727
743
|
connections = parseInt(tcpConns) || 0;
|
|
728
744
|
} catch {
|
|
729
745
|
connections = 0;
|
|
@@ -731,7 +747,7 @@ async function collectPackets() {
|
|
|
731
747
|
let topProcesses = [];
|
|
732
748
|
let allProcesses = [];
|
|
733
749
|
try {
|
|
734
|
-
const lsof = (await run("lsof -i -n -P 2>/dev/null | tail -n +2 | awk '{print $1, $2}' | sort | uniq -c | sort -rn", "")).trim();
|
|
750
|
+
const lsof = (await run("lsof -i -n -P 2>/dev/null | tail -n +2 | awk '{print $1, $2}' | sort | uniq -c | sort -rn", "", 2e3)).trim();
|
|
735
751
|
const lsofLines = lsof.split("\n");
|
|
736
752
|
topProcesses = lsofLines.map((line) => {
|
|
737
753
|
const parts = line.trim().split(/\s+/);
|