@felipebutcher/node-os-info

When I needed to get memory, cpu and disk information on NodeJS, I ended up looking for answers on stackoverflow and using multiple packages with some code. I am putting all together here.


Keywords
os, info, memory, cpu, node
License
ISC
Install
npm install @felipebutcher/node-os-info@0.0.6

Documentation

node-os-info

When I needed to get memory, cpu and disk information on NodeJS, I ended up looking for answers on stackoverflow and using multiple packages with some code. I am putting all together here.

The values that this package show are the same as in htop, which were what I was looking for.

Code from others

This project uses this code for CPU calculation.
We also use NodeJS OS module.
The packages systeminformation and check-disk-space are used for memory and disk calculation.

Installation

npm install @felipebutcher/node-os-info

Usage

All the three variables (memory, cpu and disk) are a number between 0 and 1, representing the percentage of use of each resource.

const osInfo = require("@felipebutcher/node-os-info");

osInfo.mem(memory => {
    console.log("Memory: " + Math.round(memory * 100) + "%");
});

osInfo.cpu(cpu => {
    console.log("CPU: " + Math.round(cpu * 100) + "%");
});

osInfo.disk(disk => {
    console.log("Disk: " + Math.round(disk * 100) + "%");
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

There's no license, do what you want.