querysub 0.307.0 → 0.308.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 +1 -1
- package/src/deployManager/components/MachineDetailPage.tsx +22 -4
- package/src/deployManager/components/MachinesListPage.tsx +15 -1
- package/src/deployManager/machineApplyMainCode.ts +9 -61
- package/src/deployManager/machineSchema.ts +0 -1
- package/src/deployManager/spec.txt +0 -16
package/package.json
CHANGED
|
@@ -3,9 +3,10 @@ import { qreact } from "../../4-dom/qreact";
|
|
|
3
3
|
import { MACHINE_RESYNC_INTERVAL, MachineServiceController, ServiceConfig } from "../machineSchema";
|
|
4
4
|
import { css } from "typesafecss";
|
|
5
5
|
import { currentViewParam, selectedMachineIdParam, selectedServiceIdParam } from "../urlParams";
|
|
6
|
-
import { formatVeryNiceDateTime } from "socket-function/src/formatting/format";
|
|
6
|
+
import { formatNumber, formatVeryNiceDateTime } from "socket-function/src/formatting/format";
|
|
7
7
|
import { sort } from "socket-function/src/misc";
|
|
8
8
|
import { Anchor } from "../../library-components/ATag";
|
|
9
|
+
import { ShowMore } from "../../library-components/ShowMore";
|
|
9
10
|
|
|
10
11
|
export class MachineDetailPage extends qreact.Component {
|
|
11
12
|
render() {
|
|
@@ -65,10 +66,27 @@ export class MachineDetailPage extends qreact.Component {
|
|
|
65
66
|
|
|
66
67
|
<div>
|
|
67
68
|
<h3>System Information</h3>
|
|
68
|
-
<div className={css.vbox(
|
|
69
|
+
<div className={css.vbox(10)}>
|
|
69
70
|
{Object.entries(machine.info).map(([key, value]) => (
|
|
70
|
-
<div key={key}>
|
|
71
|
-
<
|
|
71
|
+
<div key={key} className={css.hbox(10).hsla(0, 0, 0, 0.1).pad2(10, 2)}>
|
|
72
|
+
<b>{key}:</b>
|
|
73
|
+
<ShowMore className={css.whiteSpace("pre-wrap")} maxHeight={40}>
|
|
74
|
+
{(() => {
|
|
75
|
+
if (typeof value === "object") {
|
|
76
|
+
return <div className={css.pad2(6, 2).hsla(0, 0, 0, 0.1).relative}>
|
|
77
|
+
<div className={
|
|
78
|
+
css.absolute.pos(0, 0)
|
|
79
|
+
.size(`${value.value / value.max * 100}%`, "100%")
|
|
80
|
+
.hsl(0, 0, 70)
|
|
81
|
+
} />
|
|
82
|
+
<div className={css.relative}>
|
|
83
|
+
{value.type} ({formatNumber(value.value)} / {formatNumber(value.max)})
|
|
84
|
+
</div>
|
|
85
|
+
</div>;
|
|
86
|
+
}
|
|
87
|
+
return value;
|
|
88
|
+
})()}
|
|
89
|
+
</ShowMore>
|
|
72
90
|
</div>
|
|
73
91
|
))}
|
|
74
92
|
</div>
|
|
@@ -5,7 +5,7 @@ import { css } from "typesafecss";
|
|
|
5
5
|
import { t } from "../../2-proxy/schema2";
|
|
6
6
|
import { Querysub } from "../../4-querysub/QuerysubController";
|
|
7
7
|
import { currentViewParam, selectedMachineIdParam } from "../urlParams";
|
|
8
|
-
import { formatVeryNiceDateTime } from "socket-function/src/formatting/format";
|
|
8
|
+
import { formatNumber, formatVeryNiceDateTime } from "socket-function/src/formatting/format";
|
|
9
9
|
import { sort } from "socket-function/src/misc";
|
|
10
10
|
import { formatDateJSX } from "../../misc/formatJSX";
|
|
11
11
|
import { DeployMachineButtons, RenderGitRefInfo } from "./deployButtons";
|
|
@@ -173,6 +173,20 @@ export class MachinesListPage extends qreact.Component {
|
|
|
173
173
|
Last heartbeat {formatDateJSX(machineInfo.heartbeat)}
|
|
174
174
|
</div>
|
|
175
175
|
<RenderGitRefInfo gitRef={machineInfo.gitRef} />
|
|
176
|
+
{Object.values(machineInfo.info).map(value => {
|
|
177
|
+
if (typeof value === "string") return undefined;
|
|
178
|
+
return <div className={css.pad2(6, 2).hsla(0, 0, 0, 0.1).relative}>
|
|
179
|
+
<div className={
|
|
180
|
+
css.absolute.pos(0, 0)
|
|
181
|
+
.size(`${value.value / value.max * 100}%`, "100%")
|
|
182
|
+
.hsl(0, 0, 70)
|
|
183
|
+
} />
|
|
184
|
+
<div className={css.relative}>
|
|
185
|
+
{value.type} ({formatNumber(value.value)} / {formatNumber(value.max)})
|
|
186
|
+
</div>
|
|
187
|
+
</div>;
|
|
188
|
+
|
|
189
|
+
})}
|
|
176
190
|
</div>
|
|
177
191
|
<div className={css.vbox(4).flexGrow(1)}>
|
|
178
192
|
<div>
|
|
@@ -51,48 +51,6 @@ const getMemoryInfo = measureWrap(async function getMemoryInfo(): Promise<{ valu
|
|
|
51
51
|
return undefined;
|
|
52
52
|
});
|
|
53
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
54
|
|
|
97
55
|
const getDiskInfo = measureWrap(async function getDiskInfo(): Promise<{ value: number; max: number } | undefined> {
|
|
98
56
|
if (os.platform() === "win32") {
|
|
@@ -130,18 +88,9 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
130
88
|
gitRef: "",
|
|
131
89
|
};
|
|
132
90
|
|
|
133
|
-
machineInfo.info.hostnamectl = await errorToUndefinedSilent(runPromise("hostnamectl")) || "";
|
|
134
|
-
machineInfo.info.getExternalIP = await errorToUndefinedSilent(getExternalIP()) || "";
|
|
135
|
-
machineInfo.info.lscpu = await errorToUndefinedSilent(runPromise("lscpu")) || "";
|
|
136
|
-
machineInfo.info.id = await errorToUndefinedSilent(runPromise("id")) || await errorToUndefinedSilent(runPromise("whoami")) || "";
|
|
137
|
-
|
|
138
|
-
machineInfo.repoUrl = await getGitURLLive(".");
|
|
139
|
-
machineInfo.gitRef = await getGitRefLive(".");
|
|
140
|
-
|
|
141
91
|
// Get system resource information
|
|
142
|
-
let [memoryInfo,
|
|
92
|
+
let [memoryInfo, diskInfo] = await Promise.all([
|
|
143
93
|
getMemoryInfo(),
|
|
144
|
-
getCpuInfo(),
|
|
145
94
|
getDiskInfo()
|
|
146
95
|
]);
|
|
147
96
|
|
|
@@ -153,15 +102,6 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
153
102
|
};
|
|
154
103
|
}
|
|
155
104
|
|
|
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
105
|
if (diskInfo) {
|
|
166
106
|
machineInfo.info.disk = {
|
|
167
107
|
type: "DISK",
|
|
@@ -170,6 +110,14 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
170
110
|
};
|
|
171
111
|
}
|
|
172
112
|
|
|
113
|
+
machineInfo.info.hostnamectl = await errorToUndefinedSilent(runPromise("hostnamectl")) || "";
|
|
114
|
+
machineInfo.info.getExternalIP = await errorToUndefinedSilent(getExternalIP()) || "";
|
|
115
|
+
machineInfo.info.lscpu = await errorToUndefinedSilent(runPromise("lscpu")) || "";
|
|
116
|
+
machineInfo.info.id = await errorToUndefinedSilent(runPromise("id")) || await errorToUndefinedSilent(runPromise("whoami")) || "";
|
|
117
|
+
|
|
118
|
+
machineInfo.repoUrl = await getGitURLLive(".");
|
|
119
|
+
machineInfo.gitRef = await getGitRefLive(".");
|
|
120
|
+
|
|
173
121
|
return machineInfo;
|
|
174
122
|
});
|
|
175
123
|
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
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:
|
|
3
|
-
RAM
|
|
4
|
-
CPU
|
|
5
|
-
DISK
|
|
6
|
-
|
|
7
|
-
10) Add RAM total, ram % used, cpu count, CPU %, disk size, disk % used to machine info
|
|
8
|
-
- Show this all in the list page, with nice bars?
|
|
9
|
-
- Filled, but the total size will also depend on the maximum (to a degree), so it's very nice.
|
|
10
|
-
- A bar, with a label, or something. The AI can give us a few options
|
|
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).
|
|
12
|
-
|
|
13
|
-
|
|
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
|