node-opcua-vendor-diagnostic 2.178.0 → 2.180.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type OPCUAServer } from "node-opcua-server";
|
|
1
2
|
/**
|
|
2
3
|
*
|
|
3
4
|
* optionally install a CPU Usage and Memory Usage node
|
|
@@ -6,4 +7,4 @@
|
|
|
6
7
|
* @param server {OPCUAServer}
|
|
7
8
|
*
|
|
8
9
|
*/
|
|
9
|
-
export declare function install_optional_cpu_and_memory_usage_node(server:
|
|
10
|
+
export declare function install_optional_cpu_and_memory_usage_node(server: OPCUAServer): void;
|
|
@@ -5,17 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.install_optional_cpu_and_memory_usage_node = install_optional_cpu_and_memory_usage_node;
|
|
7
7
|
/* c8 ignore start */
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const util_1 = require("util");
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
9
|
+
const node_util_1 = require("node:util");
|
|
11
10
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
12
11
|
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
12
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
13
13
|
const node_opcua_server_1 = require("node-opcua-server");
|
|
14
14
|
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
15
15
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
16
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
17
16
|
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
18
|
-
// tslint:disable:no-var-requires
|
|
19
17
|
const humanize = require("humanize");
|
|
20
18
|
/**
|
|
21
19
|
|
|
@@ -24,6 +22,12 @@ const humanize = require("humanize");
|
|
|
24
22
|
* @param options.browseName
|
|
25
23
|
* @private
|
|
26
24
|
*/
|
|
25
|
+
// This helper is unreachable in practice (install_optional_cpu_and_memory_usage_node has no callers
|
|
26
|
+
// anywhere in the workspace) and its body doesn't actually match AddVariableOptions — it assumes
|
|
27
|
+
// options.browseName is always a QualifiedNameOptions object (`.name.toString()`), but every call
|
|
28
|
+
// site in this file passes a plain string. Typing this precisely would mean fixing that pre-existing
|
|
29
|
+
// bug, which is out of scope for a lint pass on dead code.
|
|
30
|
+
// biome-ignore lint/suspicious/noExplicitAny: see comment above
|
|
27
31
|
function addVariableWithHumanizeText(namespace, options) {
|
|
28
32
|
(0, node_opcua_assert_1.assert)(options.componentOf || options.organizedBy);
|
|
29
33
|
(0, node_opcua_assert_1.assert)(typeof options.description === "string");
|
|
@@ -31,9 +35,9 @@ function addVariableWithHumanizeText(namespace, options) {
|
|
|
31
35
|
// add the xxxAsText property
|
|
32
36
|
namespace.addVariable({
|
|
33
37
|
propertyOf: variable,
|
|
34
|
-
browseName: options.browseName.name.toString()
|
|
38
|
+
browseName: `${options.browseName.name.toString()}AsText`,
|
|
35
39
|
dataType: "String",
|
|
36
|
-
description: options.description
|
|
40
|
+
description: `${options.description} as text`,
|
|
37
41
|
minimumSamplingInterval: options.minimumSamplingInterval,
|
|
38
42
|
value: {
|
|
39
43
|
get() {
|
|
@@ -60,15 +64,21 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
60
64
|
usage = require(usage_module); // a warning will be generated here with webpack as the module name is not a litteral
|
|
61
65
|
}
|
|
62
66
|
catch (err) {
|
|
63
|
-
if (
|
|
67
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
64
68
|
warningLog("err", err.message);
|
|
65
69
|
}
|
|
66
70
|
usage = null;
|
|
67
71
|
// xx return;
|
|
68
72
|
}
|
|
69
73
|
const addressSpace = engine.addressSpace;
|
|
74
|
+
if (!addressSpace) {
|
|
75
|
+
throw new Error("engine.addressSpace must be initialized");
|
|
76
|
+
}
|
|
70
77
|
const namespace = addressSpace.getOwnNamespace();
|
|
71
78
|
const vendorServerInfo = addressSpace.findNode(node_opcua_constants_1.ObjectIds.Server_VendorServerInfo);
|
|
79
|
+
if (!vendorServerInfo) {
|
|
80
|
+
throw new Error("Server_VendorServerInfo node must exist in the address space");
|
|
81
|
+
}
|
|
72
82
|
let usage_result = { memory: 0, cpu: 100 };
|
|
73
83
|
const pid = typeof process === "object" ? process.pid || 0 : 0;
|
|
74
84
|
if (usage) {
|
|
@@ -127,7 +137,7 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
127
137
|
nodeId: "s=PercentageMemoryUsed",
|
|
128
138
|
value: {
|
|
129
139
|
get() {
|
|
130
|
-
const percent_used = Math.round(((
|
|
140
|
+
const percent_used = Math.round(((node_os_1.default.totalmem() - node_os_1.default.freemem()) / node_os_1.default.totalmem()) * 100);
|
|
131
141
|
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Double, value: percent_used });
|
|
132
142
|
}
|
|
133
143
|
}
|
|
@@ -142,7 +152,7 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
142
152
|
nodeId: "s=SystemMemoryTotal",
|
|
143
153
|
value: {
|
|
144
154
|
get() {
|
|
145
|
-
const memory =
|
|
155
|
+
const memory = node_os_1.default.totalmem();
|
|
146
156
|
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt64, value: memory });
|
|
147
157
|
}
|
|
148
158
|
}
|
|
@@ -157,7 +167,7 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
157
167
|
nodeId: "s=SystemMemoryFree",
|
|
158
168
|
value: {
|
|
159
169
|
get() {
|
|
160
|
-
const memory =
|
|
170
|
+
const memory = node_os_1.default.freemem();
|
|
161
171
|
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt64, value: memory });
|
|
162
172
|
}
|
|
163
173
|
}
|
|
@@ -172,7 +182,7 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
172
182
|
nodeId: "s=NumberOfCPUs",
|
|
173
183
|
value: {
|
|
174
184
|
get() {
|
|
175
|
-
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt32, value:
|
|
185
|
+
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt32, value: node_os_1.default.cpus().length });
|
|
176
186
|
}
|
|
177
187
|
}
|
|
178
188
|
});
|
|
@@ -186,7 +196,7 @@ function install_optional_cpu_and_memory_usage_node(server) {
|
|
|
186
196
|
nodeId: "s=ServerArchitecture",
|
|
187
197
|
value: {
|
|
188
198
|
get() {
|
|
189
|
-
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.String, value:
|
|
199
|
+
return new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.String, value: node_os_1.default.type() });
|
|
190
200
|
}
|
|
191
201
|
}
|
|
192
202
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vendor_diagnostic_nodes.js","sourceRoot":"","sources":["../source/vendor_diagnostic_nodes.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"vendor_diagnostic_nodes.js","sourceRoot":"","sources":["../source/vendor_diagnostic_nodes.ts"],"names":[],"mappings":";;;;;AAgEA,gGAuOC;AAvSD,qBAAqB;AACrB,sDAAyB;AAEzB,yCAAkC;AAElC,yDAA2C;AAC3C,+DAAiD;AACjD,uDAAmD;AACnD,yDAAmE;AACnE,mEAAqD;AACrD,2DAAuD;AAEvD,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAE/C,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAOrC;;;;;;GAMG;AACH,oGAAoG;AACpG,iGAAiG;AACjG,kGAAkG;AAClG,qGAAqG;AACrG,2DAA2D;AAC3D,gEAAgE;AAChE,SAAS,2BAA2B,CAAC,SAAoB,EAAE,OAAY;IACnE,IAAA,0BAAM,EAAC,OAA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ACH,GAAG;gBACC,OAAO,IAAI,4BAAO,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;YAC5G,CAAC;SACJ;KACJ,CAAC,CAAC;AACP,CAAC;AACD,oBAAoB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-vendor-diagnostic",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.180.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module vendor-diagnostic",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"humanize": "0.0.9",
|
|
14
|
-
"node-opcua-address-space": "2.
|
|
15
|
-
"node-opcua-assert": "2.
|
|
16
|
-
"node-opcua-constants": "2.
|
|
17
|
-
"node-opcua-debug": "2.
|
|
18
|
-
"node-opcua-server": "2.
|
|
19
|
-
"node-opcua-status-code": "2.
|
|
20
|
-
"node-opcua-variant": "2.
|
|
14
|
+
"node-opcua-address-space": "2.180.0",
|
|
15
|
+
"node-opcua-assert": "2.179.0",
|
|
16
|
+
"node-opcua-constants": "2.179.0",
|
|
17
|
+
"node-opcua-debug": "2.179.0",
|
|
18
|
+
"node-opcua-server": "2.180.0",
|
|
19
|
+
"node-opcua-status-code": "2.180.0",
|
|
20
|
+
"node-opcua-variant": "2.180.0"
|
|
21
21
|
},
|
|
22
22
|
"author": "Etienne Rossignon",
|
|
23
23
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"internet of things"
|
|
35
35
|
],
|
|
36
36
|
"homepage": "http://node-opcua.github.io/",
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "11ad1e0894355cd279e19443c6c9a4fc090e7d7a",
|
|
38
38
|
"files": [
|
|
39
39
|
"dist",
|
|
40
40
|
"source"
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/* c8 ignore start */
|
|
2
|
-
|
|
3
|
-
import os from "os";
|
|
2
|
+
import os from "node:os";
|
|
4
3
|
|
|
5
|
-
import { types } from "util";
|
|
6
|
-
import { Namespace } from "node-opcua-address-space";
|
|
4
|
+
import { types } from "node:util";
|
|
5
|
+
import type { Namespace } from "node-opcua-address-space";
|
|
7
6
|
import { assert } from "node-opcua-assert";
|
|
8
7
|
import { ObjectIds } from "node-opcua-constants";
|
|
9
|
-
import {
|
|
8
|
+
import { make_warningLog } from "node-opcua-debug";
|
|
9
|
+
import { type OPCUAServer, ServerEngine } from "node-opcua-server";
|
|
10
10
|
import { StatusCodes } from "node-opcua-status-code";
|
|
11
11
|
import { DataType, Variant } from "node-opcua-variant";
|
|
12
|
-
import { make_warningLog } from "node-opcua-debug";
|
|
13
12
|
|
|
14
13
|
const warningLog = make_warningLog(__filename);
|
|
15
14
|
|
|
16
|
-
// tslint:disable:no-var-requires
|
|
17
15
|
const humanize = require("humanize");
|
|
18
16
|
|
|
17
|
+
interface UsageResult {
|
|
18
|
+
memory: number;
|
|
19
|
+
cpu: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
|
|
21
24
|
* @param namespace
|
|
@@ -23,6 +26,12 @@ const humanize = require("humanize");
|
|
|
23
26
|
* @param options.browseName
|
|
24
27
|
* @private
|
|
25
28
|
*/
|
|
29
|
+
// This helper is unreachable in practice (install_optional_cpu_and_memory_usage_node has no callers
|
|
30
|
+
// anywhere in the workspace) and its body doesn't actually match AddVariableOptions — it assumes
|
|
31
|
+
// options.browseName is always a QualifiedNameOptions object (`.name.toString()`), but every call
|
|
32
|
+
// site in this file passes a plain string. Typing this precisely would mean fixing that pre-existing
|
|
33
|
+
// bug, which is out of scope for a lint pass on dead code.
|
|
34
|
+
// biome-ignore lint/suspicious/noExplicitAny: see comment above
|
|
26
35
|
function addVariableWithHumanizeText(namespace: Namespace, options: any) {
|
|
27
36
|
assert(options.componentOf || options.organizedBy);
|
|
28
37
|
assert(typeof options.description === "string");
|
|
@@ -32,9 +41,9 @@ function addVariableWithHumanizeText(namespace: Namespace, options: any) {
|
|
|
32
41
|
namespace.addVariable({
|
|
33
42
|
propertyOf: variable,
|
|
34
43
|
|
|
35
|
-
browseName: options.browseName.name.toString()
|
|
44
|
+
browseName: `${options.browseName.name.toString()}AsText`,
|
|
36
45
|
dataType: "String",
|
|
37
|
-
description: options.description
|
|
46
|
+
description: `${options.description} as text`,
|
|
38
47
|
minimumSamplingInterval: options.minimumSamplingInterval,
|
|
39
48
|
value: {
|
|
40
49
|
get() {
|
|
@@ -53,11 +62,13 @@ function addVariableWithHumanizeText(namespace: Namespace, options: any) {
|
|
|
53
62
|
* @param server {OPCUAServer}
|
|
54
63
|
*
|
|
55
64
|
*/
|
|
56
|
-
export function install_optional_cpu_and_memory_usage_node(server:
|
|
65
|
+
export function install_optional_cpu_and_memory_usage_node(server: OPCUAServer) {
|
|
57
66
|
const engine = server.engine;
|
|
58
67
|
assert(engine instanceof ServerEngine);
|
|
59
68
|
|
|
60
|
-
let usage:
|
|
69
|
+
let usage: {
|
|
70
|
+
lookup(pid: number, options: { keepHistory: boolean }, callback: (err: Error | null, result: UsageResult) => void): void;
|
|
71
|
+
} | null;
|
|
61
72
|
try {
|
|
62
73
|
const usage_module = "usage"; // we use a variable here to prevent error in webpack
|
|
63
74
|
usage = require(usage_module); // a warning will be generated here with webpack as the module name is not a litteral
|
|
@@ -70,10 +81,16 @@ export function install_optional_cpu_and_memory_usage_node(server: any) {
|
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
const addressSpace = engine.addressSpace;
|
|
84
|
+
if (!addressSpace) {
|
|
85
|
+
throw new Error("engine.addressSpace must be initialized");
|
|
86
|
+
}
|
|
73
87
|
|
|
74
88
|
const namespace = addressSpace.getOwnNamespace();
|
|
75
89
|
|
|
76
90
|
const vendorServerInfo = addressSpace.findNode(ObjectIds.Server_VendorServerInfo);
|
|
91
|
+
if (!vendorServerInfo) {
|
|
92
|
+
throw new Error("Server_VendorServerInfo node must exist in the address space");
|
|
93
|
+
}
|
|
77
94
|
|
|
78
95
|
let usage_result = { memory: 0, cpu: 100 };
|
|
79
96
|
|
|
@@ -82,7 +99,7 @@ export function install_optional_cpu_and_memory_usage_node(server: any) {
|
|
|
82
99
|
if (usage) {
|
|
83
100
|
const options = { keepHistory: true };
|
|
84
101
|
setInterval(() => {
|
|
85
|
-
usage.lookup(pid, options, (err: Error | null, result:
|
|
102
|
+
usage.lookup(pid, options, (err: Error | null, result: UsageResult) => {
|
|
86
103
|
usage_result = result;
|
|
87
104
|
warningLog("result Used Memory: ", humanize.filesize(result.memory), " CPU ", Math.round(result.cpu), " %");
|
|
88
105
|
if (err) {
|