@server-state/system-information-module

0.1.2 • Public • Published

system information module

Build Status GitHub npm version Coverage Status module type: official

Description

A module to view characteristics of your system.
Its response is a object containing keys named after the request functions from the systeminformation module. The output can be defined before in SMF options with another object as the return value from the systeminformation function.
Here is a example for a request to CPU and memory information:

{
  "cpu": {
    "manufacturer": "Intel®",
    "brand": "Core™ i7-8250U",
    "vendor": "GenuineIntel",
    "family": "6",
    "model": "142",
    "stepping": "10",
    "revision": "",
    "voltage": "",
    "speed": "1.60",
    "speedmin": "0.40",
    "speedmax": "3.40",
    "cores": 8,
    "physicalCores": 4,
    "processors": 1,
    "socket": "",
    "cache": {
      "l1d": 131072,
      "l1i": 131072,
      "l2": 1,
      "l3": 8
    }
  },
  "mem": {
    "total": 16677117952,
    "free": 7204421632,
    "used": 9472696320,
    "active": 5442600960,
    "available": 11642912768,
    "buffcache": 4030095360,
    "swaptotal": 8589930496,
    "swapused": 9072640,
    "swapfree": 8580857856
  }
}

You can simply add this module with the server-base function and your specific options, for example:

server.addModule('system-information', require('@server-state/system-information-module'), {
    cpu: [],
    mem: ['free']
});

to your current api server. This results in the following output:

{
  "cpu": {
    "manufacturer": "Intel®",
    "brand": "Core™ i7-8250U",
    "vendor": "GenuineIntel",
    "family": "6",
    "model": "142",
    "stepping": "10",
    "revision": "",
    "voltage": "",
    "speed": "1.60",
    "speedmin": "0.40",
    "speedmax": "3.40",
    "cores": 8,
    "physicalCores": 4,
    "processors": 1,
    "socket": "",
    "cache": {
      "l1d": 131072,
      "l1i": 131072,
      "l2": 1,
      "l3": 8
    }
  },
  "mem": {
    "free": 7204421632
  }
}

Options

You can adjust the result of this module in the options as an object.
These object contains key-value pairs. The key defines the function based the systeminformation reference to call and the value as type of array defines the filter.
If the array or filter is empty, the result from the 'si'-function will be returned. If the array contains strings that bases on the resulting key names in the object, the result object from the 'si'-function is filtered by the defined key names.
For example, if you only want the number of cores from your CPU, an option object could look like:

const options = {
    cpu: ['cores']
};

And the result defined by this option could look like:

{
  "cpu": {
    "cores": 4
  }
}

About

This output generates a straight base to provide other applications useful information like server-state example client-base.

This official module belongs to the organization server-state.

Readme

Keywords

none

Package Sidebar

Install

npm i @server-state/system-information-module

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

15.1 kB

Total Files

6

Last publish

Collaborators

  • fussel178
  • pklaschka
  • server-state-ci