querysub 0.305.0 → 0.307.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/package.json
CHANGED
|
@@ -68,7 +68,7 @@ export class MachineDetailPage extends qreact.Component {
|
|
|
68
68
|
<div className={css.vbox(4)}>
|
|
69
69
|
{Object.entries(machine.info).map(([key, value]) => (
|
|
70
70
|
<div key={key}>
|
|
71
|
-
<span>{key}:</span> {value}
|
|
71
|
+
<span>{key}:</span> {JSON.stringify(value)}
|
|
72
72
|
</div>
|
|
73
73
|
))}
|
|
74
74
|
</div>
|
|
@@ -27,6 +27,98 @@ import path from "path";
|
|
|
27
27
|
|
|
28
28
|
const PIPE_FILE_LINE_LIMIT = 10_000;
|
|
29
29
|
|
|
30
|
+
const getMemoryInfo = measureWrap(async function getMemoryInfo(): Promise<{ value: number; max: number } | undefined> {
|
|
31
|
+
if (os.platform() === "win32") {
|
|
32
|
+
throw new Error("Windows is not supported for machine resource monitoring");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// Linux: Use free command
|
|
37
|
+
let result = await runPromise("free -b", { quiet: true });
|
|
38
|
+
let lines = result.split("\n");
|
|
39
|
+
let memLine = lines.find(line => line.startsWith("Mem:"));
|
|
40
|
+
if (memLine) {
|
|
41
|
+
let parts = memLine.split(/\s+/);
|
|
42
|
+
let total = parseInt(parts[1]);
|
|
43
|
+
let used = parseInt(parts[2]);
|
|
44
|
+
if (total && used >= 0) {
|
|
45
|
+
return { value: used, max: total };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} catch (e: any) {
|
|
49
|
+
console.warn(`Error getting memory info: ${e.message}`);
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const getCpuInfo = measureWrap(async function getCpuInfo(): Promise<{ value: number; max: number; coreCount: number } | undefined> {
|
|
55
|
+
if (os.platform() === "win32") {
|
|
56
|
+
throw new Error("Windows is not supported for machine resource monitoring");
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let coreCount = os.cpus().length;
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
// Linux: Get CPU usage from /proc/stat - need two readings to calculate current usage
|
|
63
|
+
let result1 = await runPromise("grep 'cpu ' /proc/stat", { quiet: true });
|
|
64
|
+
let parts1 = result1.trim().split(/\s+/);
|
|
65
|
+
|
|
66
|
+
if (parts1.length >= 8) {
|
|
67
|
+
// Wait 1 second for accurate measurement
|
|
68
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
69
|
+
|
|
70
|
+
let result2 = await runPromise("grep 'cpu ' /proc/stat", { quiet: true });
|
|
71
|
+
let parts2 = result2.trim().split(/\s+/);
|
|
72
|
+
|
|
73
|
+
if (parts2.length >= 8) {
|
|
74
|
+
// Calculate differences between the two readings
|
|
75
|
+
let idle1 = parseInt(parts1[4]) + parseInt(parts1[5]); // idle + iowait
|
|
76
|
+
let total1 = parts1.slice(1, 8).reduce((sum, val) => sum + parseInt(val), 0);
|
|
77
|
+
|
|
78
|
+
let idle2 = parseInt(parts2[4]) + parseInt(parts2[5]); // idle + iowait
|
|
79
|
+
let total2 = parts2.slice(1, 8).reduce((sum, val) => sum + parseInt(val), 0);
|
|
80
|
+
|
|
81
|
+
let totalDiff = total2 - total1;
|
|
82
|
+
let idleDiff = idle2 - idle1;
|
|
83
|
+
|
|
84
|
+
if (totalDiff > 0) {
|
|
85
|
+
let usagePercent = (totalDiff - idleDiff) / totalDiff;
|
|
86
|
+
let coresUsed = usagePercent * coreCount;
|
|
87
|
+
return { value: coresUsed, max: coreCount, coreCount };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} catch (e: any) {
|
|
92
|
+
console.warn(`Error getting CPU info: ${e.message}`);
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const getDiskInfo = measureWrap(async function getDiskInfo(): Promise<{ value: number; max: number } | undefined> {
|
|
98
|
+
if (os.platform() === "win32") {
|
|
99
|
+
throw new Error("Windows is not supported for machine resource monitoring");
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
// Linux: Get disk usage for root filesystem
|
|
104
|
+
let result = await runPromise("df -B1 /", { quiet: true });
|
|
105
|
+
let lines = result.split("\n");
|
|
106
|
+
if (lines.length >= 2) {
|
|
107
|
+
let parts = lines[1].split(/\s+/);
|
|
108
|
+
if (parts.length >= 4) {
|
|
109
|
+
let total = parseInt(parts[1]);
|
|
110
|
+
let used = parseInt(parts[2]);
|
|
111
|
+
if (total && used >= 0) {
|
|
112
|
+
return { value: used, max: total };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
} catch (e: any) {
|
|
117
|
+
console.warn(`Error getting disk info: ${e.message}`);
|
|
118
|
+
}
|
|
119
|
+
return undefined;
|
|
120
|
+
});
|
|
121
|
+
|
|
30
122
|
const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
31
123
|
let machineInfo: MachineInfo = {
|
|
32
124
|
machineId: getOwnMachineId(),
|
|
@@ -46,6 +138,38 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
46
138
|
machineInfo.repoUrl = await getGitURLLive(".");
|
|
47
139
|
machineInfo.gitRef = await getGitRefLive(".");
|
|
48
140
|
|
|
141
|
+
// Get system resource information
|
|
142
|
+
let [memoryInfo, cpuInfo, diskInfo] = await Promise.all([
|
|
143
|
+
getMemoryInfo(),
|
|
144
|
+
getCpuInfo(),
|
|
145
|
+
getDiskInfo()
|
|
146
|
+
]);
|
|
147
|
+
|
|
148
|
+
if (memoryInfo) {
|
|
149
|
+
machineInfo.info.ram = {
|
|
150
|
+
type: "MEMORY",
|
|
151
|
+
value: memoryInfo.value,
|
|
152
|
+
max: memoryInfo.max,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (cpuInfo) {
|
|
157
|
+
machineInfo.info.cpu = {
|
|
158
|
+
type: "CPU",
|
|
159
|
+
value: cpuInfo.value,
|
|
160
|
+
max: cpuInfo.max,
|
|
161
|
+
coreCount: cpuInfo.coreCount,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (diskInfo) {
|
|
166
|
+
machineInfo.info.disk = {
|
|
167
|
+
type: "DISK",
|
|
168
|
+
value: diskInfo.value,
|
|
169
|
+
max: diskInfo.max,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
49
173
|
return machineInfo;
|
|
50
174
|
});
|
|
51
175
|
|
|
@@ -334,19 +458,12 @@ const runScreenCommand = measureWrap(async function runScreenCommand(config: {
|
|
|
334
458
|
let prefix = getTmuxPrefix();
|
|
335
459
|
let screenName = config.screenName;
|
|
336
460
|
|
|
337
|
-
if (config.rollingWindow) {
|
|
461
|
+
if (config.rollingWindow !== undefined) {
|
|
338
462
|
let screens = await getScreenState();
|
|
339
463
|
let rollingObj = rollingKeepScreenAlive.get(screenName);
|
|
340
464
|
if (rollingObj) {
|
|
341
465
|
rollingObj.pinnedDuration = config.rollingWindow;
|
|
342
466
|
}
|
|
343
|
-
// Without this check we might have only 1 service up for a long period of time. I guess even with it we can still have only 1 service up for a long period of time (if the rolling window is alive, but barely), but... idk... this seems better?
|
|
344
|
-
if (rollingObj && rollingObj.pinnedTime + rollingObj.pinnedDuration < Date.now()) {
|
|
345
|
-
console.log(red(`Rolling screen ${screenName} is finished, deleting it, it should be killed shortly`));
|
|
346
|
-
rollingKeepScreenAlive.delete(screenName);
|
|
347
|
-
rollingScreens.delete(rollingObj.rollingScreenName);
|
|
348
|
-
rollingObj = undefined;
|
|
349
|
-
}
|
|
350
467
|
let existingScreen = screens.find(x => x.screenName === screenName);
|
|
351
468
|
if (existingScreen && !rollingObj) {
|
|
352
469
|
let nodeIdPath = os.homedir() + "/" + SERVICE_FOLDER + screenName + "/" + SERVICE_NODE_FILE_NAME;
|
|
@@ -43,7 +43,12 @@ export type MachineInfo = {
|
|
|
43
43
|
lscpu
|
|
44
44
|
id (fallback to whoami)
|
|
45
45
|
*/
|
|
46
|
-
info: Record<string, string
|
|
46
|
+
info: Record<string, string | {
|
|
47
|
+
type: string;
|
|
48
|
+
value: number;
|
|
49
|
+
max: number;
|
|
50
|
+
coreCount?: number; // Optional for CPU info
|
|
51
|
+
}>;
|
|
47
52
|
|
|
48
53
|
repoUrl: string;
|
|
49
54
|
gitRef: string;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
// updateRootDiscoveryLocation("127-0-0-1.querysubtest.com:7008")
|
|
2
|
-
|
|
3
|
-
Get updateRootDiscoveryLocation called when we disconnect, and don't reconnect?
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
1) Update everything to latest
|
|
8
|
-
3) Update cyoa rolling time back to 4 hours
|
|
9
|
-
|
|
10
1
|
|
|
11
2
|
9) In machine info, support an object which can show current, and max, so we can show it as a bar and the max amount for:
|
|
12
3
|
RAM
|
|
@@ -20,4 +11,6 @@ Get updateRootDiscoveryLocation called when we disconnect, and don't reconnect?
|
|
|
20
11
|
(Yes, it overlaps with node metrics, but that's okay, sometimes we want to look at machines, other times services, and the types of errors that show up in either changes).
|
|
21
12
|
|
|
22
13
|
|
|
23
|
-
11) A spinning animation on the FPS display, so we can visually see when the browser locks up (because the animation will stop?)
|
|
14
|
+
11) A spinning animation on the FPS display, so we can visually see when the browser locks up (because the animation will stop?)
|
|
15
|
+
|
|
16
|
+
1) Update everything to latest
|