Quick Start

Lightweight collection of 40+ 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 and SunOS support
  • no npm dependencies (for production)

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 work in progress. It is supposed to be used as a backend/server-side library (will definilely not work within a browser). 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) and some Windows 7, 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

Installation

$ npm install systeminformation --save

Usage

All functions (except version and time) are implemented as asynchronous functions. Here a small example how to use them:

const si = require('systeminformation');

// promises style - new since version 3
si.cpu()
    .then(data => console.log(data))
    .catch(error => console.error(error));

Callback, Promises, Async Await

Remember: all functions (except version and time) are implemented as asynchronous functions! There are now three ways to consume them:

Callback Style

const si = require('systeminformation');

si.cpu(function(data) {
    console.log('CPU Information:');
    console.log('- manufucturer: ' + 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('...');
})

Promise Style

Promises style is new since version 3.0.

When omitting callback parameter (cb), then you can use all function in a promise oriented way. All functions (exept of version and time) are returning a promise, that you can consume:

const si = require('systeminformation');

si.cpu()
    .then(data => {
        console.log('CPU Information:');
        console.log('- manufucturer: ' + 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));

Async/Await Style

Since node v7.6 you can also use the async / await pattern. The above example would then look like this:

const si = require('systeminformation');

async function cpuData() {
    try {
        const data = await si.cpu();
        console.log('CPU Information:');
        console.log('- manufucturer: ' + 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)
    }
}