From a9a2914b882cc992f0bea9801167b831f5b59e7f Mon Sep 17 00:00:00 2001 From: addievo Date: Thu, 26 Oct 2023 18:38:42 +1100 Subject: [PATCH] feat: added nodes domain stats to `agent status` command [ci skip] --- package-lock.json | 8 ++++---- package.json | 2 +- src/agent/CommandStatus.ts | 4 ++++ tests/agent/status.test.ts | 6 ++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fd7e6627..5f6811c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,7 @@ "nexpect": "^0.6.0", "node-gyp-build": "^4.4.0", "nodemon": "^3.0.1", - "polykey": "^1.2.1-alpha.27", + "polykey": "^1.2.1-alpha.29", "prettier": "^3.0.0", "shelljs": "^0.8.5", "shx": "^0.3.4", @@ -7469,9 +7469,9 @@ } }, "node_modules/polykey": { - "version": "1.2.1-alpha.27", - "resolved": "https://registry.npmjs.org/polykey/-/polykey-1.2.1-alpha.27.tgz", - "integrity": "sha512-LUNKgvgNZH4cIl/egJj/LgIqPYhlN8zAhNlhPAyRg/zUMJeeeR7noevje/c+OJ4oXx0PjRvgV8ljJ710mAcGSA==", + "version": "1.2.1-alpha.29", + "resolved": "https://registry.npmjs.org/polykey/-/polykey-1.2.1-alpha.29.tgz", + "integrity": "sha512-bAsJEVtey2xxlDbHBufmLtpjVvHKwkkrxuGtAB6YOhR5hIDkJb+9Qu+SrE6El2uqBsSqwge37AA+8e6y9H66fw==", "dev": true, "dependencies": { "@matrixai/async-cancellable": "^1.1.1", diff --git a/package.json b/package.json index d830742d..4b27f09a 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "@matrixai/errors": "^1.2.0", "@matrixai/logger": "^3.1.0", "commander": "^8.3.0", - "polykey": "^1.2.1-alpha.27", + "polykey": "^1.2.1-alpha.29", "threads": "^1.6.5", "@swc/core": "1.3.82", "@swc/jest": "^0.2.29", diff --git a/src/agent/CommandStatus.ts b/src/agent/CommandStatus.ts index 058f14ac..971e3286 100644 --- a/src/agent/CommandStatus.ts +++ b/src/agent/CommandStatus.ts @@ -17,6 +17,7 @@ class CommandStatus extends CommandPolykey { const { default: PolykeyClient } = await import( 'polykey/dist/PolykeyClient' ); + const { getUnixtime } = await import('polykey/dist/utils/utils'); const clientStatus = await binProcessors.processClientStatus( options.nodePath, options.nodeId, @@ -79,6 +80,9 @@ class CommandStatus extends CommandPolykey { clientPort: response.clientPort, agentHost: response.agentHost, agentPort: response.agentPort, + upTime: getUnixtime() - response.startTime, + connectionsActive: response.connectionsActive, + nodesTotal: response.nodesTotal, }, }), ); diff --git a/tests/agent/status.test.ts b/tests/agent/status.test.ts index d57ed0dc..90159f3c 100644 --- a/tests/agent/status.test.ts +++ b/tests/agent/status.test.ts @@ -179,6 +179,9 @@ describe('status', () => { clientPort: statusInfo.data.clientPort, agentHost: statusInfo.data.agentHost, agentPort: statusInfo.data.agentPort, + upTime: expect.any(Number), + connectionsActive: expect.any(Number), + nodesTotal: expect.any(Number), }); }); testUtils.testIf( @@ -227,6 +230,9 @@ describe('status', () => { clientPort: statusInfo.data.clientPort, agentHost: statusInfo.data.agentHost, agentPort: statusInfo.data.agentPort, + upTime: expect.any(Number), + connectionsActive: expect.any(Number), + nodesTotal: expect.any(Number), }); }); });