pyre-cli 4.12.0 → 4.14.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/README.md +2 -6
- package/dist/index.js +5 -6
- package/package.json +1 -1
- package/src/monitors/collectors.ts +17 -18
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ Mac system monitoring CLI: temps, CPU, memory, disk, battery, live dashboard, pa
|
|
|
7
7
|

|
|
8
8
|

|
|
9
9
|
|
|
10
|
+
> Note : things may not work as intended if your firewall settings do not allow inbound connections for this program
|
|
11
|
+
|
|
10
12
|
## Features
|
|
11
13
|
|
|
12
14
|
- **P2P live data streaming** — send live system stats to another system over TCP with password authentication, TLS encryption, rate limiting, IP allow/deny lists, audit logging, and HMAC message signing
|
|
@@ -38,12 +40,6 @@ npm install -g pyre-cli
|
|
|
38
40
|
curl -fsSL https://raw.githubusercontent.com/somalip/pyre/main/install.sh | bash
|
|
39
41
|
```
|
|
40
42
|
|
|
41
|
-
### Homebrew
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
brew install pyre
|
|
45
|
-
```
|
|
46
|
-
|
|
47
43
|
## Usage
|
|
48
44
|
|
|
49
45
|
### Static snapshot
|
package/dist/index.js
CHANGED
|
@@ -504,15 +504,14 @@ async function collectProcesses(limit) {
|
|
|
504
504
|
try {
|
|
505
505
|
const isMac = process.platform === "darwin";
|
|
506
506
|
const sortArg = isMac ? "-r" : "--sort=-pcpu";
|
|
507
|
-
const threadsArg = isMac ? "threads" : "nlwp";
|
|
508
507
|
const headClause = limit && limit > 0 ? ` | head -n ${limit + 1}` : "";
|
|
509
|
-
const raw = (await run(`ps -eo pid,ppid,user,pcpu,pmem,state
|
|
508
|
+
const raw = (await run(`ps -eo pid,ppid,user,pcpu,pmem,state,time,comm ${sortArg}${headClause}`)).trim();
|
|
510
509
|
const lines = raw.split("\n").slice(1);
|
|
511
510
|
return lines.map((line) => {
|
|
512
|
-
const parts = line.match(/\s*(\d+)\s+(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+(
|
|
511
|
+
const parts = line.match(/\s*(\d+)\s+(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+([\d:.]+)\s+(.+)/);
|
|
513
512
|
if (!parts) return null;
|
|
514
|
-
const runtimeSec = parts[
|
|
515
|
-
return { pid: parseInt(parts[1]), ppid: parseInt(parts[2]), user: parts[3], cpu: parseFloat(parts[4]), mem: parseFloat(parts[5]), state: parts[6], threads:
|
|
513
|
+
const runtimeSec = parts[7].split(":").reduce((acc, val, idx) => acc + parseInt(val) * Math.pow(60, 2 - idx), 0);
|
|
514
|
+
return { pid: parseInt(parts[1]), ppid: parseInt(parts[2]), user: parts[3], cpu: parseFloat(parts[4]), mem: parseFloat(parts[5]), state: parts[6], threads: 0, runtime: runtimeSec, command: parts[8] };
|
|
516
515
|
}).filter((p) => p !== null && p.pid > 0);
|
|
517
516
|
} catch {
|
|
518
517
|
return [];
|
|
@@ -590,7 +589,7 @@ async function collectTasks(limit = 12) {
|
|
|
590
589
|
const raw = (await run(`ps -eo pid,user,pcpu,pmem,state,time,comm ${sortArg} | head -n ${limit + 1}`)).trim();
|
|
591
590
|
const lines = raw.split("\n").slice(1);
|
|
592
591
|
return lines.map((line) => {
|
|
593
|
-
const parts = line.match(/\s*(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+([\d
|
|
592
|
+
const parts = line.match(/\s*(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+([\d:.]+)\s+(.+)/);
|
|
594
593
|
if (!parts) return null;
|
|
595
594
|
const runtimeSec = parts[6].split(":").reduce((acc, val, idx) => acc + parseInt(val) * Math.pow(60, 2 - idx), 0);
|
|
596
595
|
return { pid: parseInt(parts[1]), user: parts[2], cpu: parseFloat(parts[3]), mem: parseFloat(parts[4]), state: parts[5], runtime: runtimeSec, command: parts[7] };
|
package/package.json
CHANGED
|
@@ -606,20 +606,19 @@ export async function collectNetwork(): Promise<NetworkData> {
|
|
|
606
606
|
|
|
607
607
|
export async function collectProcesses(limit?: number): Promise<ProcessData[]> {
|
|
608
608
|
try {
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
.filter((p): p is ProcessData => p !== null && p.pid > 0);
|
|
609
|
+
const isMac = process.platform === 'darwin';
|
|
610
|
+
const sortArg = isMac ? '-r' : '--sort=-pcpu';
|
|
611
|
+
const headClause = limit && limit > 0 ? ` | head -n ${limit + 1}` : '';
|
|
612
|
+
const raw = (await run(`ps -eo pid,ppid,user,pcpu,pmem,state,time,comm ${sortArg}${headClause}`)).trim();
|
|
613
|
+
const lines = raw.split('\n').slice(1);
|
|
614
|
+
return lines
|
|
615
|
+
.map(line => {
|
|
616
|
+
const parts = line.match(/\s*(\d+)\s+(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+([\d:.]+)\s+(.+)/);
|
|
617
|
+
if (!parts) return null;
|
|
618
|
+
const runtimeSec = parts[7].split(':').reduce((acc, val, idx) => acc + parseInt(val) * Math.pow(60, 2 - idx), 0);
|
|
619
|
+
return { pid: parseInt(parts[1]), ppid: parseInt(parts[2]), user: parts[3], cpu: parseFloat(parts[4]), mem: parseFloat(parts[5]), state: parts[6], threads: 0, runtime: runtimeSec, command: parts[8] };
|
|
620
|
+
})
|
|
621
|
+
.filter((p): p is ProcessData => p !== null && p.pid > 0);
|
|
623
622
|
} catch {
|
|
624
623
|
return [];
|
|
625
624
|
}
|
|
@@ -704,10 +703,10 @@ export async function collectTasks(limit = 12): Promise<TaskData[]> {
|
|
|
704
703
|
const lines = raw.split('\n').slice(1);
|
|
705
704
|
return lines
|
|
706
705
|
.map(line => {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
706
|
+
const parts = line.match(/\s*(\d+)\s+(\S+)\s+([\d.]+)\s+([\d.]+)\s+(\S+)\s+([\d:.]+)\s+(.+)/);
|
|
707
|
+
if (!parts) return null;
|
|
708
|
+
const runtimeSec = parts[6].split(':').reduce((acc, val, idx) => acc + parseInt(val) * Math.pow(60, 2 - idx), 0);
|
|
709
|
+
return { pid: parseInt(parts[1]), user: parts[2], cpu: parseFloat(parts[3]), mem: parseFloat(parts[4]), state: parts[5], runtime: runtimeSec, command: parts[7] };
|
|
711
710
|
})
|
|
712
711
|
.filter((t): t is TaskData => t !== null && t.pid > 0);
|
|
713
712
|
} catch {
|