querysub 0.306.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 +72 -0
- package/src/deployManager/machineSchema.ts +5 -1
- package/src/deployManager/spec.txt +0 -18
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>
|
|
@@ -27,6 +27,56 @@ 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
|
+
|
|
55
|
+
const getDiskInfo = measureWrap(async function getDiskInfo(): Promise<{ value: number; max: number } | undefined> {
|
|
56
|
+
if (os.platform() === "win32") {
|
|
57
|
+
throw new Error("Windows is not supported for machine resource monitoring");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
// Linux: Get disk usage for root filesystem
|
|
62
|
+
let result = await runPromise("df -B1 /", { quiet: true });
|
|
63
|
+
let lines = result.split("\n");
|
|
64
|
+
if (lines.length >= 2) {
|
|
65
|
+
let parts = lines[1].split(/\s+/);
|
|
66
|
+
if (parts.length >= 4) {
|
|
67
|
+
let total = parseInt(parts[1]);
|
|
68
|
+
let used = parseInt(parts[2]);
|
|
69
|
+
if (total && used >= 0) {
|
|
70
|
+
return { value: used, max: total };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} catch (e: any) {
|
|
75
|
+
console.warn(`Error getting disk info: ${e.message}`);
|
|
76
|
+
}
|
|
77
|
+
return undefined;
|
|
78
|
+
});
|
|
79
|
+
|
|
30
80
|
const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
31
81
|
let machineInfo: MachineInfo = {
|
|
32
82
|
machineId: getOwnMachineId(),
|
|
@@ -38,6 +88,28 @@ const getLiveMachineInfo = measureWrap(async function getLiveMachineInfo() {
|
|
|
38
88
|
gitRef: "",
|
|
39
89
|
};
|
|
40
90
|
|
|
91
|
+
// Get system resource information
|
|
92
|
+
let [memoryInfo, diskInfo] = await Promise.all([
|
|
93
|
+
getMemoryInfo(),
|
|
94
|
+
getDiskInfo()
|
|
95
|
+
]);
|
|
96
|
+
|
|
97
|
+
if (memoryInfo) {
|
|
98
|
+
machineInfo.info.ram = {
|
|
99
|
+
type: "MEMORY",
|
|
100
|
+
value: memoryInfo.value,
|
|
101
|
+
max: memoryInfo.max,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (diskInfo) {
|
|
106
|
+
machineInfo.info.disk = {
|
|
107
|
+
type: "DISK",
|
|
108
|
+
value: diskInfo.value,
|
|
109
|
+
max: diskInfo.max,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
41
113
|
machineInfo.info.hostnamectl = await errorToUndefinedSilent(runPromise("hostnamectl")) || "";
|
|
42
114
|
machineInfo.info.getExternalIP = await errorToUndefinedSilent(getExternalIP()) || "";
|
|
43
115
|
machineInfo.info.lscpu = await errorToUndefinedSilent(runPromise("lscpu")) || "";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
1) Update everything to latest
|
|
3
|
-
3) Update cyoa rolling time back to 4 hours
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
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:
|
|
7
|
-
RAM
|
|
8
|
-
CPU
|
|
9
|
-
DISK
|
|
10
|
-
|
|
11
|
-
10) Add RAM total, ram % used, cpu count, CPU %, disk size, disk % used to machine info
|
|
12
|
-
- Show this all in the list page, with nice bars?
|
|
13
|
-
- Filled, but the total size will also depend on the maximum (to a degree), so it's very nice.
|
|
14
|
-
- A bar, with a label, or something. The AI can give us a few options
|
|
15
|
-
(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).
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
11) A spinning animation on the FPS display, so we can visually see when the browser locks up (because the animation will stop?)
|