postgresai 0.14.0-dev.79 → 0.14.0-dev.80
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/bin/postgres-ai.ts +3 -16
- package/dist/bin/postgres-ai.js +22 -18
- package/lib/checkup.ts +32 -0
- package/package.json +1 -1
- package/test/checkup.test.ts +1 -1
package/bin/postgres-ai.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { maskSecret } from "../lib/util";
|
|
|
20
20
|
import { createInterface } from "readline";
|
|
21
21
|
import * as childProcess from "child_process";
|
|
22
22
|
import { REPORT_GENERATORS, CHECK_INFO, generateAllReports } from "../lib/checkup";
|
|
23
|
-
import {
|
|
23
|
+
import { getCheckupEntry } from "../lib/checkup-dictionary";
|
|
24
24
|
import { createCheckupReport, uploadCheckupReportJson, RpcError, formatRpcErrorForDisplay, withRetry } from "../lib/checkup-api";
|
|
25
25
|
|
|
26
26
|
// Singleton readline interface for stdin prompts
|
|
@@ -1642,14 +1642,6 @@ program
|
|
|
1642
1642
|
}
|
|
1643
1643
|
});
|
|
1644
1644
|
|
|
1645
|
-
// Build help text showing all checks from dictionary with express-mode indicators
|
|
1646
|
-
const expressCheckIds = new Set(Object.keys(REPORT_GENERATORS));
|
|
1647
|
-
const allChecks = getAllCheckupEntries();
|
|
1648
|
-
const checkHelpLines = allChecks.map((entry) => {
|
|
1649
|
-
const isExpress = expressCheckIds.has(entry.code);
|
|
1650
|
-
return ` ${entry.code}: ${entry.title}${isExpress ? "" : " (*)"}`;
|
|
1651
|
-
});
|
|
1652
|
-
|
|
1653
1645
|
program
|
|
1654
1646
|
.command("checkup [conn]")
|
|
1655
1647
|
.description("generate health check reports directly from PostgreSQL (express mode)")
|
|
@@ -1667,18 +1659,13 @@ program
|
|
|
1667
1659
|
[
|
|
1668
1660
|
"",
|
|
1669
1661
|
"Available checks:",
|
|
1670
|
-
...
|
|
1671
|
-
"",
|
|
1672
|
-
" (*) = not yet available in express mode (coming soon)",
|
|
1673
|
-
" ALL = run all express-mode checks",
|
|
1662
|
+
...Object.entries(CHECK_INFO).map(([id, title]) => ` ${id}: ${title}`),
|
|
1674
1663
|
"",
|
|
1675
1664
|
"Examples:",
|
|
1676
1665
|
" postgresai checkup postgresql://user:pass@host:5432/db",
|
|
1677
|
-
" postgresai checkup postgresql://user:pass@host:5432/db --check-id
|
|
1666
|
+
" postgresai checkup postgresql://user:pass@host:5432/db --check-id D001",
|
|
1678
1667
|
" postgresai checkup postgresql://user:pass@host:5432/db --output ./reports",
|
|
1679
1668
|
" postgresai checkup postgresql://user:pass@host:5432/db --project my_project",
|
|
1680
|
-
" postgresai set-default-project my_project",
|
|
1681
|
-
" postgresai checkup postgresql://user:pass@host:5432/db",
|
|
1682
1669
|
" postgresai checkup postgresql://user:pass@host:5432/db --no-upload --json",
|
|
1683
1670
|
].join("\n")
|
|
1684
1671
|
)
|
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13064,7 +13064,7 @@ var {
|
|
|
13064
13064
|
// package.json
|
|
13065
13065
|
var package_default = {
|
|
13066
13066
|
name: "postgresai",
|
|
13067
|
-
version: "0.14.0-dev.
|
|
13067
|
+
version: "0.14.0-dev.80",
|
|
13068
13068
|
description: "postgres_ai CLI",
|
|
13069
13069
|
license: "Apache-2.0",
|
|
13070
13070
|
private: false,
|
|
@@ -15889,7 +15889,7 @@ var Result = import_lib.default.Result;
|
|
|
15889
15889
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
15890
15890
|
var defaults = import_lib.default.defaults;
|
|
15891
15891
|
// package.json
|
|
15892
|
-
var version = "0.14.0-dev.
|
|
15892
|
+
var version = "0.14.0-dev.80";
|
|
15893
15893
|
var package_default2 = {
|
|
15894
15894
|
name: "postgresai",
|
|
15895
15895
|
version,
|
|
@@ -27755,6 +27755,23 @@ async function generateD004(client, nodeName) {
|
|
|
27755
27755
|
};
|
|
27756
27756
|
return report;
|
|
27757
27757
|
}
|
|
27758
|
+
async function generateD001(client, nodeName) {
|
|
27759
|
+
const report = createBaseReport("D001", "Logging settings", nodeName);
|
|
27760
|
+
const postgresVersion = await getPostgresVersion(client);
|
|
27761
|
+
const pgMajorVersion = parseInt(postgresVersion.server_major_ver, 10) || 16;
|
|
27762
|
+
const allSettings = await getSettings(client, pgMajorVersion);
|
|
27763
|
+
const loggingSettings = {};
|
|
27764
|
+
for (const [name, setting] of Object.entries(allSettings)) {
|
|
27765
|
+
if (name.startsWith("log_") || name.startsWith("logging_")) {
|
|
27766
|
+
loggingSettings[name] = setting;
|
|
27767
|
+
}
|
|
27768
|
+
}
|
|
27769
|
+
report.results[nodeName] = {
|
|
27770
|
+
data: loggingSettings,
|
|
27771
|
+
postgres_version: postgresVersion
|
|
27772
|
+
};
|
|
27773
|
+
return report;
|
|
27774
|
+
}
|
|
27758
27775
|
async function generateF001(client, nodeName) {
|
|
27759
27776
|
const report = createBaseReport("F001", "Autovacuum: current settings", nodeName);
|
|
27760
27777
|
const postgresVersion = await getPostgresVersion(client);
|
|
@@ -27861,6 +27878,7 @@ var REPORT_GENERATORS = {
|
|
|
27861
27878
|
A004: generateA004,
|
|
27862
27879
|
A007: generateA007,
|
|
27863
27880
|
A013: generateA013,
|
|
27881
|
+
D001: generateD001,
|
|
27864
27882
|
D004: generateD004,
|
|
27865
27883
|
F001: generateF001,
|
|
27866
27884
|
G001: generateG001,
|
|
@@ -27897,9 +27915,6 @@ async function generateAllReports(client, nodeName = "node-01", onProgress) {
|
|
|
27897
27915
|
|
|
27898
27916
|
// lib/checkup-dictionary.ts
|
|
27899
27917
|
var dictionaryByCode2 = new Map(CHECKUP_DICTIONARY_DATA.map((entry) => [entry.code, entry]));
|
|
27900
|
-
function getAllCheckupEntries() {
|
|
27901
|
-
return CHECKUP_DICTIONARY_DATA;
|
|
27902
|
-
}
|
|
27903
27918
|
function getCheckupEntry(code) {
|
|
27904
27919
|
return dictionaryByCode2.get(code.toUpperCase()) ?? null;
|
|
27905
27920
|
}
|
|
@@ -29410,27 +29425,16 @@ program2.command("unprepare-db [conn]").description("remove monitoring setup: dr
|
|
|
29410
29425
|
closeReadline();
|
|
29411
29426
|
}
|
|
29412
29427
|
});
|
|
29413
|
-
var expressCheckIds = new Set(Object.keys(REPORT_GENERATORS));
|
|
29414
|
-
var allChecks = getAllCheckupEntries();
|
|
29415
|
-
var checkHelpLines = allChecks.map((entry) => {
|
|
29416
|
-
const isExpress = expressCheckIds.has(entry.code);
|
|
29417
|
-
return ` ${entry.code}: ${entry.title}${isExpress ? "" : " (*)"}`;
|
|
29418
|
-
});
|
|
29419
29428
|
program2.command("checkup [conn]").description("generate health check reports directly from PostgreSQL (express mode)").option("--check-id <id>", `specific check to run (see list below), or ALL`, "ALL").option("--node-name <name>", "node name for reports", "node-01").option("--output <path>", "output directory for JSON files").option("--[no-]upload", "upload JSON results to PostgresAI (default: enabled; requires API key)", undefined).option("--project <project>", "project name or ID for remote upload (used with --upload; defaults to config defaultProject; auto-generated on first run)").option("--json", "output JSON to stdout (implies --no-upload)").addHelpText("after", [
|
|
29420
29429
|
"",
|
|
29421
29430
|
"Available checks:",
|
|
29422
|
-
...
|
|
29423
|
-
"",
|
|
29424
|
-
" (*) = not yet available in express mode (coming soon)",
|
|
29425
|
-
" ALL = run all express-mode checks",
|
|
29431
|
+
...Object.entries(CHECK_INFO).map(([id, title]) => ` ${id}: ${title}`),
|
|
29426
29432
|
"",
|
|
29427
29433
|
"Examples:",
|
|
29428
29434
|
" postgresai checkup postgresql://user:pass@host:5432/db",
|
|
29429
|
-
" postgresai checkup postgresql://user:pass@host:5432/db --check-id
|
|
29435
|
+
" postgresai checkup postgresql://user:pass@host:5432/db --check-id D001",
|
|
29430
29436
|
" postgresai checkup postgresql://user:pass@host:5432/db --output ./reports",
|
|
29431
29437
|
" postgresai checkup postgresql://user:pass@host:5432/db --project my_project",
|
|
29432
|
-
" postgresai set-default-project my_project",
|
|
29433
|
-
" postgresai checkup postgresql://user:pass@host:5432/db",
|
|
29434
29438
|
" postgresai checkup postgresql://user:pass@host:5432/db --no-upload --json"
|
|
29435
29439
|
].join(`
|
|
29436
29440
|
`)).action(async (conn, opts, cmd) => {
|
package/lib/checkup.ts
CHANGED
|
@@ -1186,6 +1186,37 @@ async function generateD004(client: Client, nodeName: string): Promise<Report> {
|
|
|
1186
1186
|
return report;
|
|
1187
1187
|
}
|
|
1188
1188
|
|
|
1189
|
+
/**
|
|
1190
|
+
* Generate D001 report - Logging settings
|
|
1191
|
+
*
|
|
1192
|
+
* Collects all PostgreSQL logging-related settings including:
|
|
1193
|
+
* - Log destination and collector settings
|
|
1194
|
+
* - Log file rotation and naming
|
|
1195
|
+
* - Log verbosity and filtering
|
|
1196
|
+
* - Statement and duration logging
|
|
1197
|
+
*/
|
|
1198
|
+
async function generateD001(client: Client, nodeName: string): Promise<Report> {
|
|
1199
|
+
const report = createBaseReport("D001", "Logging settings", nodeName);
|
|
1200
|
+
const postgresVersion = await getPostgresVersion(client);
|
|
1201
|
+
const pgMajorVersion = parseInt(postgresVersion.server_major_ver, 10) || 16;
|
|
1202
|
+
const allSettings = await getSettings(client, pgMajorVersion);
|
|
1203
|
+
|
|
1204
|
+
// Filter logging-related settings (log_* and logging_*)
|
|
1205
|
+
const loggingSettings: Record<string, SettingInfo> = {};
|
|
1206
|
+
for (const [name, setting] of Object.entries(allSettings)) {
|
|
1207
|
+
if (name.startsWith("log_") || name.startsWith("logging_")) {
|
|
1208
|
+
loggingSettings[name] = setting;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
report.results[nodeName] = {
|
|
1213
|
+
data: loggingSettings,
|
|
1214
|
+
postgres_version: postgresVersion,
|
|
1215
|
+
};
|
|
1216
|
+
|
|
1217
|
+
return report;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1189
1220
|
/**
|
|
1190
1221
|
* Generate F001 report - Autovacuum: current settings
|
|
1191
1222
|
*/
|
|
@@ -1336,6 +1367,7 @@ export const REPORT_GENERATORS: Record<string, (client: Client, nodeName: string
|
|
|
1336
1367
|
A004: generateA004,
|
|
1337
1368
|
A007: generateA007,
|
|
1338
1369
|
A013: generateA013,
|
|
1370
|
+
D001: generateD001,
|
|
1339
1371
|
D004: generateD004,
|
|
1340
1372
|
F001: generateF001,
|
|
1341
1373
|
G001: generateG001,
|
package/package.json
CHANGED
package/test/checkup.test.ts
CHANGED
|
@@ -86,7 +86,7 @@ describe("createBaseReport", () => {
|
|
|
86
86
|
// Tests for CHECK_INFO
|
|
87
87
|
describe("CHECK_INFO and REPORT_GENERATORS", () => {
|
|
88
88
|
// Express-mode checks that have generators
|
|
89
|
-
const expressCheckIds = ["A002", "A003", "A004", "A007", "A013", "D004", "F001", "G001", "H001", "H002", "H004"];
|
|
89
|
+
const expressCheckIds = ["A002", "A003", "A004", "A007", "A013", "D001", "D004", "F001", "G001", "H001", "H002", "H004"];
|
|
90
90
|
|
|
91
91
|
test("CHECK_INFO contains all express-mode checks", () => {
|
|
92
92
|
for (const checkId of expressCheckIds) {
|