@harperfast/harper-pro 5.0.6 → 5.0.7
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/core/bin/status.js +2 -2
- package/core/bin/stop.js +6 -5
- package/core/components/EntryHandler.ts +2 -4
- package/core/components/Scope.ts +1 -1
- package/core/components/componentLoader.ts +4 -11
- package/core/components/requestRestart.ts +2 -17
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +25 -0
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +34 -0
- package/core/package-lock.json +63 -971
- package/core/resources/DatabaseTransaction.ts +3 -8
- package/core/resources/Table.ts +17 -12
- package/core/resources/databases.ts +2 -2
- package/core/resources/graphql.ts +165 -163
- package/core/resources/indexes/HierarchicalNavigableSmallWorld.ts +3 -14
- package/core/resources/indexes/vector.ts +0 -17
- package/core/resources/loadEnv.ts +16 -20
- package/core/resources/login.ts +3 -4
- package/core/resources/roles.ts +65 -60
- package/core/security/auth.ts +14 -15
- package/core/security/jsLoader.ts +2 -14
- package/core/server/REST.ts +11 -10
- package/core/server/fastifyRoutes.ts +29 -30
- package/core/server/graphqlQuerying.ts +3 -4
- package/core/server/http.ts +1 -175
- package/core/server/mqtt.ts +2 -8
- package/core/server/serverHelpers/serverUtilities.ts +5 -2
- package/core/server/threads/threadServer.js +2 -30
- package/core/server/throttle.ts +0 -18
- package/core/utility/environment/environmentManager.js +4 -10
- package/core/utility/environment/systemInformation.js +355 -0
- package/core/utility/hdbTerms.ts +0 -1
- package/core/utility/operation_authorization.js +5 -2
- package/dist/core/bin/status.js +2 -2
- package/dist/core/bin/status.js.map +1 -1
- package/dist/core/bin/stop.js +5 -5
- package/dist/core/bin/stop.js.map +1 -1
- package/dist/core/components/EntryHandler.js +2 -4
- package/dist/core/components/EntryHandler.js.map +1 -1
- package/dist/core/components/Scope.js +1 -1
- package/dist/core/components/Scope.js.map +1 -1
- package/dist/core/components/componentLoader.js +3 -11
- package/dist/core/components/componentLoader.js.map +1 -1
- package/dist/core/components/requestRestart.js +1 -12
- package/dist/core/components/requestRestart.js.map +1 -1
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +24 -0
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js.map +1 -0
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +19 -18
- package/dist/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js.map +1 -1
- package/dist/core/resources/DatabaseTransaction.js +1 -6
- package/dist/core/resources/DatabaseTransaction.js.map +1 -1
- package/dist/core/resources/Table.js +18 -14
- package/dist/core/resources/Table.js.map +1 -1
- package/dist/core/resources/databases.js +1 -2
- package/dist/core/resources/databases.js.map +1 -1
- package/dist/core/resources/graphql.js +176 -176
- package/dist/core/resources/graphql.js.map +1 -1
- package/dist/core/resources/indexes/HierarchicalNavigableSmallWorld.js +2 -14
- package/dist/core/resources/indexes/HierarchicalNavigableSmallWorld.js.map +1 -1
- package/dist/core/resources/indexes/vector.js +0 -14
- package/dist/core/resources/indexes/vector.js.map +1 -1
- package/dist/core/resources/loadEnv.js +17 -20
- package/dist/core/resources/loadEnv.js.map +1 -1
- package/dist/core/resources/login.js +4 -4
- package/dist/core/resources/login.js.map +1 -1
- package/dist/core/resources/roles.js +68 -64
- package/dist/core/resources/roles.js.map +1 -1
- package/dist/core/security/auth.js +15 -17
- package/dist/core/security/auth.js.map +1 -1
- package/dist/core/security/jsLoader.js +2 -16
- package/dist/core/security/jsLoader.js.map +1 -1
- package/dist/core/server/REST.js +11 -11
- package/dist/core/server/REST.js.map +1 -1
- package/dist/core/server/fastifyRoutes.js +29 -30
- package/dist/core/server/fastifyRoutes.js.map +1 -1
- package/dist/core/server/graphqlQuerying.js +4 -5
- package/dist/core/server/graphqlQuerying.js.map +1 -1
- package/dist/core/server/http.js +0 -179
- package/dist/core/server/http.js.map +1 -1
- package/dist/core/server/mqtt.js +3 -5
- package/dist/core/server/mqtt.js.map +1 -1
- package/dist/core/server/serverHelpers/serverUtilities.js +2 -2
- package/dist/core/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/core/server/threads/threadServer.js +2 -26
- package/dist/core/server/threads/threadServer.js.map +1 -1
- package/dist/core/server/throttle.js +0 -17
- package/dist/core/server/throttle.js.map +1 -1
- package/dist/core/utility/environment/environmentManager.js +4 -9
- package/dist/core/utility/environment/environmentManager.js.map +1 -1
- package/dist/core/utility/environment/systemInformation.js +219 -359
- package/dist/core/utility/environment/systemInformation.js.map +1 -1
- package/dist/core/utility/hdbTerms.js +0 -1
- package/dist/core/utility/hdbTerms.js.map +1 -1
- package/dist/core/utility/operation_authorization.js +2 -2
- package/dist/core/utility/operation_authorization.js.map +1 -1
- package/npm-shrinkwrap.json +54 -974
- package/package.json +1 -2
- package/studio/web/assets/{index-qbLPhOzw.js → index-C0And10y.js} +2 -2
- package/studio/web/assets/{index-qbLPhOzw.js.map → index-C0And10y.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/core/dataLayer/harperBridge/TableSizeObject.ts +0 -35
- package/core/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.ts +0 -24
- package/core/utility/environment/systemInformation.ts +0 -698
- package/dist/core/dataLayer/harperBridge/TableSizeObject.js +0 -32
- package/dist/core/dataLayer/harperBridge/TableSizeObject.js.map +0 -1
|
@@ -1,87 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.SystemInformationResponse = exports.SystemInformationRequest = void 0;
|
|
40
|
-
exports.getTimeInfo = getTimeInfo;
|
|
41
|
-
exports.getCPUInfo = getCPUInfo;
|
|
42
|
-
exports.getMemoryInfo = getMemoryInfo;
|
|
43
|
-
exports.getHDBProcessInfo = getHDBProcessInfo;
|
|
44
|
-
exports.getDiskInfo = getDiskInfo;
|
|
45
|
-
exports.getNetworkInfo = getNetworkInfo;
|
|
46
|
-
exports.getSystemInformation = getSystemInformation;
|
|
47
|
-
exports.getTableSize = getTableSize;
|
|
48
|
-
exports.getMetrics = getMetrics;
|
|
49
|
-
exports.systemInformation = systemInformation;
|
|
50
|
-
const promises_1 = require("node:fs/promises");
|
|
51
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
52
|
-
const systeminformation_1 = __importDefault(require("systeminformation"));
|
|
53
|
-
const harper_logger_js_1 = __importDefault(require("../logging/harper_logger.js"));
|
|
54
|
-
const hdbTerms = __importStar(require("../hdbTerms.js"));
|
|
55
|
-
const lmdbGetTableSize_ts_1 = require("../../dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js");
|
|
56
|
-
const manageThreads_js_1 = require("../../server/threads/manageThreads.js");
|
|
57
|
-
const environmentManager_js_1 = __importDefault(require("./environmentManager.js"));
|
|
58
|
-
const databases_ts_1 = require("../../resources/databases.js");
|
|
59
|
-
const TableSizeObject_ts_1 = require("../../dataLayer/harperBridge/TableSizeObject.js");
|
|
60
|
-
const rocksdb_js_1 = require("@harperfast/rocksdb-js");
|
|
61
|
-
environmentManager_js_1.default.initSync();
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const si = require('systeminformation');
|
|
5
|
+
const log = require('../logging/harper_logger.js');
|
|
6
|
+
const terms = require("../hdbTerms.js");
|
|
7
|
+
const lmdbGetTableSize = require('../../dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js');
|
|
8
|
+
const schemaDescribe = require('../../dataLayer/schemaDescribe.js');
|
|
9
|
+
const { getThreadInfo } = require('../../server/threads/manageThreads.js');
|
|
10
|
+
const env = require('./environmentManager.js');
|
|
11
|
+
env.initSync();
|
|
12
|
+
const { databases } = require("../../resources/databases.js");
|
|
62
13
|
//this will hold the system_information which is static to improve performance
|
|
63
14
|
let systemInformationCache = undefined;
|
|
64
15
|
class SystemInformationRequest {
|
|
65
|
-
operator;
|
|
66
|
-
attributes;
|
|
67
16
|
constructor(attributes) {
|
|
68
|
-
this.operator =
|
|
17
|
+
this.operator = terms.OPERATIONS_ENUM.SYSTEM_INFORMATION;
|
|
69
18
|
this.attributes = attributes;
|
|
70
19
|
}
|
|
71
20
|
}
|
|
72
|
-
exports.SystemInformationRequest = SystemInformationRequest;
|
|
73
21
|
class SystemInformationResponse {
|
|
74
|
-
system
|
|
75
|
-
time;
|
|
76
|
-
cpu;
|
|
77
|
-
memory;
|
|
78
|
-
disk;
|
|
79
|
-
network;
|
|
80
|
-
harperdb_processes;
|
|
81
|
-
table_size;
|
|
82
|
-
metrics;
|
|
83
|
-
threads;
|
|
84
|
-
constructor(system, time, cpu, memory, disk, network, harperdbProcesses, tableSize, metrics, threads) {
|
|
22
|
+
constructor(system, time, cpu, memory, disk, network, harperdbProcesses) {
|
|
85
23
|
this.system = system;
|
|
86
24
|
this.time = time;
|
|
87
25
|
this.cpu = cpu;
|
|
@@ -89,150 +27,139 @@ class SystemInformationResponse {
|
|
|
89
27
|
this.disk = disk;
|
|
90
28
|
this.network = network;
|
|
91
29
|
this.harperdb_processes = harperdbProcesses;
|
|
92
|
-
this.table_size = tableSize;
|
|
93
|
-
this.metrics = metrics;
|
|
94
|
-
this.threads = threads;
|
|
95
30
|
}
|
|
96
31
|
}
|
|
97
|
-
exports
|
|
32
|
+
module.exports = {
|
|
33
|
+
getHDBProcessInfo,
|
|
34
|
+
getNetworkInfo,
|
|
35
|
+
getDiskInfo,
|
|
36
|
+
getMemoryInfo,
|
|
37
|
+
getCPUInfo,
|
|
38
|
+
getTimeInfo,
|
|
39
|
+
getSystemInformation,
|
|
40
|
+
systemInformation,
|
|
41
|
+
getTableSize,
|
|
42
|
+
getMetrics,
|
|
43
|
+
SystemInformationRequest,
|
|
44
|
+
};
|
|
98
45
|
/**
|
|
99
|
-
*
|
|
46
|
+
* executes the time function to return the time info for the system
|
|
47
|
+
* @returns {si.Systeminformation.TimeData}
|
|
100
48
|
*/
|
|
101
49
|
function getTimeInfo() {
|
|
102
|
-
return
|
|
50
|
+
return si.time();
|
|
103
51
|
}
|
|
104
52
|
/**
|
|
105
|
-
*
|
|
106
|
-
* processors
|
|
53
|
+
* executes cpu related functions
|
|
54
|
+
* @returns {Promise<{}|Pick<si.Systeminformation.CpuData, "manufacturer" | "brand" | "vendor" | "speed" | "cores" | "physicalCores" | "processors">>}
|
|
107
55
|
*/
|
|
108
56
|
async function getCPUInfo() {
|
|
109
57
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
virtualization,
|
|
125
|
-
cpu_speed,
|
|
126
|
-
current_load: {
|
|
127
|
-
avgLoad,
|
|
128
|
-
cpus: cpus.map(({ load, loadUser, loadSystem, loadNice, loadIdle, loadIrq }) => ({
|
|
129
|
-
load,
|
|
130
|
-
loadUser,
|
|
131
|
-
loadSystem,
|
|
132
|
-
loadNice,
|
|
133
|
-
loadIdle,
|
|
134
|
-
loadIrq,
|
|
135
|
-
})),
|
|
136
|
-
currentLoad,
|
|
137
|
-
currentLoadUser,
|
|
138
|
-
currentLoadSystem,
|
|
139
|
-
currentLoadNice,
|
|
140
|
-
currentLoadIdle,
|
|
141
|
-
currentLoadIrq,
|
|
142
|
-
},
|
|
143
|
-
};
|
|
58
|
+
// eslint-disable-next-line no-unused-vars
|
|
59
|
+
let { family, model, stepping, revision, voltage, speedmin, speedmax, governor, socket, cache, ...cpuInfo } = await si.cpu();
|
|
60
|
+
cpuInfo.cpu_speed = await si.cpuCurrentSpeed();
|
|
61
|
+
let {
|
|
62
|
+
// eslint-disable-next-line no-unused-vars
|
|
63
|
+
rawCurrentload, cpus, ...cpuCurrentLoad } = await si.currentLoad();
|
|
64
|
+
cpuCurrentLoad.cpus = [];
|
|
65
|
+
cpus.forEach((cpuData) => {
|
|
66
|
+
// eslint-disable-next-line no-unused-vars
|
|
67
|
+
let { rawLoad, rawLoadIdle, rawLoadIrq, rawLoadNice, rawLoadSystem, rawLoadUser, ...cpuLoad } = cpuData;
|
|
68
|
+
cpuCurrentLoad.cpus.push(cpuLoad);
|
|
69
|
+
});
|
|
70
|
+
cpuInfo.current_load = cpuCurrentLoad;
|
|
71
|
+
return cpuInfo;
|
|
144
72
|
}
|
|
145
73
|
catch (e) {
|
|
146
|
-
|
|
147
|
-
return
|
|
74
|
+
log.error(`error in getCPUInfo: ${e}`);
|
|
75
|
+
return {};
|
|
148
76
|
}
|
|
149
77
|
}
|
|
150
78
|
/**
|
|
151
|
-
*
|
|
79
|
+
* fetches information related memory
|
|
80
|
+
* @returns {Promise<{}|Pick<si.Systeminformation.MemData, "total" | "free" | "used" | "active" | "available" | "swaptotal" | "swapused" | "swapfree">>}
|
|
152
81
|
*/
|
|
153
82
|
async function getMemoryInfo() {
|
|
154
83
|
try {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
free,
|
|
159
|
-
used,
|
|
160
|
-
active,
|
|
161
|
-
available,
|
|
162
|
-
reclaimable,
|
|
163
|
-
swaptotal,
|
|
164
|
-
swapused,
|
|
165
|
-
swapfree,
|
|
166
|
-
writeback,
|
|
167
|
-
dirty,
|
|
168
|
-
...process.memoryUsage(),
|
|
169
|
-
};
|
|
84
|
+
// eslint-disable-next-line no-unused-vars
|
|
85
|
+
let { buffers, cached, slab, buffcache, ...memInfo } = await si.mem();
|
|
86
|
+
return Object.assign(memInfo, process.memoryUsage());
|
|
170
87
|
}
|
|
171
88
|
catch (e) {
|
|
172
|
-
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async function getHdbPid() {
|
|
177
|
-
try {
|
|
178
|
-
return Number.parseInt(await (0, promises_1.readFile)(node_path_1.default.join(environmentManager_js_1.default.get(hdbTerms.CONFIG_PARAMS.ROOTPATH), hdbTerms.HDB_PID_FILE), 'utf8'));
|
|
179
|
-
}
|
|
180
|
-
catch (err) {
|
|
181
|
-
if (err.code === hdbTerms.NODE_ERROR_CODES.ENOENT) {
|
|
182
|
-
harper_logger_js_1.default.warn(`Unable to locate 'hdb.pid' file, try stopping and starting Harper. This could be because Harper is not running.`);
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
throw err;
|
|
186
|
-
}
|
|
89
|
+
log.error(`error in getMemoryInfo: ${e}`);
|
|
90
|
+
return {};
|
|
187
91
|
}
|
|
188
92
|
}
|
|
189
93
|
/**
|
|
190
|
-
*
|
|
94
|
+
* searches for & returns the processes for hdb core
|
|
191
95
|
* @returns {Promise<{core: []}>}
|
|
192
96
|
*/
|
|
193
97
|
async function getHDBProcessInfo() {
|
|
194
|
-
|
|
98
|
+
let harperdbProcesses = {
|
|
195
99
|
core: [],
|
|
196
100
|
};
|
|
197
101
|
try {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
102
|
+
let processes = await si.processes();
|
|
103
|
+
let hdbPid;
|
|
104
|
+
try {
|
|
105
|
+
hdbPid = Number.parseInt(await fs.readFile(path.join(env.get(terms.CONFIG_PARAMS.ROOTPATH), terms.HDB_PID_FILE), 'utf8'));
|
|
202
106
|
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
if (err.code === terms.NODE_ERROR_CODES.ENOENT) {
|
|
109
|
+
log.warn(`Unable to locate 'hdb.pid' file, try stopping and starting Harper. This could be because Harper is not running.`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
processes.list.forEach((p) => {
|
|
116
|
+
if (p.pid === hdbPid) {
|
|
117
|
+
harperdbProcesses.core.push(p);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
for (const hdbP of harperdbProcesses.core) {
|
|
121
|
+
for (const p of processes.list) {
|
|
122
|
+
if (p.pid === hdbP.parentPid && (p.name === 'PM2' || p.command === 'PM2')) {
|
|
123
|
+
hdbP.parent = 'PM2';
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return harperdbProcesses;
|
|
203
128
|
}
|
|
204
129
|
catch (e) {
|
|
205
|
-
|
|
130
|
+
log.error(`error in getHDBProcessInfo: ${e}`);
|
|
131
|
+
return harperdbProcesses;
|
|
206
132
|
}
|
|
207
|
-
return harperdbProcesses;
|
|
208
133
|
}
|
|
209
134
|
/**
|
|
210
|
-
*
|
|
211
|
-
* @returns {Promise<
|
|
135
|
+
* gets disk related info & stats
|
|
136
|
+
* @returns {Promise<{}>}
|
|
212
137
|
*/
|
|
213
138
|
async function getDiskInfo() {
|
|
214
|
-
|
|
139
|
+
let disk = {};
|
|
215
140
|
try {
|
|
216
|
-
if (!
|
|
141
|
+
if (!env.get(terms.CONFIG_PARAMS.OPERATIONSAPI_SYSINFO_DISK))
|
|
217
142
|
return disk;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
disk.io =
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
disk.
|
|
143
|
+
// eslint-disable-next-line no-unused-vars
|
|
144
|
+
let { rIO_sec, wIO_sec, tIO_sec, ms, ...diskIo } = await si.disksIO();
|
|
145
|
+
disk.io = diskIo;
|
|
146
|
+
// eslint-disable-next-line no-unused-vars
|
|
147
|
+
let { rxSec, txSec, wxSec, ...fsStats } = await si.fsStats();
|
|
148
|
+
disk.read_write = fsStats;
|
|
149
|
+
disk.size = await si.fsSize();
|
|
150
|
+
return disk;
|
|
224
151
|
}
|
|
225
152
|
catch (e) {
|
|
226
|
-
|
|
153
|
+
log.error(`error in getDiskInfo: ${e}`);
|
|
154
|
+
return disk;
|
|
227
155
|
}
|
|
228
|
-
return disk;
|
|
229
156
|
}
|
|
230
157
|
/**
|
|
231
|
-
*
|
|
158
|
+
* gets networking & connection information & stats
|
|
232
159
|
* @returns {Promise<{interfaces: [], default_interface: null, stats: [], latency: {}, connections: []}>}
|
|
233
160
|
*/
|
|
234
161
|
async function getNetworkInfo() {
|
|
235
|
-
|
|
162
|
+
let network = {
|
|
236
163
|
default_interface: null,
|
|
237
164
|
latency: {},
|
|
238
165
|
interfaces: [],
|
|
@@ -240,227 +167,160 @@ async function getNetworkInfo() {
|
|
|
240
167
|
connections: [],
|
|
241
168
|
};
|
|
242
169
|
try {
|
|
243
|
-
if (!
|
|
170
|
+
if (!env.get(terms.CONFIG_PARAMS.OPERATIONSAPI_SYSINFO_NETWORK))
|
|
244
171
|
return network;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
ip4subnet,
|
|
261
|
-
ip6,
|
|
262
|
-
ip6subnet,
|
|
263
|
-
mac,
|
|
264
|
-
operstate,
|
|
265
|
-
type,
|
|
266
|
-
duplex,
|
|
267
|
-
speed,
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
for (const nStat of stats) {
|
|
271
|
-
const { iface, operstate, rx_bytes, rx_dropped, rx_errors, tx_bytes, tx_dropped, tx_errors } = nStat;
|
|
272
|
-
network.stats.push({ iface, operstate, rx_bytes, rx_dropped, rx_errors, tx_bytes, tx_dropped, tx_errors });
|
|
273
|
-
}
|
|
172
|
+
network.default_interface = await si.networkInterfaceDefault();
|
|
173
|
+
network.latency = await si.inetChecksite('google.com');
|
|
174
|
+
let nInterfaces = await si.networkInterfaces();
|
|
175
|
+
nInterfaces.forEach((_interface) => {
|
|
176
|
+
// eslint-disable-next-line no-unused-vars
|
|
177
|
+
let { internal, virtual, mtu, dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState, carrierChanges, ...networkInt } = _interface;
|
|
178
|
+
network.interfaces.push(networkInt);
|
|
179
|
+
});
|
|
180
|
+
let stats = await si.networkStats();
|
|
181
|
+
stats.forEach((nStat) => {
|
|
182
|
+
// eslint-disable-next-line no-unused-vars
|
|
183
|
+
let { rxSec, txSec, ms, ...stat } = nStat;
|
|
184
|
+
network.stats.push(stat);
|
|
185
|
+
});
|
|
186
|
+
return network;
|
|
274
187
|
}
|
|
275
188
|
catch (e) {
|
|
276
|
-
|
|
189
|
+
log.error(`error in getNetworkInfo: ${e}`);
|
|
190
|
+
return network;
|
|
277
191
|
}
|
|
278
|
-
return network;
|
|
279
192
|
}
|
|
280
193
|
/**
|
|
281
|
-
*
|
|
282
|
-
* @returns {Promise<
|
|
194
|
+
* gets system information
|
|
195
|
+
* @returns {Promise<Pick<si.Systeminformation.OsData, "platform" | "distro" | "release" | "codename" | "kernel" | "arch" | "hostname">|{}>}
|
|
283
196
|
*/
|
|
284
197
|
async function getSystemInformation() {
|
|
285
198
|
if (systemInformationCache !== undefined) {
|
|
286
199
|
return systemInformationCache;
|
|
287
200
|
}
|
|
288
|
-
let
|
|
201
|
+
let system_info = {};
|
|
289
202
|
try {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
kernel,
|
|
299
|
-
arch,
|
|
300
|
-
hostname,
|
|
301
|
-
fqdn,
|
|
302
|
-
node_version: node,
|
|
303
|
-
npm_version: npm,
|
|
304
|
-
};
|
|
305
|
-
systemInformationCache = systemInfo;
|
|
203
|
+
// eslint-disable-next-line no-unused-vars
|
|
204
|
+
let { codepage, logofile, serial, build, servicepack, uefi, ...sysInfo } = await si.osInfo();
|
|
205
|
+
system_info = sysInfo;
|
|
206
|
+
let versions = await si.versions('node, npm');
|
|
207
|
+
system_info.node_version = versions.node;
|
|
208
|
+
system_info.npm_version = versions.npm;
|
|
209
|
+
systemInformationCache = system_info;
|
|
210
|
+
return systemInformationCache;
|
|
306
211
|
}
|
|
307
212
|
catch (e) {
|
|
308
|
-
|
|
213
|
+
log.error(`error in getSystemInformation: ${e}`);
|
|
214
|
+
return system_info;
|
|
309
215
|
}
|
|
310
|
-
return systemInfo;
|
|
311
216
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
// transactionLogRecordCount - currently not supported by `rocksdb-js`
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Retrieves table size information.
|
|
324
|
-
* @returns {TableSizeObject[]}
|
|
325
|
-
*/
|
|
326
|
-
function getTableSize() {
|
|
327
|
-
const results = [];
|
|
328
|
-
const databases = (0, databases_ts_1.getDatabases)();
|
|
329
|
-
for (const db of Object.values(databases)) {
|
|
330
|
-
for (const table of Object.values(db)) {
|
|
331
|
-
if (table.primaryStore.rootStore instanceof rocksdb_js_1.RocksDatabase) {
|
|
332
|
-
results.push(rocksdbGetTableSize(table));
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
results.push((0, lmdbGetTableSize_ts_1.lmdbGetTableSize)(table));
|
|
336
|
-
}
|
|
217
|
+
async function getTableSize() {
|
|
218
|
+
//get details for all tables
|
|
219
|
+
let tableSizes = [];
|
|
220
|
+
let allSchemas = await schemaDescribe.describeAll();
|
|
221
|
+
for (const tables of Object.values(allSchemas)) {
|
|
222
|
+
for (const tableData of Object.values(tables)) {
|
|
223
|
+
tableSizes.push(await lmdbGetTableSize(tableData));
|
|
337
224
|
}
|
|
338
225
|
}
|
|
339
|
-
return
|
|
226
|
+
return tableSizes;
|
|
340
227
|
}
|
|
341
|
-
const rocksDBDatabaseLevelStats = new Set([
|
|
342
|
-
'blockCacheCapacity',
|
|
343
|
-
'blockCacheDataHit',
|
|
344
|
-
'blockCacheDataMiss',
|
|
345
|
-
'blockCacheFilterHit',
|
|
346
|
-
'blockCacheFilterMiss',
|
|
347
|
-
'blockCacheHit',
|
|
348
|
-
'blockCacheIndexHit',
|
|
349
|
-
'blockCacheIndexMiss',
|
|
350
|
-
'blockCacheMiss',
|
|
351
|
-
'blockCachePinnedUsage',
|
|
352
|
-
'blockCacheUsage',
|
|
353
|
-
'bytesRead',
|
|
354
|
-
'bytesWritten',
|
|
355
|
-
'dbFlushMicros',
|
|
356
|
-
'dbGetMicros',
|
|
357
|
-
'dbSeekMicros',
|
|
358
|
-
'dbWriteMicros',
|
|
359
|
-
'noFileErrors',
|
|
360
|
-
'numberKeysRead',
|
|
361
|
-
'numberKeysWritten',
|
|
362
|
-
'numberReseeksIteration',
|
|
363
|
-
'numRunningFlushes',
|
|
364
|
-
'oldestSnapshotTime',
|
|
365
|
-
'stallMicros',
|
|
366
|
-
'txnOverheadMutexOldCommitMap',
|
|
367
|
-
'txnOverheadMutexPrepare',
|
|
368
|
-
'txnOverheadMutexSnapshot',
|
|
369
|
-
]);
|
|
370
|
-
// Strips the "rocksdb." prefix and converts kebab-case to camelCase
|
|
371
|
-
function toRocksDBCamelCase(key) {
|
|
372
|
-
return key.replace(/^rocksdb\./, '').replace(/[-.]([a-z])/g, (_, c) => c.toUpperCase());
|
|
373
|
-
}
|
|
374
|
-
function getRocksDBStats(table, dbStats) {
|
|
375
|
-
const stats = table.primaryStore.getStats();
|
|
376
|
-
const tableStats = (dbStats.tables[table.tableName] = {});
|
|
377
|
-
for (const [key, value] of Object.entries(stats)) {
|
|
378
|
-
const name = toRocksDBCamelCase(key);
|
|
379
|
-
if (rocksDBDatabaseLevelStats.has(name)) {
|
|
380
|
-
dbStats[name] = value;
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
tableStats[name] = value;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function getLMDBStats(table, dbStats) {
|
|
388
|
-
if (!dbStats.readers) {
|
|
389
|
-
const { root: _root, ...stats } = table.primaryStore.rootStore.getStats();
|
|
390
|
-
Object.assign(dbStats, stats);
|
|
391
|
-
dbStats.readers = table.primaryStore.rootStore
|
|
392
|
-
.readerList()
|
|
393
|
-
.split(/\n\s+/)
|
|
394
|
-
.slice(1)
|
|
395
|
-
.map((line) => {
|
|
396
|
-
const [pid, thread, txnid] = line.trim().split(' ');
|
|
397
|
-
return { pid, thread, txnid };
|
|
398
|
-
});
|
|
399
|
-
if (table.auditStore) {
|
|
400
|
-
const { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages } = table.auditStore.getStats();
|
|
401
|
-
dbStats.audit = { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages };
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
const { entryCount, overflowPages, treeBranchPageCount, treeDepth, treeLeafPageCount } = table.primaryStore.getStats();
|
|
405
|
-
dbStats.tables[table.tableName] = { entryCount, overflowPages, treeBranchPageCount, treeDepth, treeLeafPageCount };
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Get RocksDB or LMDB metrics for all databases and tables.
|
|
409
|
-
* @returns {Promise<DatabaseMetrics>}
|
|
410
|
-
*/
|
|
411
228
|
async function getMetrics() {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
for (const [tableName, table] of Object.entries(db)) {
|
|
229
|
+
let schemaStats = {};
|
|
230
|
+
for (let schemaName in databases) {
|
|
231
|
+
let dbStats = (schemaStats[schemaName] = {});
|
|
232
|
+
let tableStats = (dbStats.tables = {});
|
|
233
|
+
for (let tableName in databases[schemaName]) {
|
|
418
234
|
try {
|
|
419
|
-
|
|
420
|
-
|
|
235
|
+
let table = databases[schemaName][tableName];
|
|
236
|
+
if (!dbStats.readers) {
|
|
237
|
+
Object.assign(dbStats, table.primaryStore.rootStore.getStats());
|
|
238
|
+
delete dbStats.root;
|
|
239
|
+
dbStats.readers = table.primaryStore.rootStore
|
|
240
|
+
.readerList()
|
|
241
|
+
.split(/\n\s+/)
|
|
242
|
+
.slice(1)
|
|
243
|
+
.map((line) => {
|
|
244
|
+
const [pid, thread, txnid] = line.trim().split(' ');
|
|
245
|
+
return { pid, thread, txnid };
|
|
246
|
+
});
|
|
247
|
+
if (table.auditStore) {
|
|
248
|
+
const { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages } = table.auditStore.getStats();
|
|
249
|
+
dbStats.audit = { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages };
|
|
250
|
+
}
|
|
421
251
|
}
|
|
422
|
-
|
|
423
|
-
|
|
252
|
+
let tableFullStats = table.primaryStore.getStats();
|
|
253
|
+
let tablePrunedStats = {};
|
|
254
|
+
for (let storeKey of ['treeDepth', 'treeBranchPageCount', 'treeLeafPageCount', 'entryCount', 'overflowPages']) {
|
|
255
|
+
tablePrunedStats[storeKey] = tableFullStats[storeKey];
|
|
424
256
|
}
|
|
257
|
+
tableStats[tableName] = tablePrunedStats;
|
|
425
258
|
}
|
|
426
259
|
catch (error) {
|
|
427
|
-
// if a
|
|
428
|
-
|
|
260
|
+
// if a schema no longer exists, don't want to throw an error
|
|
261
|
+
log.notify(`Error getting stats for table ${tableName}: ${error}`);
|
|
429
262
|
}
|
|
430
263
|
}
|
|
431
264
|
}
|
|
432
|
-
return
|
|
265
|
+
return schemaStats;
|
|
433
266
|
}
|
|
434
|
-
const attributeMap = {
|
|
435
|
-
system: getSystemInformation,
|
|
436
|
-
time: getTimeInfo,
|
|
437
|
-
cpu: getCPUInfo,
|
|
438
|
-
memory: getMemoryInfo,
|
|
439
|
-
disk: getDiskInfo,
|
|
440
|
-
network: getNetworkInfo,
|
|
441
|
-
harperdb_processes: getHDBProcessInfo,
|
|
442
|
-
table_size: getTableSize,
|
|
443
|
-
metrics: getMetrics,
|
|
444
|
-
threads: manageThreads_js_1.getThreadInfo,
|
|
445
|
-
};
|
|
446
267
|
/**
|
|
447
|
-
*
|
|
268
|
+
*
|
|
448
269
|
* @param {SystemInformationRequest} systemInfoReq
|
|
449
270
|
* @returns {Promise<SystemInformationResponse>}
|
|
450
271
|
*/
|
|
451
272
|
async function systemInformation(systemInfoReq) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
.
|
|
458
|
-
.
|
|
459
|
-
|
|
460
|
-
|
|
273
|
+
let response = new SystemInformationResponse();
|
|
274
|
+
if (!Array.isArray(systemInfoReq.attributes) || systemInfoReq.attributes.length === 0) {
|
|
275
|
+
response.system = await getSystemInformation();
|
|
276
|
+
response.time = getTimeInfo();
|
|
277
|
+
response.cpu = await getCPUInfo();
|
|
278
|
+
response.memory = await getMemoryInfo();
|
|
279
|
+
response.disk = await getDiskInfo();
|
|
280
|
+
response.network = await getNetworkInfo();
|
|
281
|
+
response.harperdb_processes = await getHDBProcessInfo();
|
|
282
|
+
response.table_size = await getTableSize();
|
|
283
|
+
response.metrics = await getMetrics();
|
|
284
|
+
response.threads = await getThreadInfo();
|
|
285
|
+
return response;
|
|
286
|
+
}
|
|
287
|
+
for (let attr of systemInfoReq.attributes) {
|
|
288
|
+
switch (attr) {
|
|
289
|
+
case 'system':
|
|
290
|
+
response.system = await getSystemInformation();
|
|
291
|
+
break;
|
|
292
|
+
case 'time':
|
|
293
|
+
response.time = getTimeInfo();
|
|
294
|
+
break;
|
|
295
|
+
case 'cpu':
|
|
296
|
+
response.cpu = await getCPUInfo();
|
|
297
|
+
break;
|
|
298
|
+
case 'memory':
|
|
299
|
+
response.memory = await getMemoryInfo();
|
|
300
|
+
break;
|
|
301
|
+
case 'disk':
|
|
302
|
+
response.disk = await getDiskInfo();
|
|
303
|
+
break;
|
|
304
|
+
case 'network':
|
|
305
|
+
response.network = await getNetworkInfo();
|
|
306
|
+
break;
|
|
307
|
+
case 'harperdb_processes':
|
|
308
|
+
response.harperdb_processes = await getHDBProcessInfo();
|
|
309
|
+
break;
|
|
310
|
+
case 'table_size':
|
|
311
|
+
response.table_size = await getTableSize();
|
|
312
|
+
break;
|
|
313
|
+
case 'database_metrics':
|
|
314
|
+
case 'metrics':
|
|
315
|
+
response.metrics = await getMetrics();
|
|
316
|
+
break;
|
|
317
|
+
case 'threads':
|
|
318
|
+
response.threads = await getThreadInfo();
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
break;
|
|
461
322
|
}
|
|
462
|
-
|
|
463
|
-
}));
|
|
323
|
+
}
|
|
464
324
|
return response;
|
|
465
325
|
}
|
|
466
326
|
//# sourceMappingURL=systemInformation.js.map
|