Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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.
The npm package node-system-stats receives a total of 5,343 weekly downloads. As such, node-system-stats popularity was classified as popular.
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.