added partial SunOS support, system() Raspberry Pi bugfix and extended detection

This commit is contained in:
Sebastian Hildebrandt 2018-05-11 22:12:50 +02:00
parent 426e37ed93
commit a719e1dd3f
8 changed files with 425 additions and 390 deletions

View File

@ -100,6 +100,7 @@ Other changes
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 3.41.0 | 2018-05-11 | `system()` Raspberry Pi bugfix and extended detection, added partial `SunOS` support |
| 3.40.1 | 2018-05-10 | bugfix `system().sku` (windows) | | 3.40.1 | 2018-05-10 | bugfix `system().sku` (windows) |
| 3.40.0 | 2018-04-29 | extended `versions()` (php, redis, mongodb) | | 3.40.0 | 2018-04-29 | extended `versions()` (php, redis, mongodb) |
| 3.39.0 | 2018-04-29 | added `versions().mysql` and `versions().nginx`, starting `SunOS` support (untested) | | 3.39.0 | 2018-04-29 | added `versions().mysql` and `versions().nginx`, starting `SunOS` support (untested) |

603
README.md
View File

@ -11,7 +11,7 @@ Simple system and OS information library for [node.js][nodejs-url]
## Quick Start ## Quick Start
Lightweight collection of 35+ functions to retrieve detailed hardware, system and OS information (Linux, macOS, partial Windows and FreeBSD support) - no npm dependencies. Lightweight collection of 35+ functions to retrieve detailed hardware, system and OS information (Linux, macOS, partial Windows, FreeBSD and SunOS support) - no npm dependencies.
### Installation ### Installation
@ -53,13 +53,14 @@ async function cpu() {
### Latest Activity ### Latest Activity
(last 7 major and minor version releases) (last 7 major and minor version releases)
- Version 3.41.0: first partial `SunOS` support
- Version 3.40.0: extended `versions()` (php, redis, mongodb) - Version 3.40.0: extended `versions()` (php, redis, mongodb)
- Version 3.39.0: added `versions().mysql` and `versions().nginx`, starting `SunOS` support - Version 3.39.0: added `versions().mysql` and `versions().nginx`, start implementing `SunOS` support
- Version 3.38.0: added `battery.acconnected` - Version 3.38.0: added `battery.acconnected`
- Version 3.37.0: extended FreeBSD support `networkStats()` - Version 3.37.0: extended FreeBSD support `networkStats()`
- Version 3.36.0: extended FreeBSD support `networkConnections()` - Version 3.36.0: extended FreeBSD support `networkConnections()`
- Version 3.35.0: extended FreeBSD support `processLoad()` - Version 3.35.0: extended FreeBSD support `processLoad()`
- Version 3.34.0: first partial FreeBSD support
- ... - ...
You can find all changes here: [detailed changelog][changelog-url] You can find all changes here: [detailed changelog][changelog-url]
@ -70,7 +71,7 @@ You can find all changes here: [detailed changelog][changelog-url]
little library. This library is still work in progress. Version 3 comes with further improvements. First it little library. This library is still work in progress. Version 3 comes with further improvements. First it
requires now node.js version 4.0 and above. Another big change is, that all functions now return promises. You can use them requires now node.js version 4.0 and above. Another big change is, that all functions now return promises. You can use them
like before with callbacks OR with promises (see example in this documentation). I am sure, there is for sure room for improvement. like before with callbacks OR with promises (see example in this documentation). I am sure, there is for sure room for improvement.
I was only able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows and FreeBSD machines. I was only able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows, FreeBSD and SunOS machines.
Since version 2 nearly all functionality is available for OS X/Darwin platforms. In Version 3 I started to add windows and (partial) FreeBSD support - see docs. Since version 2 nearly all functionality is available for OS X/Darwin platforms. In Version 3 I started to add windows and (partial) FreeBSD support - see docs.
If you have comments, suggestions & reports, please feel free to contact me! If you have comments, suggestions & reports, please feel free to contact me!
@ -84,335 +85,335 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
#### 1. General #### 1. General
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.version() | : string | X | X | X | X | lib version (no callback/promise) | | si.version() | : string | X | X | X | X | X | lib version (no callback/promise) |
| si.time() | {...} | X | X | X | X | (no callback/promise) | | si.time() | {...} | X | X | X | X | X | (no callback/promise) |
| | current | X | X | X | X | local time | | | current | X | X | X | X | X | local time |
| | uptime | X | X | X | X | uptime | | | uptime | X | X | X | X | X | uptime |
| | timezone | X | X | X | X | e.g. GMT+0200 | | | timezone | X | X | X | X | X | e.g. GMT+0200 |
| | timezoneName | X | X | X | X | e.g. CEST | | | timezoneName | X | X | X | X | X | e.g. CEST |
#### 2. System (HW) #### 2. System (HW)
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.system(cb) | {...} | X | X | X | X | hardware information | | si.system(cb) | {...} | X | X | X | X | | hardware information |
| | manufacturer | X | X | X | X | e.g. 'MSI' | | | manufacturer | X | X | X | X | | e.g. 'MSI' |
| | model | X | X | X | X | model/product e.g. 'MS-7823' | | | model | X | X | X | X | | model/product e.g. 'MS-7823' |
| | version | X | X | X | X | version e.g. '1.0' | | | version | X | X | X | X | | version e.g. '1.0' |
| | serial | X | X | X | X | serial number | | | serial | X | X | X | X | | serial number |
| | uuid | X | X | X | X | UUID | | | uuid | X | X | X | X | | UUID |
| | sku | X | X | | X | SKU number | | | sku | X | X | | X | | SKU number |
| si.bios(cb) | {...} | X | X | X | X | hardware information | | si.bios(cb) | {...} | X | X | X | X | | hardware information |
| | vendor | X | X | X | X | e.g. 'AMI' | | | vendor | X | X | X | X | | e.g. 'AMI' |
| | version | X | X | | X | version | | | version | X | X | | X | | version |
| | releaseDate | X | X | | X | release date | | | releaseDate | X | X | | X | | release date |
| | revision | X | X | | X | revision | | | revision | X | X | | X | | revision |
| si.baseboard(cb) | {...} | X | X | X | X | hardware information | | si.baseboard(cb) | {...} | X | X | X | X | | hardware information |
| | manufacturer | X | X | X | X | e.g. 'ASUS' | | | manufacturer | X | X | X | X | | e.g. 'ASUS' |
| | model | X | X | X | X | model / product name | | | model | X | X | X | X | | model / product name |
| | version | X | X | X | X | version | | | version | X | X | X | X | | version |
| | serial | X | X | X | X | serial number | | | serial | X | X | X | X | | serial number |
| | assetTag | X | X | X | X | asset tag | | | assetTag | X | X | X | X | | asset tag |
#### 3. CPU, Memory, Disks, Battery, Graphics #### 3. CPU, Memory, Disks, Battery, Graphics
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.cpu(cb) | {...} | X | X | X | X | CPU information| | si.cpu(cb) | {...} | X | X | X | X | | CPU information|
| | manufacturer | X | X | X | X | e.g. 'Intel(R)' | | | manufacturer | X | X | X | X | | e.g. 'Intel(R)' |
| | brand | X | X | X | X | e.g. 'Core(TM)2 Duo' | | | brand | X | X | X | X | | e.g. 'Core(TM)2 Duo' |
| | speed | X | X | X | X | in GHz e.g. '3.40' | | | speed | X | X | X | X | | in GHz e.g. '3.40' |
| | speedmin | X | | X | X | in GHz e.g. '0.80' | | | speedmin | X | | X | X | | in GHz e.g. '0.80' |
| | speedmax | X | X | X | X | in GHz e.g. '3.90' | | | speedmax | X | X | X | | X | | in GHz e.g. '3.90' |
| | cores | X | X | X | X | # cores | | | cores | X | X | X | X | | # cores |
| | vendor | X | X | X | X | vendor ID | | | vendor | X | X | X | X | | vendor ID |
| | family | X | X | X | X | processor family | | | family | X | X | X | X | | processor family |
| | Model | X | X | X | X | processor model | | | Model | X | X | X | X | | processor model |
| | stepping | X | X | X | X | processor stepping | | | stepping | X | X | X | X | | processor stepping |
| | revision | X | | X | X | revision | | | revision | X | | X | X | | revision |
| | voltage | | X | | | voltage | | | voltage | | X | | | | voltage |
| | cache | X | X | X | X | cache in bytes (object) | | | cache | X | X | X | X | | cache in bytes (object) |
| | cache.l1d | X | X | X | X | L1D (data) size | | | cache.l1d | X | X | X | X | | L1D (data) size |
| | cache.l1i | X | X | X | X | L1I (instruction) size | | | cache.l1i | X | X | X | X | | L1I (instruction) size |
| | cache.l2 | X | X | X | X | L2 size | | | cache.l2 | X | X | X | X | | L2 size |
| | cache.l3 | X | X | X | X | L3 size | | | cache.l3 | X | X | X | X | | L3 size |
| si.cpuFlags(cb) | : string | X | X | X | X | CPU flags| | si.cpuFlags(cb) | : string | X | X | X | X | | CPU flags|
| si.cpuCache(cb) | {...} | X | X | X | X | CPU cache sizes | | si.cpuCache(cb) | {...} | X | X | X | X | | CPU cache sizes |
| | l1d | X | X | X | X | L1D size | | | l1d | X | X | X | X | | L1D size |
| | l1i | X | X | X | X | L1I size | | | l1i | X | X | X | X | | L1I size |
| | l2 | X | X | X | X | L2 size | | | l2 | X | X | X | X | | L2 size |
| | l3 | X | X | X | X | L3 size | | | l3 | X | X | X | X | | L3 size |
| si.cpuCurrentspeed(cb) | {...} | X | X | X | X | current CPU speed (in GHz)| | si.cpuCurrentspeed(cb) | {...} | X | X | X | X | X | current CPU speed (in GHz)|
| | avg | X | X | X | X | avg CPU speed (all cores) | | | avg | X | X | X | X | X | avg CPU speed (all cores) |
| | min | X | X | X | X | min CPU speed (all cores) | | | min | X | X | X | X | X | min CPU speed (all cores) |
| | max | X | X | X | X | max CPU speed (all cores) | | | max | X | X | X | X | X | max CPU speed (all cores) |
| si.cpuTemperature(cb) | {...} | X | X | X* | X | CPU temperature (if supported) | | si.cpuTemperature(cb) | {...} | X | X | X* | X | | CPU temperature (if supported) |
| | main | X | X | X | X | main temperature (avg) | | | main | X | X | X | X | | main temperature (avg) |
| | cores | X | X | X | X | array of temperatures | | | cores | X | X | X | X | | array of temperatures |
| | max | X | X | X | X | max temperature | | | max | X | X | X | X | | max temperature |
| si.mem(cb) | {...} | X | X | X | X | Memory information (in bytes)| | si.mem(cb) | {...} | X | X | X | X | X | Memory information (in bytes)|
| | total | X | X | X | X | total memory in bytes | | | total | X | X | X | X | X | total memory in bytes |
| | free | X | X | X | X | not used in bytes | | | free | X | X | X | X | X | not used in bytes |
| | used | X | X | X | X | used (incl. buffers/cache) | | | used | X | X | X | X | X | used (incl. buffers/cache) |
| | active | X | X | X | X | used actively (excl. buffers/cache) | | | active | X | X | X | X | X | used actively (excl. buffers/cache) |
| | buffcache | X | X | X | | used by buffers+cache | | | buffcache | X | X | X | | X | used by buffers+cache |
| | available | X | X | X | X | potentially available (total - active) | | | available | X | X | X | X | X | potentially available (total - active) |
| | swaptotal | X | X | X | X | | | | swaptotal | X | X | X | X | X | |
| | swapused | X | X | X | X | | | | swapused | X | X | X | X | X | |
| | swapfree | X | X | X | X | | | | swapfree | X | X | X | X | X | |
| si.memLayout(cb) | [{...}] | X | X | X | X | Memory Layout (array) | | si.memLayout(cb) | [{...}] | X | X | X | X | | Memory Layout (array) |
| | [0].size | X | X | X | X | size in bytes | | | [0].size | X | X | X | X | | size in bytes |
| | [0].bank | X | X | | X | memory bank | | | [0].bank | X | X | | X | | memory bank |
| | [0].type | X | X | X | X | memory type | | | [0].type | X | X | X | X | | memory type |
| | [0].clockSpeed | X | X | X | X | clock speed | | | [0].clockSpeed | X | X | X | X | | clock speed |
| | [0].formFactor | X | X | | X | form factor | | | [0].formFactor | X | X | | X | | form factor |
| | [0].manufacturer | X | X | X | X | manufacturer | | | [0].manufacturer | X | X | X | X | | manufacturer |
| | [0].partNum | X | X | X | X | part number | | | [0].partNum | X | X | X | X | | part number |
| | [0].serialNum | X | X | X | X | serial number | | | [0].serialNum | X | X | X | X | | serial number |
| | [0].voltageConfigured | X | X | | X | voltage conf. | | | [0].voltageConfigured | X | X | | X | | voltage conf. |
| | [0].voltageMin | X | X | | X | voltage min | | | [0].voltageMin | X | X | | X | | voltage min |
| | [0].voltageMax | X | X | | X | voltage max | | | [0].voltageMax | X | X | | X | | voltage max |
| si.diskLayout(cb) | [{...}] | X | | X | X | physical disk layout (array) | | si.diskLayout(cb) | [{...}] | X | | X | X | | physical disk layout (array) |
| | [0].type | X | | X | X | HD, SSD | | | [0].type | X | | X | X | | HD, SSD |
| | [0].name | X | | X | X | disk name | | | [0].name | X | | X | X | | disk name |
| | [0].vendor | X | | | X | vendor/producer | | | [0].vendor | X | | | X | | vendor/producer |
| | [0].firmwareRevision | X | | X | X | firmware revision | | | [0].firmwareRevision | X | | X | X | | firmware revision |
| | [0].serialNum | X | | X | X | serial number | | | [0].serialNum | X | | X | X | | serial number |
| | [0].interfaceType | | | | X | | | | [0].interfaceType | | | | X | | |
| | [0].size | X | | X | X | size in bytes | | | [0].size | X | | X | X | | size in bytes |
| | [0].totalCylinders | | | | X | total cylinders | | | [0].totalCylinders | | | | X | | total cylinders |
| | [0].totalHeads | | | | X | total heads | | | [0].totalHeads | | | | X | | total heads |
| | [0].totalTracks | | | | X | total tracks | | | [0].totalTracks | | | | X | | total tracks |
| | [0].tracksPerCylinder | | | | X | tracks per cylinder | | | [0].tracksPerCylinder | | | | X | | tracks per cylinder |
| | [0].sectorsPerTrack | | | | X | sectors per track | | | [0].sectorsPerTrack | | | | X | | sectors per track |
| | [0].totalSectors | | | | X | total sectors | | | [0].totalSectors | | | | X | | total sectors |
| | [0].bytesPerSector | | | | X | bytes per sector | | | [0].bytesPerSector | | | | X | | bytes per sector |
| si.battery(cb) | {...} | X | X | X | X | battery information | | si.battery(cb) | {...} | X | X | X | X | | battery information |
| | hasbattery | X | X | X | X | indicates presence of battery | | | hasbattery | X | X | X | X | | indicates presence of battery |
| | cyclecount | X | | X | | numbers of recharges | | | cyclecount | X | | X | | | numbers of recharges |
| | ischarging | X | X | X | X | indicates if battery is charging | | | ischarging | X | X | X | X | | indicates if battery is charging |
| | maxcapacity | X | | X | X | max capacity of battery | | | maxcapacity | X | | X | X | | max capacity of battery |
| | currentcapacity | X | | X | X | current capacity of battery | | | currentcapacity | X | | X | X | | current capacity of battery |
| | percent | X | X | X | X | charging level in percent | | | percent | X | X | X | X | | charging level in percent |
| | acconnected | X | X | X | X | AC connected | | | acconnected | X | X | X | X | | AC connected |
| si.graphics(cb) | {...} | X | | X | X | arrays of graphics controllers and displays | | si.graphics(cb) | {...} | X | | X | X | | arrays of graphics controllers and displays |
| | controllers[]| X | | X | X | graphics controllers array | | | controllers[]| X | | X | X | | graphics controllers array |
| | ...[0].model | X | | X | X | graphics controller model | | | ...[0].model | X | | X | X | | graphics controller model |
| | ...[0].vendor | X | | X | X | e.g. ATI | | | ...[0].vendor | X | | X | X | | e.g. ATI |
| | ...[0].bus | X | | X | X| on which bus (e.g. PCIe) | | | ...[0].bus | X | | X | X | | on which bus (e.g. PCIe) |
| | ...[0].vram | X | | X | X | VRAM size (in MB) | | | ...[0].vram | X | | X | X | | VRAM size (in MB) |
| | ...[0].vramDynamic | X | | X | X | true if dynamicly allocated ram | | | ...[0].vramDynamic | X | | X | X | | true if dynamicly allocated ram |
| | displays[] | X | | X | X | monitor/display Array | | | displays[] | X | | X | X | | monitor/display Array |
| | ...[0].model | X | | X | X | monitor/display Model | | | ...[0].model | X | | X | X | | monitor/display Model |
| | ...[0].main | X | | X | | true if main monitor | | | ...[0].main | X | | X | | | true if main monitor |
| | ...[0].builtin | X | | X | | true if built in monitor | | | ...[0].builtin | X | | X | | | true if built in monitor |
| | ...[0].connection | X | | X | | e.g. DisplayPort or HDMI | | | ...[0].connection | X | | X | | | e.g. DisplayPort or HDMI |
| | ...[0].resolutionx | X | | X | X | pixel horizontal | | | ...[0].resolutionx | X | | X | X | | pixel horizontal |
| | ...[0].resolutiony | X | | X | X | pixel vertical | | | ...[0].resolutiony | X | | X | X | | pixel vertical |
| | ...[0].pixeldepth | X | | X | X | color depth in bits | | | ...[0].pixeldepth | X | | X | X | | color depth in bits |
| | ...[0].sizex | X | | X | | size in mm horizontal | | | ...[0].sizex | X | | X | | | size in mm horizontal |
| | ...[0].sizey | X | | X | | size in mm vertical | | | ...[0].sizey | X | | X | | | size in mm vertical |
#### 4. Operating System #### 4. Operating System
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.osInfo(cb) | {...} | X | X | X | X | OS information | | si.osInfo(cb) | {...} | X | X | X | X | X | OS information |
| | platform | X | X | X | X | 'Linux', 'Darwin', 'Windows' | | | platform | X | X | X | X | X | 'Linux', 'Darwin', 'Windows' |
| | distro | X | X | X | X | | | | distro | X | X | X | X | X | |
| | release | X | X | X | X | | | | release | X | X | X | X | X | |
| | codename | | | X | | | | | codename | | | X | | | |
| | kernel | X | X | X | X | kernel release - same as os.release() | | | kernel | X | X | X | X | X | kernel release - same as os.release() |
| | arch | X | X | X | X | same as os.arch() | | | arch | X | X | X | X | | X | same as os.arch() |
| | hostname | X | X | X | X | same as os.hostname() | | | hostname | X | X | X | X | X | same as os.hostname() |
| | logofile | X | X | X | X | e.g. 'apple', 'debian', 'fedora', ... | | | logofile | X | X | X | X | X | e.g. 'apple', 'debian', 'fedora', ... |
| si.versions(cb) | {...} | X | X | X | X | version information (kernel, ssl, node, ...) | | si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) |
| si.shell(cb) | : string | X | X | X | | standard shell | | si.shell(cb) | : string | X | X | X | | | standard shell |
| si.users(cb) | [{...}] | X | X | X | X | array of users online | | si.users(cb) | [{...}] | X | X | X | X | X | array of users online |
| | [0].user | X | X | X | X | user name | | | [0].user | X | X | X | X | X | user name |
| | [0].tty | X | X | X | X | terminal | | | [0].tty | X | X | X | X | X | terminal |
| | [0].date | X | X | X | X | login date | | | [0].date | X | X | X | X | X | login date |
| | [0].time | X | X | X | X | login time | | | [0].time | X | X | X | X | X | login time |
| | [0].ip | X | X | X | | ip address (remote login) | | | [0].ip | X | X | X | | X | ip address (remote login) |
| | [0].command | X | X | X | | last command or shell | | | [0].command | X | X | X | | X | last command or shell |
#### 5. File System #### 5. File System
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.fsSize(cb) | [{...}] | X | X | X | X | returns array of mounted file systems | | si.fsSize(cb) | [{...}] | X | X | X | X | | returns array of mounted file systems |
| | [0].fs | X | X | X | X | name of file system | | | [0].fs | X | X | X | X | | name of file system |
| | [0].type | X | X | X | X | type of file system | | | [0].type | X | X | X | X | | type of file system |
| | [0].size | X | X | X | X | sizes in bytes | | | [0].size | X | X | X | X | | sizes in bytes |
| | [0].used | X | X | X | X | used in bytes | | | [0].used | X | X | X | X | | used in bytes |
| | [0].use | X | X | X | X | used in % | | | [0].use | X | X | X | X | | used in % |
| | [0].mount | X | X | X | X | mount point | | | [0].mount | X | X | X | X | | mount point |
| si.blockDevices(cb) | [{...}] | X | | X | X | returns array of disks, partitions,<br>raids and roms | | si.blockDevices(cb) | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids and roms |
| | [0].name | X | | X | X | name | | | [0].name | X | | X | X | | name |
| | [0].type | X | | X | X | type | | | [0].type | X | | X | X | | type |
| | [0].fstype | X | | X | X | file system type (e.g. ext4) | | | [0].fstype | X | | X | X | | file system type (e.g. ext4) |
| | [0].mount | X | | X | X | mount point | | | [0].mount | X | | X | X | | mount point |
| | [0].size | X | | X | X | size in bytes | | | [0].size | X | | X | X | | size in bytes |
| | [0].physical | X | | X | X | physical type (HDD, SSD, CD/DVD) | | | [0].physical | X | | X | X | | physical type (HDD, SSD, CD/DVD) |
| | [0].uuid | X | | X | X | UUID | | | [0].uuid | X | | X | X | | UUID |
| | [0].label | X | | X | X | label | | | [0].label | X | | X | X | | label |
| | [0].model | X | | X | | model | | | [0].model | X | | X | | | model |
| | [0].serial | X | | | X | serial | | | [0].serial | X | | | X | | serial |
| | [0].removable | X | | X | X | serial | | | [0].removable | X | | X | X | | serial |
| | [0].protocol | X | | X | | protocol (SATA, PCI-Express, ...) | | | [0].protocol | X | | X | | | protocol (SATA, PCI-Express, ...) |
| si.fsStats(cb) | {...} | X | | X | | current transfer stats | | si.fsStats(cb) | {...} | X | | X | | | current transfer stats |
| | rx | X | | X | | bytes read since startup | | | rx | X | | X | | | bytes read since startup |
| | wx | X | | X | | bytes written since startup | | | wx | X | | X | | | bytes written since startup |
| | tx | X | | X | | total bytes read + written since startup | | | tx | X | | X | | | total bytes read + written since startup |
| | rx_sec | X | | X | | bytes read / second (* see notes) | | | rx_sec | X | | X | | | bytes read / second (* see notes) |
| | wx_sec | X | | X | | bytes written / second (* see notes) | | | wx_sec | X | | X | | | bytes written / second (* see notes) |
| | tx_sec | X | | X | | total bytes reads + written / second | | | tx_sec | X | | X | | | total bytes reads + written / second |
| | ms | X | | X | | interval length (for per second values) | | | ms | X | | X | | | interval length (for per second values) |
| si.disksIO(cb) | {...} | X | | X | | current transfer stats | | si.disksIO(cb) | {...} | X | | X | | | current transfer stats |
| | rIO | X | | X | | read IOs on all mounted drives | | | rIO | X | | X | | | read IOs on all mounted drives |
| | wIO | X | | X | | write IOs on all mounted drives | | | wIO | X | | X | | | write IOs on all mounted drives |
| | tIO | X | | X | | write IOs on all mounted drives | | | tIO | X | | X | | | write IOs on all mounted drives |
| | rIO_sec | X | | X | | read IO per sec (* see notes) | | | rIO_sec | X | | X | | | read IO per sec (* see notes) |
| | wIO_sec | X | | X | | write IO per sec (* see notes) | | | wIO_sec | X | | X | | | write IO per sec (* see notes) |
| | tIO_sec | X | | X | | total IO per sec (* see notes) | | | tIO_sec | X | | X | | | total IO per sec (* see notes) |
| | ms | X | | X | | interval length (for per second values) | | | ms | X | | X | | | interval length (for per second values) |
#### 6. Network related functions #### 6. Network related functions
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.networkInterfaces(cb) | [{...}] | X | X | X | X | array of network interfaces | | si.networkInterfaces(cb) | [{...}] | X | X | X | X | X | array of network interfaces |
| | [0].iface | X | X | X | X | interface name | | | [0].iface | X | X | X | X | X | interface name |
| | [0].ip4 | X | X | X | X | ip4 address | | | [0].ip4 | X | X | X | X | X | ip4 address |
| | [0].ip6 | X | X | X | X | ip6 address | | | [0].ip6 | X | X | X | X | X | ip6 address |
| | [0].mac | X | X | X | X | MAC address | | | [0].mac | X | X | X | X | X | MAC address |
| | [0].internal | X | X | X | X | true if internal interface | | | [0].internal | X | X | X | X | X | true if internal interface |
| si.networkInterfaceDefault(cb) | : string | X | X | X | X | get name of default network interface | | si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface |
| si.networkStats(iface,cb) | {...} | X | X | X | X | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface| | si.networkStats(iface,cb) | {...} | X | X | X | X | | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface|
| | iface | X | X | X | X | interface | | | iface | X | X | X | X | | interface |
| | operstate | X | X | X | X | up / down | | | operstate | X | X | X | X | | up / down |
| | rx | X | X | X | X | received bytes overall | | | rx | X | X | X | X | | received bytes overall |
| | tx | X | X | X | X | transferred bytes overall | | | tx | X | X | X | X | | transferred bytes overall |
| | rx_sec | X | X | X | X | received bytes / second (* see notes) | | | rx_sec | X | X | X | X | | received bytes / second (* see notes) |
| | tx_sec | X | X | X | X | transferred bytes per second (* see notes) | | | tx_sec | X | X | X | X | | transferred bytes per second (* see notes) |
| | ms | X | X | X | X | interval length (for per second values) | | | ms | X | X | X | X | | interval length (for per second values) |
| si.networkConnections(cb) | [{...}] | X | X | X | X | current network network connections<br>returns an array of all connections| | si.networkConnections(cb) | [{...}] | X | X | X | X | | current network network connections<br>returns an array of all connections|
| | [0].protocol | X | X | X | X | tcp or udp | | | [0].protocol | X | X | X | X | | tcp or udp |
| | [0].localaddress | X | X | X | X | local address | | | [0].localaddress | X | X | X | X | | local address |
| | [0].localport | X | X | X | X | local port | | | [0].localport | X | X | X | X | | local port |
| | [0].peeraddress | X | X | X | X | peer address | | | [0].peeraddress | X | X | X | X | | peer address |
| | [0].peerport | X | X | X | X | peer port | | | [0].peerport | X | X | X | X | | peer port |
| | [0].state | X | X | X | X | like ESTABLISHED, TIME_WAIT, ... | | | [0].state | X | X | X | X | | like ESTABLISHED, TIME_WAIT, ... |
| si.inetChecksite(url, cb) | {...} | X | X | X | X | response-time (ms) to fetch given URL | | si.inetChecksite(url, cb) | {...} | X | X | X | X | X | response-time (ms) to fetch given URL |
| | url | X | X | X | X | given url | | | url | X | X | X | X | X | given url |
| | ok | X | X | X | X | status code OK (2xx, 3xx) | | | ok | X | X | X | X | X | status code OK (2xx, 3xx) |
| | status | X | X | X | X | status code | | | status | X | X | X | X | X | status code |
| | ms | X | X | X | X | response time in ms | | | ms | X | X | X | X | X | response time in ms |
| si.inetLatency(host, cb) | : number | X | X | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)| | si.inetLatency(host, cb) | : number | X | X | X | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)|
#### 7. Current Load, Processes & Services #### 7. Current Load, Processes & Services
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.currentLoad(cb) | {...} | X | | X | X | CPU-Load | | si.currentLoad(cb) | {...} | X | | X | X | X | CPU-Load |
| | avgload | X | | X | X | average load | | | avgload | X | | X | X | X | average load |
| | currentload | X | | X | X | CPU load in % | | | currentload | X | | X | X | X | CPU load in % |
| | currentload_user | X | | X | X | CPU load user in % | | | currentload_user | X | | X | X | X | CPU load user in % |
| | currentload_system | X | | X | X | CPU load system in % | | | currentload_system | X | | X | X | X | CPU load system in % |
| | currentload_nice | X | | X | X | CPU load nice in % | | | currentload_nice | X | | X | X | X | CPU load nice in % |
| | currentload_idle | X | | X | X | CPU load idle in % | | | currentload_idle | X | | X | X | X | CPU load idle in % |
| | currentload_irq | X | | X | X | CPU load system in % | | | currentload_irq | X | | X | X | X | CPU load system in % |
| | raw_currentload... | X | | X | X | CPU load raw values (ticks) | | | raw_currentload... | X | | X | X | X | CPU load raw values (ticks) |
| | cpus[] | X | | X | X | current loads per CPU in % + raw ticks | | | cpus[] | X | | X | X | X | current loads per CPU in % + raw ticks |
| si.fullLoad(cb) | : integer | X | | X | X | CPU full load since bootup in % | | si.fullLoad(cb) | : integer | X | | X | X | | CPU full load since bootup in % |
| si.processes(cb) | {...} | X | X | X | X | # running processes | | si.processes(cb) | {...} | X | X | X | X | X | # running processes |
| | all | X | X | X | X | # of all processes | | | all | X | X | X | X | X | # of all processes |
| | running | X | X | X | X | # of all processes running | | | running | X | X | X | X | X | # of all processes running |
| | blocked | X | X | X | X | # of all processes blocked | | | blocked | X | X | X | X | X | # of all processes blocked |
| | sleeping | X | X | X | X | # of all processes sleeping | | | sleeping | X | X | X | X | X | # of all processes sleeping |
| | unknown | | | | X | # of all processes unknown status | | | unknown | | | | X | | # of all processes unknown status |
| | list[] | X | X | X | X | list of all processes incl. details | | | list[] | X | X | X | X | X | list of all processes incl. details |
| | ...[0].pid | X | X | X | X | process PID | | | ...[0].pid | X | X | X | X | X | process PID |
| | ...[0].name | X | X | X | X | process name | | | ...[0].name | X | X | X | X | X | process name |
| | ...[0].pcpu | X | X | X | X | process % CPU usage | | | ...[0].pcpu | X | X | X | X | X | process % CPU usage |
| | ...[0].pcpuu | X | X | | X | process % CPU usage (user) | | | ...[0].pcpuu | X | X | | X | | process % CPU usage (user) |
| | ...[0].pcpus | X | X | | X | process % CPU usage (system) | | | ...[0].pcpus | X | X | | X | | process % CPU usage (system) |
| | ...[0].pmem | X | X | X | X | process memory % | | | ...[0].pmem | X | X | X | X | X | process memory % |
| | ...[0].priority | X | X | X | X | process priotity | | | ...[0].priority | X | X | X | X | X | process priotity |
| | ...[0].mem_vsz | X | X | X | X | process virtual memory size | | | ...[0].mem_vsz | X | X | X | X | X | process virtual memory size |
| | ...[0].mem_rss | X | X | X | X | process mem resident set size | | | ...[0].mem_rss | X | X | X | X | X | process mem resident set size |
| | ...[0].nice | X | X | X | | process nice value | | | ...[0].nice | X | X | X | | X | process nice value |
| | ...[0].started | X | X | X | X | process start time | | | ...[0].started | X | X | X | X | X | process start time |
| | ...[0].state | X | X | X | X | process state (e.g. sleeping) | | | ...[0].state | X | X | X | X | X | process state (e.g. sleeping) |
| | ...[0].tty | X | X | X | | tty from which process was started | | | ...[0].tty | X | X | X | | X | tty from which process was started |
| | ...[0].user | X | X | X | | user who started process | | | ...[0].user | X | X | X | | X | user who started process |
| | ...[0].command | X | X | X | X | process starting command | | | ...[0].command | X | X | X | X | X | process starting command |
| si.processLoad('apache2',cb) | {...} | X | X | X | | detailed information about given process | | si.processLoad('apache2',cb) | {...} | X | X | X | | | detailed information about given process |
| | proc | X | X | X | | process name | | | proc | X | X | X | | | process name |
| | pid | X | X | X | | PID | | | pid | X | X | X | | | PID |
| | cpu | X | X | X | | process % CPU | | | cpu | X | X | X | | | process % CPU |
| | mem | X | X | X | | process % MEM | | | mem | X | X | X | | | process % MEM |
| si.services('mysql, apache2', cb) | [{...}] | X | X | X | X | pass comma separated string of services | | si.services('mysql, apache2', cb) | [{...}] | X | X | X | X | | pass comma separated string of services |
| | [0].name | X | X | X | X | name of service | | | [0].name | X | X | X | X | | name of service |
| | [0].running | X | X | X | X | true / false | | | [0].running | X | X | X | X | | true / false |
| | [0].pcpu | X | X | X | | process % CPU | | | [0].pcpu | X | X | X | | | process % CPU |
| | [0].pmem | X | X | X | | process % MEM | | | [0].pmem | X | X | X | | | process % MEM |
#### 8. Docker #### 8. Docker
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.dockerContainers(all, cb) | [{...}] | X | X | X | X | returns array of active/all docker containers | | si.dockerContainers(all, cb) | [{...}] | X | X | X | X | X | returns array of active/all docker containers |
| | [0].id | X | X | X | X | ID of container | | | [0].id | X | X | X | X | X | ID of container |
| | [0].name | X | X | X | X | name of container | | | [0].name | X | X | X | X | X | name of container |
| | [0].image | X | X | X | X | name of image | | | [0].image | X | X | X | X | X | name of image |
| | [0].imageID | X | X | X | X | ID of image | | | [0].imageID | X | X | X | X | X | ID of image |
| | [0].command | X | X | X | X | command | | | [0].command | X | X | X | X | X | command |
| | [0].created | X | X | X | X | creation time | | | [0].created | X | X | X | X | X | creation time |
| | [0].state | X | X | X | X | created, running, exited | | | [0].state | X | X | X | X | X | created, running, exited |
| | [0].ports | X | X | X | X | array of ports | | | [0].ports | X | X | X | X | X | array of ports |
| | [0].mounts | X | X | X | X | array of mounts | | | [0].mounts | X | X | X | X | X | array of mounts |
| si.dockerContainerStats(id, cb) | {...} | X | X | X | X | statistics for a specific container | | si.dockerContainerStats(id, cb) | {...} | X | X | X | X | X | statistics for a specific container |
| | id | X | X | X | X | Container ID | | | id | X | X | X | X | X | Container ID |
| | mem_usage | X | X | X | X | memory usage in bytes | | | mem_usage | X | X | X | X | X | memory usage in bytes |
| | mem_limit | X | X | X | X | memory limit (max mem) in bytes | | | mem_limit | X | X | X | X | X | memory limit (max mem) in bytes |
| | mem_percent | X | X | X | X | memory usage in percent | | | mem_percent | X | X | X | X | X | memory usage in percent |
| | cpu_percent | X | X | X | X | cpu usage in percent | | | cpu_percent | X | X | X | X | X | cpu usage in percent |
| | pids | X | X | X | X | number of processes | | | pids | X | X | X | X | X | number of processes |
| | netIO.rx | X | X | X | X | received bytes via network | | | netIO.rx | X | X | X | X | X | received bytes via network |
| | netIO.wx | X | X | X | X | sent bytes via network | | | netIO.wx | X | X | X | X | X | sent bytes via network |
| | blockIO.r | X | X | X | X | bytes read from BlockIO | | | blockIO.r | X | X | X | X | X | bytes read from BlockIO |
| | blockIO.w | X | X | X | X | bytes written to BlockIO | | | blockIO.w | X | X | X | X | X | bytes written to BlockIO |
| | cpu_stats | X | X | X | X | detailed cpu stats | | | cpu_stats | X | X | X | X | X | detailed cpu stats |
| | percpu_stats | X | X | X | X | detailed per cpu stats | | | percpu_stats | X | X | X | X | X | detailed per cpu stats |
| | memory_stats | X | X | X | X | detailed memory stats | | | memory_stats | X | X | X | X | X | detailed memory stats |
| | networks | X | X | X | X | detailed network stats per interface | | | networks | X | X | X | X | X | detailed network stats per interface |
| si.dockerContainerProcesses(id, cb) | [{...}] | X | X | X | X | array of processes inside a container | | si.dockerContainerProcesses(id, cb) | [{...}] | X | X | X | X | X | array of processes inside a container |
| | [0].pid_host | X | X | X | X | process ID (host) | | | [0].pid_host | X | X | X | X | X | process ID (host) |
| | [0].ppid | X | X | X | X | parent process ID | | | [0].ppid | X | X | X | X | X | parent process ID |
| | [0].pgid | X | X | X | X | process group ID | | | [0].pgid | X | X | X | X | X | process group ID |
| | [0].user | X | X | X | X | effective user name | | | [0].user | X | X | X | X | X | effective user name |
| | [0].ruser | X | X | X | X | real user name | | | [0].ruser | X | X | X | X | X | real user name |
| | [0].group | X | X | X | X | effective group name | | | [0].group | X | X | X | X | X | effective group name |
| | [0].rgroup | X | X | X | X | real group name | | | [0].rgroup | X | X | X | X | X | real group name |
| | [0].stat | X | X | X | X | process state | | | [0].stat | X | X | X | X | X | process state |
| | [0].time | X | X | X | X | accumulated CPU time | | | [0].time | X | X | X | X | X | accumulated CPU time |
| | [0].elapsed | X | X | X | X | elapsed running time | | | [0].elapsed | X | X | X | X | X | elapsed running time |
| | [0].nice | X | X | X | X | nice value | | | [0].nice | X | X | X | X | X | nice value |
| | [0].rss | X | X | X | X | resident set size | | | [0].rss | X | X | X | X | X | resident set size |
| | [0].vsz | X | X | X | X | virtual size in Kbytes | | | [0].vsz | X | X | X | X | X | virtual size in Kbytes |
| | [0].command | X | X | X | X | command and arguments | | | [0].command | X | X | X | X | X | command and arguments |
| si.dockerAll(cb) | {...} | X | X | X | X | list of all containers including their stats<br>and processes in one single array | | si.dockerAll(cb) | {...} | X | X | X | X | X | list of all containers including their stats<br>and processes in one single array |
#### 9. "Get All at once" - functions #### 9. "Get All at once" - functions
| Function | Result object | Linux | FreeBSD | macOS | Win | Comments | | Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | -------- | | --------------- | ------------- | ----- | ------- | --- | --- | -------- |
| si.getStaticData(cb) | {...} | X | X | X | X | all static data at once | | si.getStaticData(cb) | {...} | X | X | X | X | | all static data at once |
| si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | all dynamic data at once | | si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | | all dynamic data at once |
| si.getAllData(srv,iface,cb) | {...} | X | X | X | X | all data at once | | si.getAllData(srv,iface,cb) | {...} | X | X | X | X | | all data at once |
### cb: Asynchronous Function Calls (callback) ### cb: Asynchronous Function Calls (callback)
@ -575,7 +576,7 @@ Windows is a registered trademark of Microsoft Corporation. Node.js is a tradema
Intel is a trademark of Intel Corporation, AMD is a trademark of Advanced Micro Devices Inc., Intel is a trademark of Intel Corporation, AMD is a trademark of Advanced Micro Devices Inc.,
Raspberry Pi is a trademark of the Raspberry Pi Foundation, Debian is a trademark of the Debian Project, Raspberry Pi is a trademark of the Raspberry Pi Foundation, Debian is a trademark of the Debian Project,
Ubuntu is a trademark of Canonical Ltd., FreeBSD is a registered trademark of The FreeBSD Foundation, Ubuntu is a trademark of Canonical Ltd., FreeBSD is a registered trademark of The FreeBSD Foundation,
Docker is a trademark of Docker, Inc. Docker is a trademark of Docker, Inc., Sun, Solaris, OpenSolaris and registered trademarks of Sun Microsystems.
All other trademarks are the property of their respective owners. All other trademarks are the property of their respective owners.

View File

@ -631,9 +631,20 @@ function cpuFlags(callback) {
}); });
} }
result = flags.join(' ').trim(); result = flags.join(' ').trim();
if (!result) {
exec('cat /proc/cpuinfo', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
result = util.getValue(lines, 'features', ':', true).toLowerCase();
}
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
}); });
} else {
if (callback) { callback(result); }
resolve(result);
}
});
} }
if (_darwin) { if (_darwin) {
exec('sysctl machdep.cpu.features', function (error, stdout) { exec('sysctl machdep.cpu.features', function (error, stdout) {

View File

@ -148,7 +148,7 @@ function inetLatency(host, callback) {
if (line.length > 1) { if (line.length > 1) {
const parts = line[1].split('/'); const parts = line[1].split('/');
if (parts.length > 1) { if (parts.length > 1) {
result = parseFloat(parts[1]); result = parseFloat(parts[1].replace(',', '.'));
} }
} }
} }

View File

@ -53,11 +53,11 @@ function getDefaultNetworkInterface() {
}); });
} }
} }
if (_linux || _darwin || _freebsd || _openbsd) { if (_linux || _darwin || _freebsd || _openbsd || _sunos) {
let cmd = ''; let cmd = '';
if (_linux) cmd = 'route 2>/dev/null | grep default | awk \'{print $8}\''; if (_linux) cmd = 'route 2>/dev/null | grep default | awk \'{print $8}\'';
if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\''; if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\'';
if (_freebsd || _openbsd) cmd = 'route get 0.0.0.0 | grep interface:'; if (_freebsd || _openbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:';
let result = execSync(cmd); let result = execSync(cmd);
ifacename = result.toString().split('\n')[0]; ifacename = result.toString().split('\n')[0];
if (ifacename.indexOf(':') > -1) { if (ifacename.indexOf(':') > -1) {

View File

@ -53,7 +53,7 @@ exports.time = time;
function getLogoFile(distro) { function getLogoFile(distro) {
distro = distro || ''; distro = distro || '';
distro = distro.toLowerCase(); distro = distro.toLowerCase();
let result = 'linux'; let result = _platform;
if (_windows) { if (_windows) {
result = 'windows'; result = 'windows';
} }
@ -144,6 +144,9 @@ function getLogoFile(distro) {
else if (distro.indexOf('ubuntu') !== -1) { else if (distro.indexOf('ubuntu') !== -1) {
result = 'ubuntu'; result = 'ubuntu';
} }
else if (distro.indexOf('solaris') !== -1) {
result = 'solaris';
}
return result; return result;
} }
@ -229,11 +232,13 @@ function osInfo(callback) {
}); });
} }
if (_sunos) { if (_sunos) {
result.logofile = getLogoFile();
result.release = result.kernel; result.release = result.kernel;
exec('uname -o', function (error, stdout) { exec('uname -o', function (error, stdout) {
let lines = stdout.toString().split('\n'); let lines = stdout.toString().split('\n');
result.distro = lines[0]; result.distro = lines[0];
result.logofile = getLogoFile(result.distro);
if (callback) { callback(result); }
resolve(result);
}); });
} }
if (_windows) { if (_windows) {

View File

@ -284,7 +284,7 @@ function processes(callback) {
checkColumn(5); checkColumn(5);
let rss = parseInt(line.substring(parsedhead[5].from + offset, parsedhead[5].to + offset2)); let rss = parseInt(line.substring(parsedhead[5].from + offset, parsedhead[5].to + offset2));
checkColumn(6); checkColumn(6);
let nice = parseInt(line.substring(parsedhead[6].from + offset, parsedhead[6].to + offset2)); let nice = parseInt(line.substring(parsedhead[6].from + offset, parsedhead[6].to + offset2)) || 0;
checkColumn(7); checkColumn(7);
let started = line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2).trim(); let started = line.substring(parsedhead[7].from + offset, parsedhead[7].to + offset2).trim();
checkColumn(8); checkColumn(8);

View File

@ -58,55 +58,81 @@ function system(callback) {
if (result.model.toLowerCase().indexOf('o.e.m.') !== -1) result.model = 'Computer'; if (result.model.toLowerCase().indexOf('o.e.m.') !== -1) result.model = 'Computer';
if (result.version.toLowerCase().indexOf('o.e.m.') !== -1) result.version = '-'; if (result.version.toLowerCase().indexOf('o.e.m.') !== -1) result.version = '-';
if (result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-'; if (result.sku.toLowerCase().indexOf('o.e.m.') !== -1) result.sku = '-';
}
// detect docker
if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) {
result.model = 'Docker Container';
}
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') { // still default values
exec('dmesg | grep -i virtual | grep -iE "vmware|qemu|kvm|xen"', function (error, stdout) {
// detect virtual machines
if (!error) {
let lines = stdout.toString().split('\n');
if (lines.length > 0) result.model = 'Virtual machine';
}
if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') { if (result.manufacturer === '' && result.model === 'Computer' && result.version === '-') {
// Check Raspberry Pi // Check Raspberry Pi
exec('grep Hardware /proc/cpuinfo; grep Serial /proc/cpuinfo; grep Revision /proc/cpuinfo', function (error, stdout) { exec('cat /proc/cpuinfo', function (error, stdout) {
if (!error) { if (!error) {
let lines = stdout.toString().split('\n'); let lines = stdout.toString().split('\n');
lines.forEach(function (line) { result.model = util.getValue(lines, 'hardware', ':', true).toUpperCase();
if (line.indexOf(':') !== -1) { result.version = util.getValue(lines, 'revision', ':', true).toLowerCase();
if (line.toLowerCase().indexOf('hardware') !== -1) result.model = line.split(':')[1].trim(); result.serial = util.getValue(lines, 'serial', ':', true);
if (line.toLowerCase().indexOf('revision') !== -1) result.version = line.split(':')[1].trim();
if (line.toLowerCase().indexOf('serial') !== -1) result.serial = line.split(':')[1].trim(); // reference values: https://elinux.org/RPi_HardwareHistory
} if (result.model === 'BCM2835' || result.model === 'BCM2708' || result.model === 'BCM2709' || result.model === 'BCM2835' || result.model === 'BCM2837') {
});
if (result.model === 'BCM2835') { // Pi 3 // Pi 3
result.manufacturer = 'Raspberry Pi Foundation';
result.model = result.model + ' - Pi 3 Model B';
if (['a02082', 'a22082', 'a32082'].indexOf(result.version) >= 0) { if (['a02082', 'a22082', 'a32082'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 3 Model B';
result.version = result.version + ' - Rev. 1.2'; result.version = result.version + ' - Rev. 1.2';
} }
if (['a020d3'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 3 Model B';
result.version = result.version + ' - Rev. 1.3';
} }
if (result.model === 'BCM2709') { // Pi 2 // Pi 2 Model B
result.manufacturer = 'Raspberry Pi Foundation'; if (['a01040'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 2 Model B'; result.model = result.model + ' - Pi 2 Model B';
result.version = result.version + ' - Rev. 1.0';
}
if (['a01041', 'a21041'].indexOf(result.version) >= 0) { if (['a01041', 'a21041'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 2 Model B';
result.version = result.version + ' - Rev. 1.1'; result.version = result.version + ' - Rev. 1.1';
} }
if (['a22042'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi 2 Model B';
result.version = result.version + ' - Rev. 1.2';
} }
if (result.model === 'BCM2708') { // Pi, Pi Zero
result.manufacturer = 'Raspberry Pi Foundation'; // Pi Zero
if (['0002', '0003'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model B';
result.version = result.version + ' - Rev 1.0';
}
if (['900092'].indexOf(result.version) >= 0) { if (['900092'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Zero'; result.model = result.model + ' - Pi Zero';
result.version = result.version + ' - Rev 1.2'; result.version = result.version + ' - Rev 1.2';
} }
if (['900092', '900093', '920093'].indexOf(result.version) >= 0) { if (['900093', '920093'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Zero'; result.model = result.model + ' - Pi Zero';
result.version = result.version + ' - Rev 1.3'; result.version = result.version + ' - Rev 1.3';
} }
if (['0007', '0008', '0009'].indexOf(result.version) >= 0) { if (['9000c1'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model A'; result.model = result.model + ' - Pi Zero W';
result.version = result.version + ' - Rev 2.0'; result.version = result.version + ' - Rev 1.1';
}
// A, B, A+ B+
if (['0002', '0003'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model B';
result.version = result.version + ' - Rev 1.0';
} }
if (['0004', '0005', '0006', '000d', '000e', '000f'].indexOf(result.version) >= 0) { if (['0004', '0005', '0006', '000d', '000e', '000f'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model B'; result.model = result.model + ' - Pi Model B';
result.version = result.version + ' - Rev 2.0'; result.version = result.version + ' - Rev 2.0';
} }
if (['0007', '0008', '0009'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model A';
result.version = result.version + ' - Rev 2.0';
}
if (['0010'].indexOf(result.version) >= 0) { if (['0010'].indexOf(result.version) >= 0) {
result.model = result.model + ' - Pi Model B+'; result.model = result.model + ' - Pi Model B+';
result.version = result.version + ' - Rev 1.0'; result.version = result.version + ' - Rev 1.0';
@ -123,9 +149,11 @@ function system(callback) {
result.model = result.model + ' - Pi Model A+'; result.model = result.model + ' - Pi Model A+';
result.version = result.version + ' - Rev 1.1'; result.version = result.version + ' - Rev 1.1';
} }
if (result.model.indexOf('Pi') !== -1 && result.version) { // Pi, Pi Zero
result.manufacturer = 'Raspberry Pi Foundation';
}
} }
} }
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
}); });
@ -133,17 +161,6 @@ function system(callback) {
if (callback) { callback(result); } if (callback) { callback(result); }
resolve(result); resolve(result);
} }
} else {
exec('dmesg | grep -i virtual | grep -iE "vmware|qemu|kvm|xen"', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
if (lines.length > 0) result.model = 'Virtual machine';
}
if (fs.existsSync('/.dockerenv') || fs.existsSync('/.dockerinit')) {
result.model = 'Docker Container';
}
if (callback) { callback(result); }
resolve(result);
}); });
} }
}); });