Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
c4f5e9338a | |||
dad2bc26fc | |||
29609eb5ba | |||
0292d9bc13 | |||
69af53a30a | |||
121bfdad43 | |||
f96ed80be0 | |||
ce74c3da40 | |||
c108c00963 | |||
25de5d5874 | |||
9822d470e3 | |||
a425ed64c3 | |||
2eb4bc5697 | |||
dd46f0d90b | |||
0972f1c64d | |||
22b181a7a0 | |||
e43b89f51d | |||
3185c7dab1 |
74
package-lock.json
generated
74
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.7",
|
"version": "1.0.16",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.7",
|
"version": "1.0.16",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
@ -17,11 +17,11 @@
|
|||||||
"prom-client": "^13.2.0"
|
"prom-client": "^13.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.26",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.78",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.44",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^16.6.0",
|
"@types/node": "^16.6.1",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
}
|
}
|
||||||
@ -1822,38 +1822,24 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@gitzone/tsbuild": {
|
"node_modules/@gitzone/tsbuild": {
|
||||||
"version": "2.1.25",
|
"version": "2.1.26",
|
||||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.25.tgz",
|
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.26.tgz",
|
||||||
"integrity": "sha512-KtesoQEm96x0/x1800R3pcj06RcYTdqwBhG9oje+jQW4qZs/bnUirWZXkRMSLAK92cVm899KzZtYkq/fKga2+A==",
|
"integrity": "sha512-FE0cjdAyzTR+Rr7pHULTF5rHiCW+FFnEHuV4kP7pdrHzl5oFZTUQ3uqEFEgmsrV6a0gzNwKgr/MfnVO/3sUrdw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/early": "^3.0.6",
|
"@pushrocks/early": "^3.0.6",
|
||||||
"@pushrocks/smartcli": "^3.0.12",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"@pushrocks/smartfile": "^8.0.0",
|
"@pushrocks/smartfile": "^8.0.10",
|
||||||
"@pushrocks/smartlog": "^2.0.36",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartpath": "^4.0.3",
|
"@pushrocks/smartpath": "^4.0.3",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^4.3.5"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsbuild": "cli.js"
|
"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": {
|
"node_modules/@gitzone/tsbundle": {
|
||||||
"version": "1.0.84",
|
"version": "1.0.84",
|
||||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbundle/-/tsbundle-1.0.84.tgz",
|
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbundle/-/tsbundle-1.0.84.tgz",
|
||||||
@ -3041,9 +3027,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "16.6.0",
|
"version": "16.6.1",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.6.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.6.1.tgz",
|
||||||
"integrity": "sha512-OyiZPohMMjZEYqcVo/UJ04GyAxXOJEZO/FpzyXxcH4r/ArrVoXHf4MbUrkLp0Tz7/p1mMKpo5zJ6ZHl8XBNthQ==",
|
"integrity": "sha512-Sr7BhXEAer9xyGuCN3Ek9eg9xPviCF2gfu9kTfuU2HkTVAMYSDeX40fvpmo72n5nansg3nsBjuQBrsS28r+NUw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
@ -16032,26 +16018,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@gitzone/tsbuild": {
|
"@gitzone/tsbuild": {
|
||||||
"version": "2.1.25",
|
"version": "2.1.26",
|
||||||
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.25.tgz",
|
"resolved": "https://verdaccio.lossless.one/@gitzone%2ftsbuild/-/tsbuild-2.1.26.tgz",
|
||||||
"integrity": "sha512-KtesoQEm96x0/x1800R3pcj06RcYTdqwBhG9oje+jQW4qZs/bnUirWZXkRMSLAK92cVm899KzZtYkq/fKga2+A==",
|
"integrity": "sha512-FE0cjdAyzTR+Rr7pHULTF5rHiCW+FFnEHuV4kP7pdrHzl5oFZTUQ3uqEFEgmsrV6a0gzNwKgr/MfnVO/3sUrdw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@pushrocks/early": "^3.0.6",
|
"@pushrocks/early": "^3.0.6",
|
||||||
"@pushrocks/smartcli": "^3.0.12",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"@pushrocks/smartfile": "^8.0.0",
|
"@pushrocks/smartfile": "^8.0.10",
|
||||||
"@pushrocks/smartlog": "^2.0.36",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartpath": "^4.0.3",
|
"@pushrocks/smartpath": "^4.0.3",
|
||||||
"@pushrocks/smartpromise": "^3.0.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^4.3.5"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"typescript": {
|
|
||||||
"version": "3.9.10",
|
|
||||||
"resolved": "https://verdaccio.lossless.one/typescript/-/typescript-3.9.10.tgz",
|
|
||||||
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
|
|
||||||
"dev": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@gitzone/tsbundle": {
|
"@gitzone/tsbundle": {
|
||||||
@ -17071,9 +17049,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "16.6.0",
|
"version": "16.6.1",
|
||||||
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.6.0.tgz",
|
"resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.6.1.tgz",
|
||||||
"integrity": "sha512-OyiZPohMMjZEYqcVo/UJ04GyAxXOJEZO/FpzyXxcH4r/ArrVoXHf4MbUrkLp0Tz7/p1mMKpo5zJ6ZHl8XBNthQ==",
|
"integrity": "sha512-Sr7BhXEAer9xyGuCN3Ek9eg9xPviCF2gfu9kTfuU2HkTVAMYSDeX40fvpmo72n5nansg3nsBjuQBrsS28r+NUw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/parcel-bundler": {
|
"@types/parcel-bundler": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.7",
|
"version": "1.0.16",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy system metrics",
|
"description": "easy system metrics",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -12,11 +12,11 @@
|
|||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.26",
|
||||||
"@gitzone/tsbundle": "^1.0.78",
|
"@gitzone/tsbundle": "^1.0.78",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.44",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^16.6.0",
|
"@types/node": "^16.6.1",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,7 @@ export class SmartMetrics {
|
|||||||
eventType: 'heartbeat',
|
eventType: 'heartbeat',
|
||||||
metrics: await this.getMetrics(),
|
metrics: await this.getMetrics(),
|
||||||
});
|
});
|
||||||
await plugins.smartdelay.delayFor(10000, null, true);
|
await plugins.smartdelay.delayFor(20000, null, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
unattendedStart();
|
unattendedStart();
|
||||||
@ -58,9 +58,9 @@ export class SmartMetrics {
|
|||||||
let cpuPercentage = 0;
|
let cpuPercentage = 0;
|
||||||
for (const stat of Object.keys(stats)) {
|
for (const stat of Object.keys(stats)) {
|
||||||
if (!stats[stat]) continue;
|
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
|
// lets compute memory usage
|
||||||
let memoryUsageBytes = 0;
|
let memoryUsageBytes = 0;
|
||||||
@ -68,11 +68,12 @@ export class SmartMetrics {
|
|||||||
if (!stats[stat]) continue;
|
if (!stats[stat]) continue;
|
||||||
memoryUsageBytes += stats[stat].memory;
|
memoryUsageBytes += stats[stat].memory;
|
||||||
}
|
}
|
||||||
let memoryUsageText = this.formatBytes(memoryUsageBytes);
|
let memoryPercentage = Math.round((memoryUsageBytes / 1000000000) * 100 * 100) / 100;
|
||||||
let memoryPercentage = Math.round((memoryUsageBytes / plugins.os.totalmem()) * 100) / 100;
|
let memoryUsageText = `${memoryPercentage}% | ${this.formatBytes(memoryUsageBytes)} / ${this.formatBytes(1000000000)}`;
|
||||||
|
|
||||||
|
console.log(`${cpuUsageText} ||| ${memoryUsageText} `);
|
||||||
|
|
||||||
const returnMetrics: interfaces.IMetricsSnapshot = {
|
const returnMetrics: interfaces.IMetricsSnapshot = {
|
||||||
originalMetrics,
|
|
||||||
process_cpu_seconds_total: (
|
process_cpu_seconds_total: (
|
||||||
originalMetrics.find((metricSet) => metricSet.name === 'process_cpu_seconds_total') as any
|
originalMetrics.find((metricSet) => metricSet.name === 'process_cpu_seconds_total') as any
|
||||||
).values[0].value,
|
).values[0].value,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
// this might be extracted into a package @pushrocks/smartmetrics-interfaces in the future
|
// this might be extracted into a package @pushrocks/smartmetrics-interfaces in the future
|
||||||
export interface IMetricsSnapshot {
|
export interface IMetricsSnapshot {
|
||||||
originalMetrics: any[];
|
|
||||||
process_cpu_seconds_total: number;
|
process_cpu_seconds_total: number;
|
||||||
nodejs_active_handles_total: number;
|
nodejs_active_handles_total: number;
|
||||||
nodejs_active_requests_total: number;
|
nodejs_active_requests_total: number;
|
||||||
|
Reference in New Issue
Block a user