5 Commits

Author SHA1 Message Date
533639b66d 1.0.5 2021-08-13 13:13:12 +02:00
8f0ebccb58 fix(core): update 2021-08-13 13:13:11 +02:00
e98b1779e1 1.0.4 2021-08-13 11:55:38 +02:00
df5197fc8e fix(core): update 2021-08-13 11:55:38 +02:00
0e3fadca36 1.0.3 2021-08-12 23:31:11 +02:00
3 changed files with 7 additions and 8 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@pushrocks/smartmetrics",
"version": "1.0.2",
"version": "1.0.5",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@pushrocks/smartmetrics",
"version": "1.0.2",
"version": "1.0.5",
"license": "MIT",
"dependencies": {
"@pushrocks/smartdelay": "^2.0.13",

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartmetrics",
"version": "1.0.2",
"version": "1.0.5",
"private": false,
"description": "easy system metrics",
"main": "dist_ts/index.js",

View File

@ -26,7 +26,8 @@ export class SmartMetrics {
}
this.started = true;
while (this.started) {
this.logger.log('info', `sending heartbeat for ${this.sourceNameArg}`, {
this.logger.log('info', `sending heartbeat for ${this.sourceNameArg} with metrics`, {
eventType: 'heartbeat',
metrics: await this.getMetrics(),
});
await plugins.smartdelay.delayFor(60000, null, true);
@ -48,11 +49,9 @@ export class SmartMetrics {
cpu.times.irq +
cpu.times.idle;
}
// Normalize the one returned by process.cpuUsage()
// (microseconds VS miliseconds)
const usage = process.cpuUsage();
const currentCPUUsage = (usage.user + usage.system) * 1000;
const currentCPUUsage = (usage.user + usage.system);
// Find out the percentage used for this specific CPU
const perc = (currentCPUUsage / total) * 100;