@chrysb/alphaclaw 0.3.2-beta.1 → 0.3.2-beta.3
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.
|
@@ -361,7 +361,7 @@ export const WatchdogTab = ({
|
|
|
361
361
|
onToggle=${() => setMemoryExpanded(true)}
|
|
362
362
|
/>
|
|
363
363
|
<${ResourceBar}
|
|
364
|
-
label
|
|
364
|
+
label=${`Disk${r.disk?.path ? ` (${r.disk.path})` : ""}`}
|
|
365
365
|
percent=${r.disk?.percent}
|
|
366
366
|
detail=${`${formatBytes(r.disk?.usedBytes)} / ${formatBytes(r.disk?.totalBytes)}`}
|
|
367
367
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const os = require("os");
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const { execSync } = require("child_process");
|
|
4
|
+
const { kRootDir } = require("./constants");
|
|
4
5
|
|
|
5
6
|
const readCgroupFile = (filePath) => {
|
|
6
7
|
try {
|
|
@@ -76,6 +77,23 @@ const getProcessUsage = (pid) => {
|
|
|
76
77
|
return null;
|
|
77
78
|
};
|
|
78
79
|
|
|
80
|
+
const readDiskUsage = () => {
|
|
81
|
+
const paths = [kRootDir, "/data", "/"];
|
|
82
|
+
for (const diskPath of paths) {
|
|
83
|
+
try {
|
|
84
|
+
const stat = fs.statfsSync(diskPath);
|
|
85
|
+
return {
|
|
86
|
+
usedBytes: stat.bsize * (stat.blocks - stat.bfree),
|
|
87
|
+
totalBytes: stat.bsize * stat.blocks,
|
|
88
|
+
path: diskPath,
|
|
89
|
+
};
|
|
90
|
+
} catch {
|
|
91
|
+
// Try next path.
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { usedBytes: null, totalBytes: null, path: null };
|
|
95
|
+
};
|
|
96
|
+
|
|
79
97
|
let prevCpuSnapshot = null;
|
|
80
98
|
let prevCpuSnapshotAt = 0;
|
|
81
99
|
|
|
@@ -86,15 +104,7 @@ const getSystemResources = ({ gatewayPid = null } = {}) => {
|
|
|
86
104
|
totalBytes: cgroupMem?.totalBytes ?? os.totalmem(),
|
|
87
105
|
};
|
|
88
106
|
|
|
89
|
-
|
|
90
|
-
let diskTotalBytes = null;
|
|
91
|
-
try {
|
|
92
|
-
const stat = fs.statfsSync("/");
|
|
93
|
-
diskTotalBytes = stat.bsize * stat.blocks;
|
|
94
|
-
diskUsedBytes = stat.bsize * (stat.blocks - stat.bfree);
|
|
95
|
-
} catch {
|
|
96
|
-
// statfsSync unavailable
|
|
97
|
-
}
|
|
107
|
+
const diskUsage = readDiskUsage();
|
|
98
108
|
|
|
99
109
|
const cgroupCpu = parseCgroupCpu();
|
|
100
110
|
let cpuPercent = null;
|
|
@@ -129,10 +139,11 @@ const getSystemResources = ({ gatewayPid = null } = {}) => {
|
|
|
129
139
|
: null,
|
|
130
140
|
},
|
|
131
141
|
disk: {
|
|
132
|
-
usedBytes:
|
|
133
|
-
totalBytes:
|
|
134
|
-
|
|
135
|
-
|
|
142
|
+
usedBytes: diskUsage.usedBytes,
|
|
143
|
+
totalBytes: diskUsage.totalBytes,
|
|
144
|
+
path: diskUsage.path,
|
|
145
|
+
percent: diskUsage.totalBytes
|
|
146
|
+
? Math.round((diskUsage.usedBytes / diskUsage.totalBytes) * 1000) / 10
|
|
136
147
|
: null,
|
|
137
148
|
},
|
|
138
149
|
cpu: {
|
|
@@ -33,7 +33,8 @@ const getPairedIds = (channel) => {
|
|
|
33
33
|
return Array.from(ids);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
-
const formatDiscordMessage = (message) =>
|
|
36
|
+
const formatDiscordMessage = (message) =>
|
|
37
|
+
String(message || "").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "**$1**");
|
|
37
38
|
|
|
38
39
|
const createWatchdogNotifier = ({ telegramApi, discordApi }) => {
|
|
39
40
|
const notify = async (message) => {
|