Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
01306ed3f9 | |||
2a2ca66708 | |||
299e50cbf7 | |||
1e6af24df0 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "2.0.2",
|
"version": "2.0.4",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "2.0.2",
|
"version": "2.0.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
|
20
package.json
20
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartmetrics",
|
"name": "@pushrocks/smartmetrics",
|
||||||
"version": "2.0.2",
|
"version": "2.0.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "easy system metrics",
|
"description": "easy system metrics",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -13,11 +13,11 @@
|
|||||||
"buildDocs": "tsdoc"
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@gitzone/tsbuild": "^2.1.66",
|
||||||
"@gitzone/tsbundle": "^2.0.6",
|
"@gitzone/tsbundle": "^2.0.8",
|
||||||
"@gitzone/tstest": "^1.0.72",
|
"@gitzone/tstest": "^1.0.74",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@pushrocks/tapbundle": "^5.0.8",
|
||||||
"@types/node": "^18.6.1"
|
"@types/node": "^20.3.3"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
@ -35,12 +35,12 @@
|
|||||||
"readme.md"
|
"readme.md"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@pushrocks/smartdelay": "^3.0.1",
|
||||||
"@pushrocks/smartlog": "^3.0.1",
|
"@pushrocks/smartlog": "^3.0.2",
|
||||||
"@types/pidusage": "^2.0.2",
|
"@types/pidusage": "^2.0.2",
|
||||||
"pidtree": "^0.6.0",
|
"pidtree": "^0.6.0",
|
||||||
"pidusage": "^3.0.0",
|
"pidusage": "^3.0.2",
|
||||||
"prom-client": "^14.0.1"
|
"prom-client": "^14.2.0"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
4595
pnpm-lock.yaml
generated
Normal file
4595
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartmetrics',
|
name: '@pushrocks/smartmetrics',
|
||||||
version: '2.0.2',
|
version: '2.0.4',
|
||||||
description: 'easy system metrics'
|
description: 'easy system metrics'
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,10 @@ export class SmartMetrics {
|
|||||||
// Ignore - this will fail if not running in a Docker container
|
// Ignore - this will fail if not running in a Docker container
|
||||||
}
|
}
|
||||||
|
|
||||||
this.maxMemoryMB = Math.min(totalSystemMemoryMB, dockerMemoryLimitMB);
|
// Set the maximum memory to the lower value between the Docker limit and the total system memory
|
||||||
|
this.maxMemoryMB = Math.min(totalSystemMemoryMB, dockerMemoryLimitMB, maxHeapSizeMB);
|
||||||
|
|
||||||
|
// If the maximum old space size limit is greater than the maximum available memory, throw an error
|
||||||
if (maxHeapSizeMB > this.maxMemoryMB) {
|
if (maxHeapSizeMB > this.maxMemoryMB) {
|
||||||
throw new Error('Node.js process can use more memory than is available');
|
throw new Error('Node.js process can use more memory than is available');
|
||||||
}
|
}
|
||||||
@ -88,7 +90,6 @@ export class SmartMetrics {
|
|||||||
memoryUsageBytes += stats[stat].memory;
|
memoryUsageBytes += stats[stat].memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct memory usage percentage calculation
|
|
||||||
let memoryPercentage = Math.round((memoryUsageBytes / (this.maxMemoryMB * 1024 * 1024)) * 100 * 100) / 100;
|
let memoryPercentage = Math.round((memoryUsageBytes / (this.maxMemoryMB * 1024 * 1024)) * 100 * 100) / 100;
|
||||||
let memoryUsageText = `${memoryPercentage}% | ${this.formatBytes(memoryUsageBytes)} / ${this.formatBytes(this.maxMemoryMB * 1024 * 1024)}`;
|
let memoryUsageText = `${memoryPercentage}% | ${this.formatBytes(memoryUsageBytes)} / ${this.formatBytes(this.maxMemoryMB * 1024 * 1024)}`;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user