Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
node-system-stats
Advanced tools
This package shows you the system statistics, with wonderful type declartions.
Note: You can find documentation for all of the types and functions here.
Note: This module only relies on the os
module, so it should be compatible on all OS's where Node.js runs.
Note: This package is a TS-rewrite of the old package cpu-stat. Also it comes with 1 more function to measure the ram usage. More functions will be added later.
npm install node-system-stats
To measure the cpu Usage in percent, you can use this function below. Parameter Description can be found here
By default you can use it like that:
// TypeScript: import { usagePercent } from "node-system-stats";
const { usagePercent } = require("node-system-stats")
let result = { percent: 0 };
try {
result = await usagePercent()
} catch (err) {
console.log(err)
}
console.log(result); // Output: { percent: 1.5, seconds: 1}
Get the cpu usage percent for core 0 over a sample period of 2000ms:
// TypeScript: import { usagePercent } from "node-system-stats"
const { usagePercent } = require("node-system-stats");
let result = { percent: 0 };
try {
result = await usagePercent({ coreIndex: 0, sampleMs: 2000 })
} catch (err) {
console.log(err);
}
console.log(result);
To get all of the cores, you can use this function below. View here for more description.
// TypeScript: import { totalCores } from "node-system-stats"
const { totalCores } = require("node-system-stats");
console.log(totalCores); // Output: 8
// Note: Threads count as cores too! So if you want to only get the "real" cores use the code snippet below:
console.log(totalCores / 2); // Output: 4
If you want to get the Average CPU Clock speed, then use this function below. View here for more description.
// TypeScript: import { avgClockMHz } from "node-system-stats"
const { avgClockMHz } = require("node-system-stats");
console.log(avgClockMHz()); // Output: 3600
Note: To see every function, please take a look at the documentation.
If you wish to contribute to the Node-System-Stats codebase or documentation, feel free to fork the repository and submit a pull request. We use ESLint to enforce a consistent coding style, so having that set up in your editor of choice is a great boon to your development process.
FAQs
This package shows you the system statistics, with wonderful type declartions.
We found that node-system-stats demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.