server-health-telegram 1.0.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/.env.example +12 -0
- package/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/__tests__/config.test.d.ts +2 -0
- package/dist/__tests__/config.test.d.ts.map +1 -0
- package/dist/__tests__/config.test.js +49 -0
- package/dist/__tests__/config.test.js.map +1 -0
- package/dist/__tests__/format.test.d.ts +2 -0
- package/dist/__tests__/format.test.d.ts.map +1 -0
- package/dist/__tests__/format.test.js +29 -0
- package/dist/__tests__/format.test.js.map +1 -0
- package/dist/__tests__/report.test.d.ts +2 -0
- package/dist/__tests__/report.test.d.ts.map +1 -0
- package/dist/__tests__/report.test.js +148 -0
- package/dist/__tests__/report.test.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +81 -0
- package/dist/config.js.map +1 -0
- package/dist/docker.d.ts +9 -0
- package/dist/docker.d.ts.map +1 -0
- package/dist/docker.js +57 -0
- package/dist/docker.js.map +1 -0
- package/dist/format.d.ts +5 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +41 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/prometheus.d.ts +7 -0
- package/dist/prometheus.d.ts.map +1 -0
- package/dist/prometheus.js +47 -0
- package/dist/prometheus.js.map +1 -0
- package/dist/report.d.ts +3 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +134 -0
- package/dist/report.js.map +1 -0
- package/dist/telegram.d.ts +2 -0
- package/dist/telegram.d.ts.map +1 -0
- package/dist/telegram.js +17 -0
- package/dist/telegram.js.map +1 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/examples/minimal.health-report.config.json +17 -0
- package/examples/respira.health-report.config.json +68 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../src/docker.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,wBAAgB,aAAa,IAAI,aAAa,EAAE,CAqB/C;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAqBtC"}
|
package/dist/docker.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getContainers = getContainers;
|
|
4
|
+
exports.getMemStats = getMemStats;
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
function getContainers() {
|
|
7
|
+
try {
|
|
8
|
+
const out = (0, child_process_1.execSync)('docker ps -a --format "{{.Names}}\t{{.Status}}"', {
|
|
9
|
+
encoding: 'utf8',
|
|
10
|
+
timeout: 15000,
|
|
11
|
+
});
|
|
12
|
+
const containers = [];
|
|
13
|
+
for (const line of out.trim().split('\n')) {
|
|
14
|
+
const parts = line.split('\t');
|
|
15
|
+
if (parts.length < 2)
|
|
16
|
+
continue;
|
|
17
|
+
const name = parts[0].trim();
|
|
18
|
+
const status = parts[1].trim();
|
|
19
|
+
const sl = status.toLowerCase();
|
|
20
|
+
if (sl.startsWith('dead') || sl.startsWith('created') || sl.startsWith('removal'))
|
|
21
|
+
continue;
|
|
22
|
+
if (!name || /^\d/.test(name))
|
|
23
|
+
continue;
|
|
24
|
+
containers.push({ name, status, running: sl.startsWith('up') });
|
|
25
|
+
}
|
|
26
|
+
return containers.sort((a, b) => a.name.localeCompare(b.name));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function getMemStats() {
|
|
33
|
+
try {
|
|
34
|
+
const out = (0, child_process_1.execSync)('docker stats --no-stream --format "{{.Name}}\t{{.MemUsage}}"', { encoding: 'utf8', timeout: 30000 });
|
|
35
|
+
const stats = {};
|
|
36
|
+
for (const line of out.trim().split('\n')) {
|
|
37
|
+
const parts = line.split('\t');
|
|
38
|
+
if (parts.length < 2)
|
|
39
|
+
continue;
|
|
40
|
+
const name = parts[0].trim();
|
|
41
|
+
const used = parts[1].split('/')[0].trim();
|
|
42
|
+
if (used.includes('GiB'))
|
|
43
|
+
stats[name] = parseFloat(used) * 1024 ** 3;
|
|
44
|
+
else if (used.includes('MiB'))
|
|
45
|
+
stats[name] = parseFloat(used) * 1024 ** 2;
|
|
46
|
+
else if (used.includes('KiB'))
|
|
47
|
+
stats[name] = parseFloat(used) * 1024;
|
|
48
|
+
else
|
|
49
|
+
stats[name] = 0;
|
|
50
|
+
}
|
|
51
|
+
return stats;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=docker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker.js","sourceRoot":"","sources":["../src/docker.ts"],"names":[],"mappings":";;AAUA,sCAqBC;AAED,kCAqBC;AAtDD,iDAAyC;AAUzC,SAAgB,aAAa;IAC3B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAA,wBAAQ,EAAC,iDAAiD,EAAE;YACtE,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,MAAM,UAAU,GAAoB,EAAE,CAAC;QACvC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,I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,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,SAAS;YAC/B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC7B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAC3C,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;iBAChE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;iBACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;;gBAChE,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function bar(pct: number, width?: number): string;
|
|
2
|
+
export declare function fmtBytes(b: number | null): string;
|
|
3
|
+
export declare function pctEmoji(p: number | null): string;
|
|
4
|
+
export declare function lagEmoji(lag: number | null): string;
|
|
5
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,CAGnD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CASjD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAKjD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAKnD"}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bar = bar;
|
|
4
|
+
exports.fmtBytes = fmtBytes;
|
|
5
|
+
exports.pctEmoji = pctEmoji;
|
|
6
|
+
exports.lagEmoji = lagEmoji;
|
|
7
|
+
function bar(pct, width = 10) {
|
|
8
|
+
const filled = Math.round((pct / 100) * width);
|
|
9
|
+
return '█'.repeat(filled) + '░'.repeat(width - filled);
|
|
10
|
+
}
|
|
11
|
+
function fmtBytes(b) {
|
|
12
|
+
if (b === null || b === undefined)
|
|
13
|
+
return '?';
|
|
14
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
15
|
+
let val = b;
|
|
16
|
+
for (const unit of units) {
|
|
17
|
+
if (val < 1024)
|
|
18
|
+
return `${val.toFixed(1)} ${unit}`;
|
|
19
|
+
val /= 1024;
|
|
20
|
+
}
|
|
21
|
+
return `${val.toFixed(1)} TB`;
|
|
22
|
+
}
|
|
23
|
+
function pctEmoji(p) {
|
|
24
|
+
if (p === null)
|
|
25
|
+
return '❓';
|
|
26
|
+
if (p < 70)
|
|
27
|
+
return '🟢';
|
|
28
|
+
if (p < 85)
|
|
29
|
+
return '🟡';
|
|
30
|
+
return '🔴';
|
|
31
|
+
}
|
|
32
|
+
function lagEmoji(lag) {
|
|
33
|
+
if (!lag)
|
|
34
|
+
return '🟢';
|
|
35
|
+
if (lag > 200)
|
|
36
|
+
return '🔴';
|
|
37
|
+
if (lag > 100)
|
|
38
|
+
return '🟡';
|
|
39
|
+
return '🟢';
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":";;AAAA,kBAGC;AAED,4BASC;AAED,4BAKC;AAED,4BAKC;AA5BD,SAAgB,GAAG,CAAC,GAAW,EAAE,KAAK,GAAG,EAAE;IACzC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AACzD,CAAC;AAED,SAAgB,QAAQ,CAAC,CAAgB;IACvC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC;IAC9C,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,GAAG,GAAG,IAAI;YAAE,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QACnD,GAAG,IAAI,IAAI,CAAC;IACd,CAAC;IACD,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAChC,CAAC;AAED,SAAgB,QAAQ,CAAC,CAAgB;IACvC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,GAAG,CAAC;IAC3B,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC;IACxB,IAAI,CAAC,GAAG,EAAE;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAkB;IACzC,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,GAAG,GAAG,GAAG;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,GAAG,GAAG,GAAG;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { loadConfig } from './config.js';
|
|
2
|
+
export { buildReport } from './report.js';
|
|
3
|
+
export { sendTelegram } from './telegram.js';
|
|
4
|
+
export type { Config, ReportConfig, AppSection, RabbitmqSection, PrometheusSection, CircuitBreakerConfig } from './types.js';
|
|
5
|
+
export declare function run(envFile?: string, configFile?: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAM7H,wBAAsB,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI9E"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendTelegram = exports.buildReport = exports.loadConfig = void 0;
|
|
4
|
+
exports.run = run;
|
|
5
|
+
var config_js_1 = require("./config.js");
|
|
6
|
+
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_js_1.loadConfig; } });
|
|
7
|
+
var report_js_1 = require("./report.js");
|
|
8
|
+
Object.defineProperty(exports, "buildReport", { enumerable: true, get: function () { return report_js_1.buildReport; } });
|
|
9
|
+
var telegram_js_1 = require("./telegram.js");
|
|
10
|
+
Object.defineProperty(exports, "sendTelegram", { enumerable: true, get: function () { return telegram_js_1.sendTelegram; } });
|
|
11
|
+
const config_js_2 = require("./config.js");
|
|
12
|
+
const report_js_2 = require("./report.js");
|
|
13
|
+
const telegram_js_2 = require("./telegram.js");
|
|
14
|
+
async function run(envFile, configFile) {
|
|
15
|
+
const config = (0, config_js_2.loadConfig)(envFile, configFile);
|
|
16
|
+
const message = await (0, report_js_2.buildReport)(config);
|
|
17
|
+
await (0, telegram_js_2.sendTelegram)(config.telegramBotToken, config.telegramChatId, message);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AASA,kBAIC;AAbD,yCAAyC;AAAhC,uGAAA,UAAU,OAAA;AACnB,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AACpB,6CAA6C;AAApC,2GAAA,YAAY,OAAA;AAGrB,2CAAyC;AACzC,2CAA0C;AAC1C,+CAA6C;AAEtC,KAAK,UAAU,GAAG,CAAC,OAAgB,EAAE,UAAmB;IAC7D,MAAM,MAAM,GAAG,IAAA,sBAAU,EAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,uBAAW,EAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,IAAA,0BAAY,EAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function promQuery(baseUrl: string, query: string): Promise<number | null>;
|
|
2
|
+
export declare function promTargets(baseUrl: string): Promise<{
|
|
3
|
+
total: number;
|
|
4
|
+
downJobs: string[];
|
|
5
|
+
}>;
|
|
6
|
+
export declare function promRawResults(baseUrl: string, query: string): Promise<any[]>;
|
|
7
|
+
//# sourceMappingURL=prometheus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prometheus.d.ts","sourceRoot":"","sources":["../src/prometheus.ts"],"names":[],"mappings":"AAAA,wBAAsB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAWtF;AAED,wBAAsB,WAAW,CAC/B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAchD;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,EAAE,CAAC,CAShB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promQuery = promQuery;
|
|
4
|
+
exports.promTargets = promTargets;
|
|
5
|
+
exports.promRawResults = promRawResults;
|
|
6
|
+
async function promQuery(baseUrl, query) {
|
|
7
|
+
try {
|
|
8
|
+
const url = `${baseUrl}/api/v1/query?query=${encodeURIComponent(query)}`;
|
|
9
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
10
|
+
const data = await res.json();
|
|
11
|
+
const results = data?.data?.result;
|
|
12
|
+
if (!results?.length)
|
|
13
|
+
return null;
|
|
14
|
+
return parseFloat(results[0].value[1]);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function promTargets(baseUrl) {
|
|
21
|
+
try {
|
|
22
|
+
const res = await fetch(`${baseUrl}/api/v1/targets`, {
|
|
23
|
+
signal: AbortSignal.timeout(5000),
|
|
24
|
+
});
|
|
25
|
+
const data = await res.json();
|
|
26
|
+
const targets = data?.data?.activeTargets ?? [];
|
|
27
|
+
const downJobs = targets
|
|
28
|
+
.filter((t) => t.health !== 'up')
|
|
29
|
+
.map((t) => t.labels?.job ?? '?');
|
|
30
|
+
return { total: targets.length, downJobs };
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return { total: 0, downJobs: ['unreachable'] };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function promRawResults(baseUrl, query) {
|
|
37
|
+
try {
|
|
38
|
+
const url = `${baseUrl}/api/v1/query?query=${encodeURIComponent(query)}`;
|
|
39
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(5000) });
|
|
40
|
+
const data = await res.json();
|
|
41
|
+
return data?.data?.result ?? [];
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=prometheus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prometheus.js","sourceRoot":"","sources":["../src/prometheus.ts"],"names":[],"mappings":";;AAAA,8BAWC;AAED,kCAgBC;AAED,wCAYC;AA3CM,KAAK,UAAU,SAAS,CAAC,OAAe,EAAE,KAAa;IAC5D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,GAAG,OAAO,uBAAuB,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;Q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C,EAAE,CAAC;QACzE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAS,CAAC;QACrC,OAAO,IAAI,EAAE,IAAI,EAAE,MAAM,IAAI,EAAE,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAKpC,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8JjE"}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildReport = buildReport;
|
|
4
|
+
const prometheus_js_1 = require("./prometheus.js");
|
|
5
|
+
const docker_js_1 = require("./docker.js");
|
|
6
|
+
const format_js_1 = require("./format.js");
|
|
7
|
+
async function buildReport(config) {
|
|
8
|
+
const now = new Date().toISOString().replace('T', ' ').slice(0, 16) + ' UTC';
|
|
9
|
+
const { report } = config;
|
|
10
|
+
// Primary Prometheus URL (first entry) for system + circuit breaker metrics
|
|
11
|
+
const primaryProm = report.prometheus[0]?.url ?? 'http://localhost:9090';
|
|
12
|
+
// ── system metrics ──────────────────────────────────────────────────────────
|
|
13
|
+
const [ramUsed, ramTotal, cpuPct, diskUsed, diskTotal, load1, load5] = await Promise.all([
|
|
14
|
+
(0, prometheus_js_1.promQuery)(primaryProm, 'node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes'),
|
|
15
|
+
(0, prometheus_js_1.promQuery)(primaryProm, 'node_memory_MemTotal_bytes'),
|
|
16
|
+
(0, prometheus_js_1.promQuery)(primaryProm, "100 - (avg(rate(node_cpu_seconds_total{mode='idle'}[5m])) * 100)"),
|
|
17
|
+
(0, prometheus_js_1.promQuery)(primaryProm, "node_filesystem_size_bytes{mountpoint='/',fstype!='tmpfs'} - node_filesystem_avail_bytes{mountpoint='/',fstype!='tmpfs'}"),
|
|
18
|
+
(0, prometheus_js_1.promQuery)(primaryProm, "node_filesystem_size_bytes{mountpoint='/',fstype!='tmpfs'}"),
|
|
19
|
+
(0, prometheus_js_1.promQuery)(primaryProm, 'node_load1'),
|
|
20
|
+
(0, prometheus_js_1.promQuery)(primaryProm, 'node_load5'),
|
|
21
|
+
]);
|
|
22
|
+
const ramPct = ramUsed && ramTotal ? (ramUsed / ramTotal) * 100 : null;
|
|
23
|
+
const diskPct = diskUsed && diskTotal ? (diskUsed / diskTotal) * 100 : null;
|
|
24
|
+
// ── app metrics (one per configured section) ────────────────────────────────
|
|
25
|
+
const appResults = await Promise.all(report.apps.map(async (app) => {
|
|
26
|
+
const pUrl = app.prometheusUrl ?? primaryProm;
|
|
27
|
+
const [heap, lag] = await Promise.all([
|
|
28
|
+
(0, prometheus_js_1.promQuery)(pUrl, `sum(nodejs_heap_size_used_bytes{job='${app.promJob}'})`),
|
|
29
|
+
(0, prometheus_js_1.promQuery)(pUrl, `max(nodejs_eventloop_lag_p99_seconds{job='${app.promJob}'}) * 1000`),
|
|
30
|
+
]);
|
|
31
|
+
return { label: app.label, heap, lag };
|
|
32
|
+
}));
|
|
33
|
+
// ── docker ──────────────────────────────────────────────────────────────────
|
|
34
|
+
const containers = (0, docker_js_1.getContainers)();
|
|
35
|
+
const memStats = (0, docker_js_1.getMemStats)();
|
|
36
|
+
const running = containers.filter((c) => c.running);
|
|
37
|
+
const stopped = containers.filter((c) => !c.running);
|
|
38
|
+
// ── memory alerts ───────────────────────────────────────────────────────────
|
|
39
|
+
const thresholds = report.memoryThresholds ?? {};
|
|
40
|
+
const defaultMb = report.defaultMemoryThresholdMb ?? 150;
|
|
41
|
+
const memAlerts = [];
|
|
42
|
+
for (const [name, bytes] of Object.entries(memStats).sort()) {
|
|
43
|
+
const threshMb = thresholds[name] ?? defaultMb;
|
|
44
|
+
const threshBytes = threshMb * 1024 * 1024;
|
|
45
|
+
if (bytes > threshBytes) {
|
|
46
|
+
memAlerts.push(` 🔴 <code>${name}</code> ${(0, format_js_1.fmtBytes)(bytes)} (threshold ${threshMb} MB)`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// ── Prometheus target health ─────────────────────────────────────────────────
|
|
50
|
+
const targetResults = await Promise.all(report.prometheus.map(async (p) => ({ label: p.label, ...(await (0, prometheus_js_1.promTargets)(p.url)) })));
|
|
51
|
+
// ── RabbitMQ consumer health ─────────────────────────────────────────────────
|
|
52
|
+
const rmqResults = await Promise.all(report.rabbitmq.map(async (rmq) => {
|
|
53
|
+
const pUrl = rmq.prometheusUrl ?? primaryProm;
|
|
54
|
+
const queueRe = rmq.queues.join('|');
|
|
55
|
+
const results = await (0, prometheus_js_1.promRawResults)(pUrl, `rabbitmq_detailed_queue_consumers{vhost="/",queue=~"${queueRe}",job="${rmq.promJob}"}`);
|
|
56
|
+
if (!results.length)
|
|
57
|
+
return ` ❓ ${rmq.label}: no data`;
|
|
58
|
+
const dead = results
|
|
59
|
+
.filter((r) => parseFloat(r.value[1]) === 0)
|
|
60
|
+
.map((r) => r.metric.queue.replace(/_service_queue|_queue/g, ''));
|
|
61
|
+
if (dead.length)
|
|
62
|
+
return ` 🔴 ${rmq.label}: 0 consumers on: ${dead.join(', ')}`;
|
|
63
|
+
return ` ✅ ${rmq.label}: all ${results.length} queues have consumers`;
|
|
64
|
+
}));
|
|
65
|
+
// ── circuit breakers ─────────────────────────────────────────────────────────
|
|
66
|
+
let cbLines = [];
|
|
67
|
+
if (report.circuitBreakers !== undefined) {
|
|
68
|
+
const cb = report.circuitBreakers;
|
|
69
|
+
const cbProm = cb.prometheusUrl ?? primaryProm;
|
|
70
|
+
const cbQuery = cb.query ?? 'rpc_circuit_breaker_open == 1';
|
|
71
|
+
const lEnv = cb.labelEnv ?? 'env';
|
|
72
|
+
const lSvc = cb.labelService ?? 'service';
|
|
73
|
+
const lPat = cb.labelPattern ?? 'pattern';
|
|
74
|
+
const cbRes = await (0, prometheus_js_1.promRawResults)(cbProm, cbQuery);
|
|
75
|
+
cbLines = cbRes.length === 0
|
|
76
|
+
? [' ✅ All circuit breakers closed']
|
|
77
|
+
: [
|
|
78
|
+
' ⚠️ Open circuit breakers:',
|
|
79
|
+
...cbRes.map((r) => ` 🔴 [${r.metric[lEnv] ?? '?'}] ${r.metric[lSvc] ?? '?'} → ${r.metric[lPat] ?? '?'}`),
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
// ── build message ────────────────────────────────────────────────────────────
|
|
83
|
+
const lines = [`<b>🖥 VPS Health Report</b> ${now}\n`];
|
|
84
|
+
if (memAlerts.length) {
|
|
85
|
+
lines.push('<b>🚨 Memory Alerts</b>', ...memAlerts, '');
|
|
86
|
+
}
|
|
87
|
+
const ramStr = ramPct ? `${(0, format_js_1.fmtBytes)(ramUsed)} / ${(0, format_js_1.fmtBytes)(ramTotal)} (${ramPct.toFixed(0)}%)` : 'unavailable';
|
|
88
|
+
const cpuStr = cpuPct !== null ? `${cpuPct.toFixed(1)}%` : 'unavailable';
|
|
89
|
+
const diskStr = diskPct ? `${(0, format_js_1.fmtBytes)(diskUsed)} / ${(0, format_js_1.fmtBytes)(diskTotal)} (${diskPct.toFixed(0)}%)` : 'unavailable';
|
|
90
|
+
const loadStr = load1 !== null ? `${load1.toFixed(2)} / ${load5.toFixed(2)}` : 'unavailable';
|
|
91
|
+
lines.push(`<b>📊 System</b>\n` +
|
|
92
|
+
`${(0, format_js_1.pctEmoji)(ramPct)} RAM: ${(0, format_js_1.bar)(ramPct ?? 0)} ${ramStr}\n` +
|
|
93
|
+
`${(0, format_js_1.pctEmoji)(cpuPct)} CPU: ${(0, format_js_1.bar)(cpuPct ?? 0)} ${cpuStr}\n` +
|
|
94
|
+
`${(0, format_js_1.pctEmoji)(diskPct)} Disk: ${(0, format_js_1.bar)(diskPct ?? 0)} ${diskStr}\n` +
|
|
95
|
+
`⚖️ Load: ${loadStr} (1m / 5m)\n`);
|
|
96
|
+
const statusIcon = running.length === containers.length ? '✅' : '⚠️';
|
|
97
|
+
lines.push(`<b>${statusIcon} Containers ${running.length}/${containers.length} running</b>`);
|
|
98
|
+
for (const c of stopped.slice(0, 5)) {
|
|
99
|
+
lines.push(` ❌ <code>${c.name}</code> <i>${c.status}</i>`);
|
|
100
|
+
}
|
|
101
|
+
if (stopped.length > 5)
|
|
102
|
+
lines.push(` ❌ … and ${stopped.length - 5} more stopped`);
|
|
103
|
+
const skip = new Set(report.skipContainers ?? []);
|
|
104
|
+
const topMem = Object.entries(memStats)
|
|
105
|
+
.filter(([k, v]) => !skip.has(k) && v > 0)
|
|
106
|
+
.sort(([, a], [, b]) => b - a)
|
|
107
|
+
.slice(0, 12);
|
|
108
|
+
lines.push('\n<b>🧠 Memory per container</b>');
|
|
109
|
+
for (const [name, mem] of topMem) {
|
|
110
|
+
lines.push(` <code>${name.padEnd(40)}</code> ${(0, format_js_1.fmtBytes)(mem)}`);
|
|
111
|
+
}
|
|
112
|
+
if (appResults.length) {
|
|
113
|
+
lines.push('\n<b>⚡ App metrics</b>');
|
|
114
|
+
for (const { label, heap, lag } of appResults) {
|
|
115
|
+
lines.push(` ${(0, format_js_1.lagEmoji)(lag)} ${label} heap ${(0, format_js_1.fmtBytes)(heap)} loop ${lag !== null ? `${lag.toFixed(1)}ms` : '?'}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (targetResults.length) {
|
|
119
|
+
lines.push('\n<b>🎯 Prometheus targets</b>');
|
|
120
|
+
for (const t of targetResults) {
|
|
121
|
+
lines.push(t.downJobs.length
|
|
122
|
+
? ` ⚠️ ${t.label}: ${t.downJobs.length} target(s) down: ${t.downJobs.join(', ')}`
|
|
123
|
+
: ` ✅ ${t.label}: all ${t.total} targets up`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (rmqResults.length) {
|
|
127
|
+
lines.push('\n<b>🐇 RabbitMQ consumer health</b>', ...rmqResults);
|
|
128
|
+
}
|
|
129
|
+
if (cbLines.length) {
|
|
130
|
+
lines.push('\n<b>⚡ Circuit breakers</b>', ...cbLines);
|
|
131
|
+
}
|
|
132
|
+
return lines.join('\n');
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":";;AAKA,kCA8JC;AAlKD,mDAAyE;AACzE,2CAAyD;AACzD,2CAAgE;AAEzD,KAAK,UAAU,WAAW,CAAC,MAAc;IAC9C,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC;IAC7E,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAE1B,4EAA4E;IAC5E,MAAM,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,uBAAuB,CAAC;IAEzE,+EAA+E;IAC/E,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,GAClE,MAAM,OAAO,CAAC,GAAG,CAAC;QAChB,IAAA,yBAAS,EAAC,WAAW,EAAE,6DAA6D,CAAC;QACrF,IAAA,yBAAS,EAAC,WAAW,EAAE,4BAA4B,CAAC;QACpD,IAAA,yBAAS,EAAC,WAAW,EAAE,kEAAkE,CAAC;QAC1F,IAAA,yBAAS,E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IAAI,aAAa,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CACR,CAAC,CAAC,QAAQ,CAAC,MAAM;gBACf,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,oBAAoB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAClF,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,KAAK,aAAa,CAChD,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,sCAAsC,EAAE,GAAG,UAAU,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,KAAK,CAAC,IAAI,CAAC,6BAA6B,EAAE,GAAG,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":"AAAA,wBAAsB,YAAY,CAChC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAef"}
|
package/dist/telegram.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendTelegram = sendTelegram;
|
|
4
|
+
async function sendTelegram(botToken, chatId, text) {
|
|
5
|
+
const payload = JSON.stringify({ chat_id: chatId, text, parse_mode: 'HTML' });
|
|
6
|
+
const res = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: { 'Content-Type': 'application/json' },
|
|
9
|
+
body: payload,
|
|
10
|
+
signal: AbortSignal.timeout(10000),
|
|
11
|
+
});
|
|
12
|
+
if (!res.ok) {
|
|
13
|
+
const body = await res.text();
|
|
14
|
+
throw new Error(`Telegram API error ${res.status}: ${body}`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=telegram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.js","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":";;AAAA,oCAmBC;AAnBM,KAAK,UAAU,YAAY,CAChC,QAAgB,EAChB,MAAc,EACd,IAAY;IAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,MAAM,GAAG,GAAG,MAAM,KAAK,CACrB,+BAA+B,QAAQ,cAAc,EACrD;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,OAAO;QACb,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC;KACnC,CACF,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface AppSection {
|
|
2
|
+
label: string;
|
|
3
|
+
promJob: string;
|
|
4
|
+
prometheusUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RabbitmqSection {
|
|
7
|
+
label: string;
|
|
8
|
+
promJob: string;
|
|
9
|
+
queues: string[];
|
|
10
|
+
prometheusUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PrometheusSection {
|
|
13
|
+
label: string;
|
|
14
|
+
url: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CircuitBreakerConfig {
|
|
17
|
+
prometheusUrl?: string;
|
|
18
|
+
query?: string;
|
|
19
|
+
labelEnv?: string;
|
|
20
|
+
labelService?: string;
|
|
21
|
+
labelPattern?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ReportConfig {
|
|
24
|
+
prometheus: PrometheusSection[];
|
|
25
|
+
apps: AppSection[];
|
|
26
|
+
rabbitmq: RabbitmqSection[];
|
|
27
|
+
circuitBreakers?: CircuitBreakerConfig;
|
|
28
|
+
memoryThresholds?: Record<string, number>;
|
|
29
|
+
defaultMemoryThresholdMb?: number;
|
|
30
|
+
skipContainers?: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface Config {
|
|
33
|
+
telegramBotToken: string;
|
|
34
|
+
telegramChatId: string;
|
|
35
|
+
report: ReportConfig;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAE3B,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAGhC,IAAI,EAAE,UAAU,EAAE,CAAC;IAGnB,QAAQ,EAAE,eAAe,EAAE,CAAC;IAG5B,eAAe,CAAC,EAAE,oBAAoB,CAAC;IAGvC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAGlC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,MAAM;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;CACtB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prometheus": [
|
|
3
|
+
{ "label": "My Server", "url": "http://localhost:9090" }
|
|
4
|
+
],
|
|
5
|
+
"apps": [
|
|
6
|
+
{ "label": "My App prod", "promJob": "my-app-prod" },
|
|
7
|
+
{ "label": "My App staging", "promJob": "my-app-staging" }
|
|
8
|
+
],
|
|
9
|
+
"rabbitmq": [
|
|
10
|
+
{
|
|
11
|
+
"label": "Prod",
|
|
12
|
+
"promJob": "rabbitmq-prod",
|
|
13
|
+
"queues": ["my_queue_1", "my_queue_2"]
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"defaultMemoryThresholdMb": 200
|
|
17
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prometheus": [
|
|
3
|
+
{ "label": "App", "url": "http://localhost:9090" },
|
|
4
|
+
{ "label": "Secondary", "url": "http://localhost:9091" }
|
|
5
|
+
],
|
|
6
|
+
"apps": [
|
|
7
|
+
{ "label": "App prod (8 svc)", "promJob": "nestjs-prod" },
|
|
8
|
+
{ "label": "App staging (8 svc)", "promJob": "nestjs-staging" },
|
|
9
|
+
{ "label": "BB staging", "promJob": "app-staging", "prometheusUrl": "http://localhost:9091" }
|
|
10
|
+
],
|
|
11
|
+
"rabbitmq": [
|
|
12
|
+
{
|
|
13
|
+
"label": "Prod ",
|
|
14
|
+
"promJob": "rabbitmq-prod-detailed",
|
|
15
|
+
"queues": [
|
|
16
|
+
"user_service_queue", "survey_service_queue", "tracking_service_queue",
|
|
17
|
+
"decision_engine_queue", "guidance_service_queue",
|
|
18
|
+
"notification_service_queue", "analytics_service_queue"
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"label": "Staging",
|
|
23
|
+
"promJob": "rabbitmq-staging-detailed",
|
|
24
|
+
"queues": [
|
|
25
|
+
"user_service_queue", "survey_service_queue", "tracking_service_queue",
|
|
26
|
+
"decision_engine_queue", "guidance_service_queue",
|
|
27
|
+
"notification_service_queue", "analytics_service_queue"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"circuitBreakers": {
|
|
32
|
+
"query": "rpc_circuit_breaker_open == 1",
|
|
33
|
+
"labelEnv": "env",
|
|
34
|
+
"labelService": "service",
|
|
35
|
+
"labelPattern": "pattern"
|
|
36
|
+
},
|
|
37
|
+
"skipContainers": ["respira-promtail", "respira-docker-cleanup"],
|
|
38
|
+
"defaultMemoryThresholdMb": 150,
|
|
39
|
+
"memoryThresholds": {
|
|
40
|
+
"respira-postgres-exporter-prod": 50,
|
|
41
|
+
"respira-postgres-exporter-staging": 50,
|
|
42
|
+
"respira-prometheus": 400,
|
|
43
|
+
"bb-prometheus": 400,
|
|
44
|
+
"respira-grafana": 300,
|
|
45
|
+
"bb-grafana": 300,
|
|
46
|
+
"respira-loki": 200,
|
|
47
|
+
"respira-promtail": 200,
|
|
48
|
+
"respira-node-exporter": 50,
|
|
49
|
+
"bb-node-exporter": 50,
|
|
50
|
+
"bb-mongodb-exporter-staging": 80,
|
|
51
|
+
"respira-rabbitmq": 600,
|
|
52
|
+
"respira-staging-rabbitmq": 350,
|
|
53
|
+
"bb-rabbitmq-new": 400,
|
|
54
|
+
"respira-postgres": 400,
|
|
55
|
+
"respira-staging-postgres": 200,
|
|
56
|
+
"bb-pg-new": 300,
|
|
57
|
+
"bb-staging-mongodb": 450,
|
|
58
|
+
"respira-pgbouncer": 60,
|
|
59
|
+
"respira-staging-pgbouncer": 30,
|
|
60
|
+
"bb-pgbouncer-new": 50,
|
|
61
|
+
"respira-api-gateway": 300,
|
|
62
|
+
"respira-staging-api-gateway": 200,
|
|
63
|
+
"bb-api-gateway-new": 200,
|
|
64
|
+
"bb-staging-app": 300,
|
|
65
|
+
"respira-docker-cleanup": 50,
|
|
66
|
+
"bb-docker-cleanup": 50
|
|
67
|
+
}
|
|
68
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "server-health-telegram",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Sends a detailed VPS health report (Docker + Prometheus metrics) to Telegram. Zero heavy dependencies.",
|
|
5
|
+
"keywords": ["telegram", "health", "monitoring", "docker", "prometheus", "vps", "devops", "server", "alerting"],
|
|
6
|
+
"author": "Emaad Nahed",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/YOUR_USERNAME/server-health-telegram.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/YOUR_USERNAME/server-health-telegram#readme",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
15
|
+
"bin": {
|
|
16
|
+
"server-health-telegram": "dist/cli.js"
|
|
17
|
+
},
|
|
18
|
+
"files": ["dist", ".env.example", "examples"],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc",
|
|
21
|
+
"test": "jest",
|
|
22
|
+
"test:watch": "jest --watch",
|
|
23
|
+
"dev": "ts-node src/cli.ts",
|
|
24
|
+
"start": "node dist/cli.js",
|
|
25
|
+
"prepublishOnly": "npm run build && npm test"
|
|
26
|
+
},
|
|
27
|
+
"jest": {
|
|
28
|
+
"preset": "ts-jest",
|
|
29
|
+
"testEnvironment": "node",
|
|
30
|
+
"testMatch": ["**/*.test.ts"],
|
|
31
|
+
"moduleNameMapper": {
|
|
32
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"engines": { "node": ">=18.0.0" },
|
|
36
|
+
"dependencies": {},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/jest": "^29.5.0",
|
|
39
|
+
"@types/node": "^22.0.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"ts-jest": "^29.1.0",
|
|
42
|
+
"ts-node": "^10.9.0",
|
|
43
|
+
"typescript": "^5.4.0"
|
|
44
|
+
}
|
|
45
|
+
}
|