@harperfast/harper 5.0.7 → 5.0.9
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/status.js +2 -2
- package/bin/stop.js +5 -6
- package/components/OptionsWatcher.ts +9 -1
- package/dataLayer/harperBridge/TableSizeObject.ts +35 -0
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.ts +24 -0
- package/dist/bin/status.js +2 -2
- package/dist/bin/status.js.map +1 -1
- package/dist/bin/stop.js +5 -5
- package/dist/bin/stop.js.map +1 -1
- package/dist/components/OptionsWatcher.js +8 -1
- package/dist/components/OptionsWatcher.js.map +1 -1
- package/dist/dataLayer/harperBridge/TableSizeObject.d.ts +20 -0
- package/dist/dataLayer/harperBridge/TableSizeObject.js +32 -0
- package/dist/dataLayer/harperBridge/TableSizeObject.js.map +1 -0
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.d.ts +6 -6
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +18 -19
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js.map +1 -1
- package/dist/globals.d.ts +4 -3
- package/dist/globals.js +7 -4
- package/dist/globals.js.map +1 -1
- package/dist/index.d.ts +45 -7
- package/dist/index.js +32 -36
- package/dist/index.js.map +1 -1
- package/dist/resources/DatabaseTransaction.js +6 -1
- package/dist/resources/DatabaseTransaction.js.map +1 -1
- package/dist/resources/RecordEncoder.d.ts +1 -0
- package/dist/resources/RecordEncoder.js +18 -9
- package/dist/resources/RecordEncoder.js.map +1 -1
- package/dist/resources/Table.d.ts +1 -1
- package/dist/resources/Table.js +13 -2
- package/dist/resources/Table.js.map +1 -1
- package/dist/resources/blob.d.ts +6 -0
- package/dist/resources/blob.js +5 -2
- package/dist/resources/blob.js.map +1 -1
- package/dist/resources/databases.js +2 -1
- package/dist/resources/databases.js.map +1 -1
- package/dist/security/jsLoader.d.ts +3 -0
- package/dist/security/jsLoader.js +19 -2
- package/dist/security/jsLoader.js.map +1 -1
- package/dist/security/keys.js +1 -1
- package/dist/security/keys.js.map +1 -1
- package/dist/server/DurableSubscriptionsSession.js +2 -0
- package/dist/server/DurableSubscriptionsSession.js.map +1 -1
- package/dist/server/serverHelpers/serverUtilities.js +2 -2
- package/dist/server/serverHelpers/serverUtilities.js.map +1 -1
- package/dist/utility/environment/systemInformation.d.ts +178 -49
- package/dist/utility/environment/systemInformation.js +359 -219
- package/dist/utility/environment/systemInformation.js.map +1 -1
- package/dist/utility/operation_authorization.js +2 -2
- package/dist/utility/operation_authorization.js.map +1 -1
- package/index.ts +113 -0
- package/package.json +3 -3
- package/resources/DatabaseTransaction.ts +8 -3
- package/resources/RecordEncoder.ts +11 -3
- package/resources/Table.ts +13 -2
- package/resources/blob.ts +7 -2
- package/resources/databases.ts +2 -1
- package/security/jsLoader.ts +17 -5
- package/security/keys.js +1 -1
- package/server/DurableSubscriptionsSession.ts +1 -0
- package/server/serverHelpers/serverUtilities.ts +2 -5
- package/studio/web/assets/{index-C0And10y.js → index-DL0ibcSu.js} +2 -2
- package/studio/web/assets/{index-C0And10y.js.map → index-DL0ibcSu.js.map} +1 -1
- package/studio/web/index.html +1 -1
- package/utility/environment/systemInformation.ts +698 -0
- package/utility/operation_authorization.js +2 -5
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +0 -25
- package/dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js +0 -34
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.d.ts +0 -21
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js +0 -24
- package/dist/dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js.map +0 -1
- package/index.d.ts +0 -56
- package/index.js +0 -41
- package/utility/environment/systemInformation.js +0 -355
|
@@ -26,7 +26,7 @@ const restart = require('../bin/restart.js');
|
|
|
26
26
|
const terms = require('./hdbTerms.ts');
|
|
27
27
|
const { expandOperationsPerms } = require('./operationPermissions.ts');
|
|
28
28
|
const permsTranslator = require('../security/permissionsTranslator.js');
|
|
29
|
-
const systemInformation = require('../utility/environment/systemInformation.
|
|
29
|
+
const { systemInformation } = require('../utility/environment/systemInformation.ts');
|
|
30
30
|
const tokenAuthentication = require('../security/tokenAuthentication.ts');
|
|
31
31
|
const auth = require('../security/auth.ts');
|
|
32
32
|
const configUtils = require('../config/configUtils.js');
|
|
@@ -157,10 +157,7 @@ requiredPermissions.set(restart.restartService.name, new permission(true, []));
|
|
|
157
157
|
requiredPermissions.set(readAuditLog.name, new permission(true, [], terms.OPERATIONS_ENUM.READ_AUDIT_LOG));
|
|
158
158
|
requiredPermissions.set(getBackup.name, new permission(true, [READ_PERM]));
|
|
159
159
|
requiredPermissions.set(schema.cleanupOrphanBlobs.name, new permission(true, []));
|
|
160
|
-
requiredPermissions.set(
|
|
161
|
-
systemInformation.systemInformation.name,
|
|
162
|
-
new permission(true, [], terms.OPERATIONS_ENUM.SYSTEM_INFORMATION)
|
|
163
|
-
);
|
|
160
|
+
requiredPermissions.set(systemInformation.name, new permission(true, [], terms.OPERATIONS_ENUM.SYSTEM_INFORMATION));
|
|
164
161
|
requiredPermissions.set(
|
|
165
162
|
configUtils.getConfiguration.name,
|
|
166
163
|
new permission(true, [], terms.OPERATIONS_ENUM.GET_CONFIGURATION)
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* represents the table size entry for a table
|
|
5
|
-
*/
|
|
6
|
-
class TableSizeObject {
|
|
7
|
-
/**
|
|
8
|
-
* @param {String} schema
|
|
9
|
-
* @param {String} table
|
|
10
|
-
* @param {Number} tableSize - data size of the table in bytes
|
|
11
|
-
* @param {Number} recordCount - number of entries in the table
|
|
12
|
-
* @param {Number} transactionLogSize - number of entries in the transaction log
|
|
13
|
-
* @param {Number} transactionLogRecordCount - data size of the transaction log in bytes
|
|
14
|
-
*/
|
|
15
|
-
constructor(schema, table, tableSize = 0, recordCount = 0, transactionLogSize = 0, transactionLogRecordCount = 0) {
|
|
16
|
-
this.schema = schema;
|
|
17
|
-
this.table = table;
|
|
18
|
-
this.table_size = tableSize;
|
|
19
|
-
this.record_count = recordCount;
|
|
20
|
-
this.transaction_log_size = transactionLogSize;
|
|
21
|
-
this.transaction_log_record_count = transactionLogRecordCount;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = TableSizeObject;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const TableSizeObject = require('./TableSizeObject.js');
|
|
4
|
-
const log = require('../../../../utility/logging/harper_logger.js');
|
|
5
|
-
const { getDatabases } = require('../../../../resources/databases.ts');
|
|
6
|
-
|
|
7
|
-
module.exports = lmdbGetTableSize;
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* calculates the number of entries & data size in bytes for a table & its transaction log
|
|
11
|
-
* @param tableObject
|
|
12
|
-
* @returns {Promise<TableSizeObject>}
|
|
13
|
-
*/
|
|
14
|
-
async function lmdbGetTableSize(tableObject) {
|
|
15
|
-
let tableStats = new TableSizeObject();
|
|
16
|
-
try {
|
|
17
|
-
//get the table record count
|
|
18
|
-
let table = getDatabases()[tableObject.schema]?.[tableObject.name];
|
|
19
|
-
|
|
20
|
-
let dbiStat = table.primaryStore.getStats();
|
|
21
|
-
|
|
22
|
-
//get the txn log record count
|
|
23
|
-
let txnDbiStat = table.auditStore?.getStats();
|
|
24
|
-
|
|
25
|
-
tableStats.schema = tableObject.schema;
|
|
26
|
-
tableStats.table = tableObject.name;
|
|
27
|
-
tableStats.record_count = dbiStat.entryCount;
|
|
28
|
-
tableStats.transaction_log_record_count = txnDbiStat.entryCount;
|
|
29
|
-
} catch (e) {
|
|
30
|
-
log.warn(`unable to stat table dbi due to ${e}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return tableStats;
|
|
34
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export = TableSizeObject;
|
|
2
|
-
/**
|
|
3
|
-
* represents the table size entry for a table
|
|
4
|
-
*/
|
|
5
|
-
declare class TableSizeObject {
|
|
6
|
-
/**
|
|
7
|
-
* @param {String} schema
|
|
8
|
-
* @param {String} table
|
|
9
|
-
* @param {Number} tableSize - data size of the table in bytes
|
|
10
|
-
* @param {Number} recordCount - number of entries in the table
|
|
11
|
-
* @param {Number} transactionLogSize - number of entries in the transaction log
|
|
12
|
-
* @param {Number} transactionLogRecordCount - data size of the transaction log in bytes
|
|
13
|
-
*/
|
|
14
|
-
constructor(schema: string, table: string, tableSize?: number, recordCount?: number, transactionLogSize?: number, transactionLogRecordCount?: number);
|
|
15
|
-
schema: string;
|
|
16
|
-
table: string;
|
|
17
|
-
table_size: number;
|
|
18
|
-
record_count: number;
|
|
19
|
-
transaction_log_size: number;
|
|
20
|
-
transaction_log_record_count: number;
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
/**
|
|
3
|
-
* represents the table size entry for a table
|
|
4
|
-
*/
|
|
5
|
-
class TableSizeObject {
|
|
6
|
-
/**
|
|
7
|
-
* @param {String} schema
|
|
8
|
-
* @param {String} table
|
|
9
|
-
* @param {Number} tableSize - data size of the table in bytes
|
|
10
|
-
* @param {Number} recordCount - number of entries in the table
|
|
11
|
-
* @param {Number} transactionLogSize - number of entries in the transaction log
|
|
12
|
-
* @param {Number} transactionLogRecordCount - data size of the transaction log in bytes
|
|
13
|
-
*/
|
|
14
|
-
constructor(schema, table, tableSize = 0, recordCount = 0, transactionLogSize = 0, transactionLogRecordCount = 0) {
|
|
15
|
-
this.schema = schema;
|
|
16
|
-
this.table = table;
|
|
17
|
-
this.table_size = tableSize;
|
|
18
|
-
this.record_count = recordCount;
|
|
19
|
-
this.transaction_log_size = transactionLogSize;
|
|
20
|
-
this.transaction_log_record_count = transactionLogRecordCount;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
module.exports = TableSizeObject;
|
|
24
|
-
//# sourceMappingURL=TableSizeObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TableSizeObject.js","sourceRoot":"","sources":["../../../../../dataLayer/harperBridge/lmdbBridge/lmdbUtility/TableSizeObject.js"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;GAEG;AACH,MAAM,eAAe;IACpB;;;;;;;OAOG;IACH,YAAY,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,CAAC,EAAE,WAAW,GAAG,CAAC,EAAE,kBAAkB,GAAG,CAAC,EAAE,yBAAyB,GAAG,CAAC;QAC/G,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,kBAAkB,CAAC;QAC/C,IAAI,CAAC,4BAA4B,GAAG,yBAAyB,CAAC;IAC/D,CAAC;CACD;AAED,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC"}
|
package/index.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Resource as ResourceImport } from './resources/Resource.ts';
|
|
2
|
-
import { server as serverImport } from './server/Server.ts';
|
|
3
|
-
import { tables as dbTables, databases as dbDatabases } from './resources/databases.ts';
|
|
4
|
-
import { BlobCreationOptions } from './resources/blob.ts';
|
|
5
|
-
import { Logger } from './utility/logging/logger.ts';
|
|
6
|
-
|
|
7
|
-
export { Resource } from './resources/Resource.ts';
|
|
8
|
-
export type {
|
|
9
|
-
Query,
|
|
10
|
-
Context,
|
|
11
|
-
Session,
|
|
12
|
-
SourceContext,
|
|
13
|
-
SubscriptionRequest,
|
|
14
|
-
RequestTargetOrId,
|
|
15
|
-
} from './resources/ResourceInterface.ts';
|
|
16
|
-
export { ResourceInterface } from './resources/ResourceInterface.ts';
|
|
17
|
-
export type { User } from './security/user.ts';
|
|
18
|
-
export type { RecordObject } from './resources/RecordEncoder.ts';
|
|
19
|
-
export type { IterableEventQueue } from './resources/IterableEventQueue.ts';
|
|
20
|
-
export { RequestTarget } from './resources/RequestTarget.ts';
|
|
21
|
-
export { server } from './server/Server';
|
|
22
|
-
export { tables, databases, type Table } from './resources/databases.ts';
|
|
23
|
-
export type { Attribute } from './resources/Table.ts';
|
|
24
|
-
|
|
25
|
-
export { Scope } from './components/Scope.ts';
|
|
26
|
-
export type { FilesOption, FilesOptionObject } from './components/deriveGlobOptions.ts';
|
|
27
|
-
export type { FileAndURLPathConfig } from './components/Component.ts';
|
|
28
|
-
export { OptionsWatcher, type Config, type ConfigValue } from './components/OptionsWatcher.ts';
|
|
29
|
-
export {
|
|
30
|
-
EntryHandler,
|
|
31
|
-
type BaseEntry,
|
|
32
|
-
type FileEntry,
|
|
33
|
-
type EntryEvent,
|
|
34
|
-
type AddFileEvent,
|
|
35
|
-
type ChangeFileEvent,
|
|
36
|
-
type UnlinkFileEvent,
|
|
37
|
-
type FileEntryEvent,
|
|
38
|
-
type AddDirectoryEvent,
|
|
39
|
-
type UnlinkDirectoryEvent,
|
|
40
|
-
type DirectoryEntryEvent,
|
|
41
|
-
} from './components/EntryHandler.ts';
|
|
42
|
-
|
|
43
|
-
declare const logger: Logger;
|
|
44
|
-
export { type Logger, logger };
|
|
45
|
-
|
|
46
|
-
declare global {
|
|
47
|
-
const tables: typeof dbTables;
|
|
48
|
-
const logger: Logger;
|
|
49
|
-
const databases: typeof dbDatabases;
|
|
50
|
-
const server: typeof serverImport;
|
|
51
|
-
const Resource: typeof ResourceImport;
|
|
52
|
-
const createBlob: (
|
|
53
|
-
source: Uint8Array | NodeJS.ReadableStream | string | Iterable<Uint8Array> | AsyncIterator<Uint8Array>,
|
|
54
|
-
options?: BlobCreationOptions
|
|
55
|
-
) => Blob;
|
|
56
|
-
}
|
package/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const workerThreads = require('node:worker_threads');
|
|
2
|
-
if (!workerThreads.isMainThread) {
|
|
3
|
-
// Prevents server from starting in worker threads if this was directly imported from a non-server user thread
|
|
4
|
-
if (!workerThreads.workerData) workerThreads.workerData = {};
|
|
5
|
-
workerThreads.workerData.noServerStart = true;
|
|
6
|
-
}
|
|
7
|
-
const { globals } = require('./server/threads/threadServer.js');
|
|
8
|
-
|
|
9
|
-
// exported types are needed for parsing as well
|
|
10
|
-
exports.Attribute = undefined;
|
|
11
|
-
exports.Config = undefined;
|
|
12
|
-
exports.ConfigValue = undefined;
|
|
13
|
-
exports.Context = undefined;
|
|
14
|
-
exports.FileAndURLPathConfig = undefined;
|
|
15
|
-
exports.FilesOption = undefined;
|
|
16
|
-
exports.FilesOptionObject = undefined;
|
|
17
|
-
exports.IterableEventQueue = undefined;
|
|
18
|
-
exports.Logger = undefined;
|
|
19
|
-
exports.Query = undefined;
|
|
20
|
-
exports.RecordObject = undefined;
|
|
21
|
-
exports.RequestTarget = undefined;
|
|
22
|
-
exports.RequestTargetOrId = undefined;
|
|
23
|
-
exports.Resource = undefined;
|
|
24
|
-
exports.ResourceInterface = undefined;
|
|
25
|
-
exports.Scope = undefined;
|
|
26
|
-
exports.Session = undefined;
|
|
27
|
-
exports.SourceContext = undefined;
|
|
28
|
-
exports.SubscriptionRequest = undefined;
|
|
29
|
-
exports.Table = undefined;
|
|
30
|
-
exports.User = undefined;
|
|
31
|
-
|
|
32
|
-
// these are all overwritten by the globals, but need to be here so that Node's static
|
|
33
|
-
// exports parser can analyze them
|
|
34
|
-
exports.tables = {};
|
|
35
|
-
exports.databases = {};
|
|
36
|
-
exports.getUser = undefined;
|
|
37
|
-
exports.server = {};
|
|
38
|
-
exports.contentTypes = null;
|
|
39
|
-
exports.threads = [];
|
|
40
|
-
exports.logger = {};
|
|
41
|
-
Object.assign(exports, globals);
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const fs = require('fs-extra');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const si = require('systeminformation');
|
|
6
|
-
const log = require('../logging/harper_logger.js');
|
|
7
|
-
const terms = require('../hdbTerms.ts');
|
|
8
|
-
const lmdbGetTableSize = require('../../dataLayer/harperBridge/lmdbBridge/lmdbUtility/lmdbGetTableSize.js');
|
|
9
|
-
const schemaDescribe = require('../../dataLayer/schemaDescribe.js');
|
|
10
|
-
const { getThreadInfo } = require('../../server/threads/manageThreads.js');
|
|
11
|
-
const env = require('./environmentManager.js');
|
|
12
|
-
env.initSync();
|
|
13
|
-
const { databases } = require('../../resources/databases.ts');
|
|
14
|
-
|
|
15
|
-
//this will hold the system_information which is static to improve performance
|
|
16
|
-
let systemInformationCache = undefined;
|
|
17
|
-
|
|
18
|
-
class SystemInformationRequest {
|
|
19
|
-
constructor(attributes) {
|
|
20
|
-
this.operator = terms.OPERATIONS_ENUM.SYSTEM_INFORMATION;
|
|
21
|
-
this.attributes = attributes;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
class SystemInformationResponse {
|
|
26
|
-
constructor(system, time, cpu, memory, disk, network, harperdbProcesses) {
|
|
27
|
-
this.system = system;
|
|
28
|
-
this.time = time;
|
|
29
|
-
this.cpu = cpu;
|
|
30
|
-
this.memory = memory;
|
|
31
|
-
this.disk = disk;
|
|
32
|
-
this.network = network;
|
|
33
|
-
this.harperdb_processes = harperdbProcesses;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = {
|
|
38
|
-
getHDBProcessInfo,
|
|
39
|
-
getNetworkInfo,
|
|
40
|
-
getDiskInfo,
|
|
41
|
-
getMemoryInfo,
|
|
42
|
-
getCPUInfo,
|
|
43
|
-
getTimeInfo,
|
|
44
|
-
getSystemInformation,
|
|
45
|
-
systemInformation,
|
|
46
|
-
getTableSize,
|
|
47
|
-
getMetrics,
|
|
48
|
-
SystemInformationRequest,
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* executes the time function to return the time info for the system
|
|
53
|
-
* @returns {si.Systeminformation.TimeData}
|
|
54
|
-
*/
|
|
55
|
-
function getTimeInfo() {
|
|
56
|
-
return si.time();
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* executes cpu related functions
|
|
61
|
-
* @returns {Promise<{}|Pick<si.Systeminformation.CpuData, "manufacturer" | "brand" | "vendor" | "speed" | "cores" | "physicalCores" | "processors">>}
|
|
62
|
-
*/
|
|
63
|
-
async function getCPUInfo() {
|
|
64
|
-
try {
|
|
65
|
-
// eslint-disable-next-line no-unused-vars
|
|
66
|
-
let { family, model, stepping, revision, voltage, speedmin, speedmax, governor, socket, cache, ...cpuInfo } =
|
|
67
|
-
await si.cpu();
|
|
68
|
-
cpuInfo.cpu_speed = await si.cpuCurrentSpeed();
|
|
69
|
-
|
|
70
|
-
let {
|
|
71
|
-
// eslint-disable-next-line no-unused-vars
|
|
72
|
-
rawCurrentload,
|
|
73
|
-
cpus,
|
|
74
|
-
...cpuCurrentLoad
|
|
75
|
-
} = await si.currentLoad();
|
|
76
|
-
cpuCurrentLoad.cpus = [];
|
|
77
|
-
cpus.forEach((cpuData) => {
|
|
78
|
-
// eslint-disable-next-line no-unused-vars
|
|
79
|
-
let { rawLoad, rawLoadIdle, rawLoadIrq, rawLoadNice, rawLoadSystem, rawLoadUser, ...cpuLoad } = cpuData;
|
|
80
|
-
cpuCurrentLoad.cpus.push(cpuLoad);
|
|
81
|
-
});
|
|
82
|
-
cpuInfo.current_load = cpuCurrentLoad;
|
|
83
|
-
return cpuInfo;
|
|
84
|
-
} catch (e) {
|
|
85
|
-
log.error(`error in getCPUInfo: ${e}`);
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* fetches information related memory
|
|
92
|
-
* @returns {Promise<{}|Pick<si.Systeminformation.MemData, "total" | "free" | "used" | "active" | "available" | "swaptotal" | "swapused" | "swapfree">>}
|
|
93
|
-
*/
|
|
94
|
-
async function getMemoryInfo() {
|
|
95
|
-
try {
|
|
96
|
-
// eslint-disable-next-line no-unused-vars
|
|
97
|
-
let { buffers, cached, slab, buffcache, ...memInfo } = await si.mem();
|
|
98
|
-
return Object.assign(memInfo, process.memoryUsage());
|
|
99
|
-
} catch (e) {
|
|
100
|
-
log.error(`error in getMemoryInfo: ${e}`);
|
|
101
|
-
return {};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* searches for & returns the processes for hdb core
|
|
107
|
-
* @returns {Promise<{core: []}>}
|
|
108
|
-
*/
|
|
109
|
-
async function getHDBProcessInfo() {
|
|
110
|
-
let harperdbProcesses = {
|
|
111
|
-
core: [],
|
|
112
|
-
};
|
|
113
|
-
try {
|
|
114
|
-
let processes = await si.processes();
|
|
115
|
-
|
|
116
|
-
let hdbPid;
|
|
117
|
-
try {
|
|
118
|
-
hdbPid = Number.parseInt(
|
|
119
|
-
await fs.readFile(path.join(env.get(terms.CONFIG_PARAMS.ROOTPATH), terms.HDB_PID_FILE), 'utf8')
|
|
120
|
-
);
|
|
121
|
-
} catch (err) {
|
|
122
|
-
if (err.code === terms.NODE_ERROR_CODES.ENOENT) {
|
|
123
|
-
log.warn(
|
|
124
|
-
`Unable to locate 'hdb.pid' file, try stopping and starting Harper. This could be because Harper is not running.`
|
|
125
|
-
);
|
|
126
|
-
} else {
|
|
127
|
-
throw err;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
processes.list.forEach((p) => {
|
|
132
|
-
if (p.pid === hdbPid) {
|
|
133
|
-
harperdbProcesses.core.push(p);
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
for (const hdbP of harperdbProcesses.core) {
|
|
138
|
-
for (const p of processes.list) {
|
|
139
|
-
if (p.pid === hdbP.parentPid && (p.name === 'PM2' || p.command === 'PM2')) {
|
|
140
|
-
hdbP.parent = 'PM2';
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return harperdbProcesses;
|
|
146
|
-
} catch (e) {
|
|
147
|
-
log.error(`error in getHDBProcessInfo: ${e}`);
|
|
148
|
-
return harperdbProcesses;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* gets disk related info & stats
|
|
154
|
-
* @returns {Promise<{}>}
|
|
155
|
-
*/
|
|
156
|
-
async function getDiskInfo() {
|
|
157
|
-
let disk = {};
|
|
158
|
-
try {
|
|
159
|
-
if (!env.get(terms.CONFIG_PARAMS.OPERATIONSAPI_SYSINFO_DISK)) return disk;
|
|
160
|
-
// eslint-disable-next-line no-unused-vars
|
|
161
|
-
let { rIO_sec, wIO_sec, tIO_sec, ms, ...diskIo } = await si.disksIO();
|
|
162
|
-
disk.io = diskIo;
|
|
163
|
-
|
|
164
|
-
// eslint-disable-next-line no-unused-vars
|
|
165
|
-
let { rxSec, txSec, wxSec, ...fsStats } = await si.fsStats();
|
|
166
|
-
disk.read_write = fsStats;
|
|
167
|
-
|
|
168
|
-
disk.size = await si.fsSize();
|
|
169
|
-
|
|
170
|
-
return disk;
|
|
171
|
-
} catch (e) {
|
|
172
|
-
log.error(`error in getDiskInfo: ${e}`);
|
|
173
|
-
return disk;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* gets networking & connection information & stats
|
|
179
|
-
* @returns {Promise<{interfaces: [], default_interface: null, stats: [], latency: {}, connections: []}>}
|
|
180
|
-
*/
|
|
181
|
-
async function getNetworkInfo() {
|
|
182
|
-
let network = {
|
|
183
|
-
default_interface: null,
|
|
184
|
-
latency: {},
|
|
185
|
-
interfaces: [],
|
|
186
|
-
stats: [],
|
|
187
|
-
connections: [],
|
|
188
|
-
};
|
|
189
|
-
try {
|
|
190
|
-
if (!env.get(terms.CONFIG_PARAMS.OPERATIONSAPI_SYSINFO_NETWORK)) return network;
|
|
191
|
-
network.default_interface = await si.networkInterfaceDefault();
|
|
192
|
-
|
|
193
|
-
network.latency = await si.inetChecksite('google.com');
|
|
194
|
-
|
|
195
|
-
let nInterfaces = await si.networkInterfaces();
|
|
196
|
-
nInterfaces.forEach((_interface) => {
|
|
197
|
-
// eslint-disable-next-line no-unused-vars
|
|
198
|
-
let { internal, virtual, mtu, dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState, carrierChanges, ...networkInt } =
|
|
199
|
-
_interface;
|
|
200
|
-
network.interfaces.push(networkInt);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
let stats = await si.networkStats();
|
|
204
|
-
stats.forEach((nStat) => {
|
|
205
|
-
// eslint-disable-next-line no-unused-vars
|
|
206
|
-
let { rxSec, txSec, ms, ...stat } = nStat;
|
|
207
|
-
network.stats.push(stat);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return network;
|
|
211
|
-
} catch (e) {
|
|
212
|
-
log.error(`error in getNetworkInfo: ${e}`);
|
|
213
|
-
return network;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* gets system information
|
|
219
|
-
* @returns {Promise<Pick<si.Systeminformation.OsData, "platform" | "distro" | "release" | "codename" | "kernel" | "arch" | "hostname">|{}>}
|
|
220
|
-
*/
|
|
221
|
-
async function getSystemInformation() {
|
|
222
|
-
if (systemInformationCache !== undefined) {
|
|
223
|
-
return systemInformationCache;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
let system_info = {};
|
|
227
|
-
try {
|
|
228
|
-
// eslint-disable-next-line no-unused-vars
|
|
229
|
-
let { codepage, logofile, serial, build, servicepack, uefi, ...sysInfo } = await si.osInfo();
|
|
230
|
-
system_info = sysInfo;
|
|
231
|
-
let versions = await si.versions('node, npm');
|
|
232
|
-
system_info.node_version = versions.node;
|
|
233
|
-
system_info.npm_version = versions.npm;
|
|
234
|
-
|
|
235
|
-
systemInformationCache = system_info;
|
|
236
|
-
return systemInformationCache;
|
|
237
|
-
} catch (e) {
|
|
238
|
-
log.error(`error in getSystemInformation: ${e}`);
|
|
239
|
-
return system_info;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
async function getTableSize() {
|
|
244
|
-
//get details for all tables
|
|
245
|
-
let tableSizes = [];
|
|
246
|
-
let allSchemas = await schemaDescribe.describeAll();
|
|
247
|
-
for (const tables of Object.values(allSchemas)) {
|
|
248
|
-
for (const tableData of Object.values(tables)) {
|
|
249
|
-
tableSizes.push(await lmdbGetTableSize(tableData));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return tableSizes;
|
|
254
|
-
}
|
|
255
|
-
async function getMetrics() {
|
|
256
|
-
let schemaStats = {};
|
|
257
|
-
for (let schemaName in databases) {
|
|
258
|
-
let dbStats = (schemaStats[schemaName] = {});
|
|
259
|
-
let tableStats = (dbStats.tables = {});
|
|
260
|
-
for (let tableName in databases[schemaName]) {
|
|
261
|
-
try {
|
|
262
|
-
let table = databases[schemaName][tableName];
|
|
263
|
-
if (!dbStats.readers) {
|
|
264
|
-
Object.assign(dbStats, table.primaryStore.rootStore.getStats());
|
|
265
|
-
delete dbStats.root;
|
|
266
|
-
dbStats.readers = table.primaryStore.rootStore
|
|
267
|
-
.readerList()
|
|
268
|
-
.split(/\n\s+/)
|
|
269
|
-
.slice(1)
|
|
270
|
-
.map((line) => {
|
|
271
|
-
const [pid, thread, txnid] = line.trim().split(' ');
|
|
272
|
-
return { pid, thread, txnid };
|
|
273
|
-
});
|
|
274
|
-
if (table.auditStore) {
|
|
275
|
-
const { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages } =
|
|
276
|
-
table.auditStore.getStats();
|
|
277
|
-
dbStats.audit = { treeDepth, treeBranchPageCount, treeLeafPageCount, entryCount, overflowPages };
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
let tableFullStats = table.primaryStore.getStats();
|
|
281
|
-
let tablePrunedStats = {};
|
|
282
|
-
for (let storeKey of ['treeDepth', 'treeBranchPageCount', 'treeLeafPageCount', 'entryCount', 'overflowPages']) {
|
|
283
|
-
tablePrunedStats[storeKey] = tableFullStats[storeKey];
|
|
284
|
-
}
|
|
285
|
-
tableStats[tableName] = tablePrunedStats;
|
|
286
|
-
} catch (error) {
|
|
287
|
-
// if a schema no longer exists, don't want to throw an error
|
|
288
|
-
log.notify(`Error getting stats for table ${tableName}: ${error}`);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
return schemaStats;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
*
|
|
297
|
-
* @param {SystemInformationRequest} systemInfoReq
|
|
298
|
-
* @returns {Promise<SystemInformationResponse>}
|
|
299
|
-
*/
|
|
300
|
-
async function systemInformation(systemInfoReq) {
|
|
301
|
-
let response = new SystemInformationResponse();
|
|
302
|
-
if (!Array.isArray(systemInfoReq.attributes) || systemInfoReq.attributes.length === 0) {
|
|
303
|
-
response.system = await getSystemInformation();
|
|
304
|
-
response.time = getTimeInfo();
|
|
305
|
-
response.cpu = await getCPUInfo();
|
|
306
|
-
response.memory = await getMemoryInfo();
|
|
307
|
-
response.disk = await getDiskInfo();
|
|
308
|
-
response.network = await getNetworkInfo();
|
|
309
|
-
response.harperdb_processes = await getHDBProcessInfo();
|
|
310
|
-
response.table_size = await getTableSize();
|
|
311
|
-
response.metrics = await getMetrics();
|
|
312
|
-
response.threads = await getThreadInfo();
|
|
313
|
-
return response;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
for (let attr of systemInfoReq.attributes) {
|
|
317
|
-
switch (attr) {
|
|
318
|
-
case 'system':
|
|
319
|
-
response.system = await getSystemInformation();
|
|
320
|
-
break;
|
|
321
|
-
case 'time':
|
|
322
|
-
response.time = getTimeInfo();
|
|
323
|
-
break;
|
|
324
|
-
case 'cpu':
|
|
325
|
-
response.cpu = await getCPUInfo();
|
|
326
|
-
break;
|
|
327
|
-
case 'memory':
|
|
328
|
-
response.memory = await getMemoryInfo();
|
|
329
|
-
break;
|
|
330
|
-
case 'disk':
|
|
331
|
-
response.disk = await getDiskInfo();
|
|
332
|
-
break;
|
|
333
|
-
case 'network':
|
|
334
|
-
response.network = await getNetworkInfo();
|
|
335
|
-
break;
|
|
336
|
-
case 'harperdb_processes':
|
|
337
|
-
response.harperdb_processes = await getHDBProcessInfo();
|
|
338
|
-
break;
|
|
339
|
-
case 'table_size':
|
|
340
|
-
response.table_size = await getTableSize();
|
|
341
|
-
break;
|
|
342
|
-
case 'database_metrics':
|
|
343
|
-
case 'metrics':
|
|
344
|
-
response.metrics = await getMetrics();
|
|
345
|
-
break;
|
|
346
|
-
case 'threads':
|
|
347
|
-
response.threads = await getThreadInfo();
|
|
348
|
-
break;
|
|
349
|
-
default:
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return response;
|
|
355
|
-
}
|