Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
533639b66d | |||
8f0ebccb58 | |||
e98b1779e1 | |||
df5197fc8e |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "1.0.3",
|
"version": "1.0.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy system metrics",
|
"description": "easy system metrics",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -26,7 +26,8 @@ export class SmartMetrics {
|
|||||||
}
|
}
|
||||||
this.started = true;
|
this.started = true;
|
||||||
while (this.started) {
|
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(),
|
metrics: await this.getMetrics(),
|
||||||
});
|
});
|
||||||
await plugins.smartdelay.delayFor(60000, null, true);
|
await plugins.smartdelay.delayFor(60000, null, true);
|
||||||
@ -49,10 +50,8 @@ export class SmartMetrics {
|
|||||||
cpu.times.idle;
|
cpu.times.idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normalize the one returned by process.cpuUsage()
|
|
||||||
// (microseconds VS miliseconds)
|
|
||||||
const usage = process.cpuUsage();
|
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
|
// Find out the percentage used for this specific CPU
|
||||||
const perc = (currentCPUUsage / total) * 100;
|
const perc = (currentCPUUsage / total) * 100;
|
||||||
|
Reference in New Issue
Block a user