18 Commits

Author SHA1 Message Date
057a0a329e 1.0.17 2021-12-06 20:14:30 +01:00
e53bebf7a1 fix(core): update 2021-12-06 20:14:30 +01:00
c4f5e9338a 1.0.16 2021-08-19 19:22:30 +02:00
dad2bc26fc fix(core): update 2021-08-19 19:22:29 +02:00
29609eb5ba 1.0.15 2021-08-19 17:29:16 +02:00
0292d9bc13 fix(core): update 2021-08-19 17:29:15 +02:00
69af53a30a 1.0.14 2021-08-15 13:45:33 +02:00
121bfdad43 fix(core): update 2021-08-15 13:45:32 +02:00
f96ed80be0 1.0.13 2021-08-14 22:47:31 +02:00
ce74c3da40 fix(core): update 2021-08-14 22:47:31 +02:00
c108c00963 1.0.12 2021-08-14 21:42:25 +02:00
25de5d5874 fix(core): update 2021-08-14 21:42:25 +02:00
9822d470e3 1.0.11 2021-08-14 21:41:06 +02:00
a425ed64c3 fix(core): update 2021-08-14 21:41:06 +02:00
2eb4bc5697 1.0.10 2021-08-14 21:37:53 +02:00
dd46f0d90b fix(core): update 2021-08-14 21:37:52 +02:00
0972f1c64d 1.0.9 2021-08-14 21:31:50 +02:00
22b181a7a0 fix(core): update 2021-08-14 21:31:49 +02:00
4 changed files with 28 additions and 51 deletions

60
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@pushrocks/smartmetrics",
"version": "1.0.8",
"version": "1.0.17",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@pushrocks/smartmetrics",
"version": "1.0.8",
"version": "1.0.17",
"license": "MIT",
"dependencies": {
"@pushrocks/smartdelay": "^2.0.13",
@ -17,7 +17,7 @@
"prom-client": "^13.2.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbuild": "^2.1.26",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",
@ -1822,38 +1822,24 @@
}
},
"node_modules/@gitzone/tsbuild": {
"version": "2.1.25",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.25.tgz",
"integrity": "sha512-KtesoQEm96x0/x1800R3pcj06RcYTdqwBhG9oje+jQW4qZs/bnUirWZXkRMSLAK92cVm899KzZtYkq/fKga2+A==",
"version": "2.1.26",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.26.tgz",
"integrity": "sha512-FE0cjdAyzTR+Rr7pHULTF5rHiCW+FFnEHuV4kP7pdrHzl5oFZTUQ3uqEFEgmsrV6a0gzNwKgr/MfnVO/3sUrdw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@pushrocks/early": "^3.0.6",
"@pushrocks/smartcli": "^3.0.12",
"@pushrocks/smartfile": "^8.0.0",
"@pushrocks/smartlog": "^2.0.36",
"@pushrocks/smartcli": "^3.0.14",
"@pushrocks/smartfile": "^8.0.10",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.6",
"typescript": "^3.9.7"
"@pushrocks/smartpromise": "^3.1.6",
"typescript": "^4.3.5"
},
"bin": {
"tsbuild": "cli.js"
}
},
"node_modules/@gitzone/tsbuild/node_modules/typescript": {
"version": "3.9.10",
"resolved": "https://verdaccio.lossless.one/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/@gitzone/tsbundle": {
"version": "1.0.84",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbundle/-/tsbundle-1.0.84.tgz",
@ -16032,26 +16018,18 @@
}
},
"@gitzone/tsbuild": {
"version": "2.1.25",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.25.tgz",
"integrity": "sha512-KtesoQEm96x0/x1800R3pcj06RcYTdqwBhG9oje+jQW4qZs/bnUirWZXkRMSLAK92cVm899KzZtYkq/fKga2+A==",
"version": "2.1.26",
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.26.tgz",
"integrity": "sha512-FE0cjdAyzTR+Rr7pHULTF5rHiCW+FFnEHuV4kP7pdrHzl5oFZTUQ3uqEFEgmsrV6a0gzNwKgr/MfnVO/3sUrdw==",
"dev": true,
"requires": {
"@pushrocks/early": "^3.0.6",
"@pushrocks/smartcli": "^3.0.12",
"@pushrocks/smartfile": "^8.0.0",
"@pushrocks/smartlog": "^2.0.36",
"@pushrocks/smartcli": "^3.0.14",
"@pushrocks/smartfile": "^8.0.10",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.6",
"typescript": "^3.9.7"
},
"dependencies": {
"typescript": {
"version": "3.9.10",
"resolved": "https://verdaccio.lossless.one/typescript/-/typescript-3.9.10.tgz",
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
"dev": true
}
"@pushrocks/smartpromise": "^3.1.6",
"typescript": "^4.3.5"
}
},
"@gitzone/tsbundle": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartmetrics",
"version": "1.0.8",
"version": "1.0.17",
"private": false,
"description": "easy system metrics",
"main": "dist_ts/index.js",
@ -12,7 +12,7 @@
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsbuild": "^2.1.26",
"@gitzone/tsbundle": "^1.0.78",
"@gitzone/tstest": "^1.0.44",
"@pushrocks/tapbundle": "^3.2.9",

View File

@ -1,6 +1,5 @@
import * as plugins from './smartmetrics.plugins';
import * as interfaces from './smartmetrics.interfaces';
import { Cipher } from 'crypto';
export class SmartMetrics {
public started = false;
@ -31,7 +30,7 @@ export class SmartMetrics {
eventType: 'heartbeat',
metrics: await this.getMetrics(),
});
await plugins.smartdelay.delayFor(10000, null, true);
await plugins.smartdelay.delayFor(20000, null, true);
}
};
unattendedStart();
@ -58,9 +57,9 @@ export class SmartMetrics {
let cpuPercentage = 0;
for (const stat of Object.keys(stats)) {
if (!stats[stat]) continue;
cpuPercentage += stats[stat].cpu / 100;
cpuPercentage += stats[stat].cpu;
}
let cpuUsageText = `${cpuPercentage * 100} %`;
let cpuUsageText = `${Math.round(cpuPercentage * 100) / 100} %`;
// lets compute memory usage
let memoryUsageBytes = 0;
@ -68,11 +67,12 @@ export class SmartMetrics {
if (!stats[stat]) continue;
memoryUsageBytes += stats[stat].memory;
}
let memoryUsageText = this.formatBytes(memoryUsageBytes);
let memoryPercentage = Math.round((memoryUsageBytes / plugins.os.totalmem()) * 100) / 100;
let memoryPercentage = Math.round((memoryUsageBytes / 1000000000) * 100 * 100) / 100;
let memoryUsageText = `${memoryPercentage}% | ${this.formatBytes(memoryUsageBytes)} / ${this.formatBytes(1000000000)}`;
console.log(`${cpuUsageText} ||| ${memoryUsageText} `);
const returnMetrics: interfaces.IMetricsSnapshot = {
originalMetrics,
process_cpu_seconds_total: (
originalMetrics.find((metricSet) => metricSet.name === 'process_cpu_seconds_total') as any
).values[0].value,

View File

@ -1,6 +1,5 @@
// this might be extracted into a package @pushrocks/smartmetrics-interfaces in the future
export interface IMetricsSnapshot {
originalMetrics: any[];
process_cpu_seconds_total: number;
nodejs_active_handles_total: number;
nodejs_active_requests_total: number;