@glassmkr/crucible 0.7.1 → 0.8.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/dist/alerts/__tests__/rules.test.d.ts +1 -0
- package/dist/alerts/__tests__/rules.test.js +325 -0
- package/dist/alerts/__tests__/rules.test.js.map +1 -0
- package/dist/alerts/rules.d.ts +8 -0
- package/dist/alerts/rules.js +139 -32
- package/dist/alerts/rules.js.map +1 -1
- package/dist/api.d.ts +2 -0
- package/dist/api.js +7 -0
- package/dist/api.js.map +1 -0
- package/dist/collect/__tests__/dmi.test.d.ts +1 -0
- package/dist/collect/__tests__/dmi.test.js +114 -0
- package/dist/collect/__tests__/dmi.test.js.map +1 -0
- package/dist/collect/__tests__/ipmi.test.js +47 -1
- package/dist/collect/__tests__/ipmi.test.js.map +1 -1
- package/dist/collect/__tests__/thermal.test.d.ts +1 -0
- package/dist/collect/__tests__/thermal.test.js +164 -0
- package/dist/collect/__tests__/thermal.test.js.map +1 -0
- package/dist/collect/dmi.d.ts +19 -0
- package/dist/collect/dmi.js +109 -0
- package/dist/collect/dmi.js.map +1 -0
- package/dist/collect/ipmi.d.ts +27 -2
- package/dist/collect/ipmi.js +90 -2
- package/dist/collect/ipmi.js.map +1 -1
- package/dist/collect/thermal.d.ts +10 -0
- package/dist/collect/thermal.js +187 -0
- package/dist/collect/thermal.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +2 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/__tests__/capability.test.d.ts +1 -0
- package/dist/lib/__tests__/capability.test.js +87 -0
- package/dist/lib/__tests__/capability.test.js.map +1 -0
- package/dist/lib/__tests__/vendor-sensors.test.d.ts +1 -0
- package/dist/lib/__tests__/vendor-sensors.test.js +49 -0
- package/dist/lib/__tests__/vendor-sensors.test.js.map +1 -0
- package/dist/lib/capability.d.ts +21 -0
- package/dist/lib/capability.js +110 -0
- package/dist/lib/capability.js.map +1 -0
- package/dist/lib/cpu-thermal-chips.d.ts +2 -0
- package/dist/lib/cpu-thermal-chips.js +28 -0
- package/dist/lib/cpu-thermal-chips.js.map +1 -0
- package/dist/lib/types.d.ts +58 -0
- package/dist/lib/vendor-sensors.d.ts +27 -0
- package/dist/lib/vendor-sensors.js +63 -0
- package/dist/lib/vendor-sensors.js.map +1 -0
- package/dist/notify/telegram.js +1 -1
- package/dist/notify/telegram.js.map +1 -1
- package/package.json +16 -1
- package/rule-ids.json +29 -0
- package/.dockerignore +0 -13
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -24
- package/.github/ISSUE_TEMPLATE/no_data.md +0 -26
- package/.github/workflows/docker.yml +0 -53
- package/.github/workflows/publish.yml +0 -25
- package/Dockerfile +0 -59
- package/config/collector.example.yaml +0 -43
- package/docker-compose.yml +0 -26
- package/scripts/sign-release.sh +0 -29
- package/src/__tests__/cli.test.ts +0 -74
- package/src/__tests__/reboot-marker.test.ts +0 -122
- package/src/alerts/evaluator.ts +0 -15
- package/src/alerts/rules.ts +0 -283
- package/src/alerts/state.ts +0 -92
- package/src/cli.ts +0 -112
- package/src/collect/__tests__/ipmi.test.ts +0 -96
- package/src/collect/__tests__/smart.test.ts +0 -68
- package/src/collect/__tests__/system.test.ts +0 -29
- package/src/collect/__tests__/zfs.test.ts +0 -72
- package/src/collect/conntrack.ts +0 -27
- package/src/collect/cpu.ts +0 -92
- package/src/collect/disks.ts +0 -91
- package/src/collect/fd.ts +0 -31
- package/src/collect/io-errors.ts +0 -23
- package/src/collect/io-latency.ts +0 -103
- package/src/collect/ipmi.ts +0 -207
- package/src/collect/memory.ts +0 -30
- package/src/collect/network.ts +0 -193
- package/src/collect/ntp.ts +0 -114
- package/src/collect/os-alerts.ts +0 -43
- package/src/collect/raid.ts +0 -40
- package/src/collect/security.ts +0 -268
- package/src/collect/smart.ts +0 -72
- package/src/collect/system.ts +0 -32
- package/src/collect/systemd.ts +0 -33
- package/src/collect/zfs.ts +0 -66
- package/src/config.ts +0 -65
- package/src/index.ts +0 -221
- package/src/lib/__tests__/parse.test.ts +0 -28
- package/src/lib/exec.ts +0 -16
- package/src/lib/parse.ts +0 -29
- package/src/lib/reboot-marker.ts +0 -88
- package/src/lib/types.ts +0 -226
- package/src/lib/version-check.ts +0 -39
- package/src/lib/version.ts +0 -33
- package/src/metrics-server.ts +0 -123
- package/src/notify/email.ts +0 -69
- package/src/notify/slack.ts +0 -47
- package/src/notify/telegram.ts +0 -65
- package/src/push/forge.ts +0 -109
- package/tsconfig.json +0 -15
- package/vitest.config.ts +0 -12
package/src/push/forge.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import https from "https";
|
|
2
|
-
import tls from "tls";
|
|
3
|
-
import crypto from "crypto";
|
|
4
|
-
import type { Snapshot } from "../lib/types.js";
|
|
5
|
-
|
|
6
|
-
let agent: https.Agent | undefined;
|
|
7
|
-
|
|
8
|
-
export function initForgeAgent(tlsPin?: string): void {
|
|
9
|
-
if (!tlsPin) {
|
|
10
|
-
agent = undefined; // Use default (Node built-in fetch)
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
agent = new https.Agent({
|
|
15
|
-
rejectUnauthorized: true,
|
|
16
|
-
checkServerIdentity: (hostname: string, cert: any) => {
|
|
17
|
-
const err = tls.checkServerIdentity(hostname, cert);
|
|
18
|
-
if (err) return err;
|
|
19
|
-
|
|
20
|
-
const pubkey = cert.pubkey;
|
|
21
|
-
if (!pubkey) return new Error("Certificate has no public key");
|
|
22
|
-
|
|
23
|
-
const hash = crypto.createHash("sha256").update(pubkey).digest("base64");
|
|
24
|
-
if (hash !== tlsPin) {
|
|
25
|
-
return new Error(
|
|
26
|
-
`TLS pin mismatch for ${hostname}. ` +
|
|
27
|
-
`Expected: ${tlsPin}, Got: ${hash}. ` +
|
|
28
|
-
`If the server certificate was rotated with a new key, update tls_pin in collector.yaml.`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return undefined;
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function pushToForge(url: string, apiKey: string, snapshot: Snapshot): Promise<boolean> {
|
|
38
|
-
// If TLS pinning is enabled, use https.request (fetch doesn't support custom agents)
|
|
39
|
-
if (agent) {
|
|
40
|
-
return pushWithAgent(url, apiKey, snapshot);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Default: use fetch (no pinning)
|
|
44
|
-
try {
|
|
45
|
-
const response = await fetch(`${url}/api/v1/ingest`, {
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
48
|
-
body: JSON.stringify(snapshot),
|
|
49
|
-
signal: AbortSignal.timeout(10000),
|
|
50
|
-
});
|
|
51
|
-
if (response.ok) {
|
|
52
|
-
const data = await response.json() as { active_alerts?: number };
|
|
53
|
-
console.log(`[forge] Push successful. Active alerts: ${data.active_alerts ?? 0}`);
|
|
54
|
-
} else {
|
|
55
|
-
console.error(`[forge] Push failed: ${response.status} ${response.statusText}`);
|
|
56
|
-
}
|
|
57
|
-
return response.ok;
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.error("[forge] Push failed, will retry next cycle");
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function pushWithAgent(url: string, apiKey: string, snapshot: Snapshot): Promise<boolean> {
|
|
65
|
-
return new Promise((resolve) => {
|
|
66
|
-
const parsed = new URL(`${url}/api/v1/ingest`);
|
|
67
|
-
const body = JSON.stringify(snapshot);
|
|
68
|
-
|
|
69
|
-
const req = https.request({
|
|
70
|
-
hostname: parsed.hostname,
|
|
71
|
-
port: parsed.port ? parseInt(parsed.port) : 443,
|
|
72
|
-
path: parsed.pathname,
|
|
73
|
-
method: "POST",
|
|
74
|
-
agent,
|
|
75
|
-
headers: {
|
|
76
|
-
Authorization: `Bearer ${apiKey}`,
|
|
77
|
-
"Content-Type": "application/json",
|
|
78
|
-
"Content-Length": Buffer.byteLength(body),
|
|
79
|
-
},
|
|
80
|
-
timeout: 10000,
|
|
81
|
-
}, (res) => {
|
|
82
|
-
let data = "";
|
|
83
|
-
res.on("data", (chunk) => data += chunk);
|
|
84
|
-
res.on("end", () => {
|
|
85
|
-
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
|
86
|
-
try {
|
|
87
|
-
const parsed = JSON.parse(data);
|
|
88
|
-
console.log(`[forge] Push successful (pinned). Active alerts: ${parsed.active_alerts ?? 0}`);
|
|
89
|
-
} catch { /* ignore parse errors */ }
|
|
90
|
-
resolve(true);
|
|
91
|
-
} else {
|
|
92
|
-
console.error(`[forge] Push failed (pinned): ${res.statusCode}`);
|
|
93
|
-
resolve(false);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
req.on("error", (err) => {
|
|
99
|
-
console.error(`[forge] Push failed (pinned): ${err.message}`);
|
|
100
|
-
resolve(false);
|
|
101
|
-
});
|
|
102
|
-
req.on("timeout", () => {
|
|
103
|
-
req.destroy(new Error("Request timed out"));
|
|
104
|
-
resolve(false);
|
|
105
|
-
});
|
|
106
|
-
req.write(body);
|
|
107
|
-
req.end();
|
|
108
|
-
});
|
|
109
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"strict": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"rootDir": "./src"
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*"]
|
|
15
|
-
}
|
package/vitest.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
include: ["src/**/*.test.ts"],
|
|
6
|
-
exclude: ["node_modules", "dist"],
|
|
7
|
-
},
|
|
8
|
-
resolve: {
|
|
9
|
-
// .js specifier inside TS (NodeNext) needs to resolve to .ts in tests
|
|
10
|
-
extensions: [".ts", ".js"],
|
|
11
|
-
},
|
|
12
|
-
});
|