Lightweight collection of 50+ functions to retrieve detailed hardware, system and OS information.
- simple to use
- get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes
- supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD, SunOS and Android support
- no npm dependencies
Core Concept
Node.js comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still a work in progress. It requires node.js version 4.0 and above.
I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave, Catalina, Big Sur) and some Windows 7, Windows 8, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.
If you have comments, suggestions & reports, please feel free to contact me on github!
I also created a nice little command line tool called mmon (micro-monitor) for Linux and macOS, also available via github and npm
Attention:
This library is supposed to be used as a node.js backend/server-side library and will definitely not work within a browser.
Installation - beta version
Install via npm
$ npm install systeminformation@beta --save
or simpler:
$ npm i systeminformation@beta
Install in bun
$ bun i systeminformation@beta
Use it in Deno
$ deno install npm:systeminformation@beta
Usage
All functions are implemented as asynchronous functions. Here a small example how to use them:
const si = require('systeminformation');
// promises style
si.cpu()
.then(data => console.log(data))
.catch(error => console.error(error));
Async Await and Promises
All functions are now implemented as asynchronous functions in version 6! There are two ways to consume them:
Async/Await Style
This is the preferred way of consuming the library.
const si = require('systeminformation');
async function cpuData() {
try {
const data = await si.cpu();
console.log('CPU Information:');
console.log('- manufacturer: ' + data.manufacturer);
console.log('- brand: ' + data.brand);
console.log('- speed: ' + data.speed);
console.log('- cores: ' + data.cores);
console.log('- physical cores: ' + data.physicalCores);
console.log('...');
} catch (e) {
console.log(e)
}
}
Promise Style
As all functions are returning a promise, you can use all function in a promise oriented way:
const si = require('systeminformation');
si.cpu()
.then(data => {
console.log('CPU Information:');
console.log('- manufacturer: ' + data.manufacturer);
console.log('- brand: ' + data.brand);
console.log('- speed: ' + data.speed);
console.log('- cores: ' + data.cores);
console.log('- physical cores: ' + data.physicalCores);
console.log('...');
})
.catch(error => console.error(error));
Callback Style
Be aware: callback style is no longer available in Version 6.
Use full library or just parts
Using only parts of the library can help reduce memory usage and improve startup time. Only the imported function (and, for the plain function import, only the platform actually running) is pulled in, so unused OS implementations can be tree-shaken away.
1. Use whole library (all functions, all platforms)
const si = require("systeminformation");
await si.cpu();
2. use just single function (platform is still detected at runtime)
const { cpu } = require("systeminformation/cpu");
await cpu();
3. Use whole operating system (only that platform's implementations)
const linux = require("systeminformation/linux"); // or /darwin, /windows, /bsd, /sun
await linux.cpu();
4. Use a single function of a single operating system
const { cpu } = require("systeminformation/linux/cpu");
await cpu();
Issues
If you discover some empty or incorrect values, please be sure to first have a look at the Known Issues section.