very firet windows functions, extended processes list
This commit is contained in:
parent
26c6b72e7a
commit
b2b9f7928f
@ -94,6 +94,7 @@ Other changes
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 3.17.0 | 2017-02-19 | windows support for some first functions, extended process list (linux)|
|
||||||
| 3.16.0 | 2017-01-19 | blockDevices: added removable attribute + fix |
|
| 3.16.0 | 2017-01-19 | blockDevices: added removable attribute + fix |
|
||||||
| 3.15.1 | 2017-01-17 | minor cpuTemperature fix (OSX) |
|
| 3.15.1 | 2017-01-17 | minor cpuTemperature fix (OSX) |
|
||||||
| 3.15.0 | 2017-01-15 | added cpuTemperature also for OSX |
|
| 3.15.0 | 2017-01-15 | added cpuTemperature also for OSX |
|
||||||
|
|||||||
444
README.md
444
README.md
@ -10,7 +10,7 @@ Simple system and OS information library for [node.js][nodejs-url]
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
Collection of 30+ functions to retrieve detailed hardware, system and OS information (linux and OSX only)
|
Collection of 30+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and now partial Windows support)
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@ -42,6 +42,7 @@ si.cpu()
|
|||||||
|
|
||||||
### Latest Activity
|
### Latest Activity
|
||||||
|
|
||||||
|
- Version 3.17.0: windows support for some very first functions (work in progress)
|
||||||
- Version 3.16.0: `blockDevices`: added removable attribute
|
- Version 3.16.0: `blockDevices`: added removable attribute
|
||||||
- Version 3.15.0: added `cpuTemperature` also for OSX
|
- Version 3.15.0: added `cpuTemperature` also for OSX
|
||||||
- Version 3.14.0: added `currentLoad` per cpu/core, cpu cache (L1, L2, L3) and cpu flags
|
- Version 3.14.0: added `currentLoad` per cpu/core, cpu cache (L1, L2, L3) and cpu flags
|
||||||
@ -71,7 +72,8 @@ little library. This library is still work in progress. Version 3 comes with fur
|
|||||||
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 OS X (Mavericks, Yosemite, El Captain).
|
I was only able to test it on several Debian, Raspbian, Ubuntu distributions as well as OS X (Mavericks, Yosemite, El Captain).
|
||||||
Since version 2 nearly all functionality is available on OS X/Darwin platforms. But be careful, this library will definitely NOT work on Windows platforms!
|
Since version 2 nearly all functionality is available on OS X/Darwin platforms.
|
||||||
|
Be careful, this library has only very limited Windows support!
|
||||||
|
|
||||||
If you have comments, suggestions & reports, please feel free to contact me!
|
If you have comments, suggestions & reports, please feel free to contact me!
|
||||||
|
|
||||||
@ -99,219 +101,231 @@ This library is splitted in several sections:
|
|||||||
|
|
||||||
### Function Reference and OS Support
|
### Function Reference and OS Support
|
||||||
|
|
||||||
| Function | Linux | OS X | Comments |
|
| Function | Linux | OSX | Win | Comments |
|
||||||
| -------------- | ------ | ------ | ------- |
|
| --------------- | ----- | ---- | ------- | -------- |
|
||||||
| si.version() | X | X | library version (no callback/promise) |
|
| si.version() | X | X | X | library version (no callback/promise) |
|
||||||
| si.time() | X | X | time information (no callback/promise) |
|
| si.time() | X | X | X | time information (no callback/promise) |
|
||||||
| - current | X | X | local time |
|
| - current | X | X | X | local time |
|
||||||
| - uptime | X | X | uptime |
|
| - uptime | X | X | X | uptime |
|
||||||
| si.system(cb) | X | X | hardware information |
|
| si.system(cb) | X | X | X | hardware information |
|
||||||
| - manufacturer | X | X | e.g. 'MSI' |
|
| - manufacturer | X | X | X | e.g. 'MSI' |
|
||||||
| - model | X | X | model/product e.g. 'MS-7823' |
|
| - model | X | X | X | model/product e.g. 'MS-7823' |
|
||||||
| - version | X | X | version e.g. '1.0' |
|
| - version | X | X | X | version e.g. '1.0' |
|
||||||
| - serial | X | X | serial number |
|
| - serial | X | X | X | serial number |
|
||||||
| - uuid | X | X | UUID |
|
| - uuid | X | X | X | UUID |
|
||||||
| si.osInfo(cb) | X | X | OS information |
|
| si.osInfo(cb) | X | X | X | OS information |
|
||||||
| - platform | X | X | 'Linux' or 'Darwin' |
|
| - platform | X | X | X | 'Linux', 'Darwin', 'Windows' |
|
||||||
| - distro | X | X | |
|
| - distro | X | X | X | |
|
||||||
| - release | X | X | |
|
| - release | X | X | X | |
|
||||||
| - codename | | X | |
|
| - codename | | X | | |
|
||||||
| - kernel | X | X | kernel release - same as os.release() |
|
| - kernel | X | X | X | kernel release - same as os.release() |
|
||||||
| - arch | X | X | same as os.arch() |
|
| - arch | X | X | X | same as os.arch() |
|
||||||
| - hostname | X | X | same as os.hostname() |
|
| - hostname | X | X | X | same as os.hostname() |
|
||||||
| - logofile | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
| - logofile | X | X | X | e.g. 'apple', 'debian', 'fedora', ... |
|
||||||
| si.versions(cb) | X | X | Version information (kernel, ssl, node, ...) |
|
| si.versions(cb) | X | X | X | Version information (kernel, ssl, node, ...) |
|
||||||
| si.shell(cb) | X | X | standard shell |
|
| si.shell(cb) | X | X | | standard shell |
|
||||||
| si.cpu(cb) | X | X | CPU information|
|
| si.cpu(cb) | X | X | X | CPU information|
|
||||||
| - manufacturer | X | X | e.g. 'Intel(R)' |
|
| - manufacturer | X | X | X | e.g. 'Intel(R)' |
|
||||||
| - brand | X | X | e.g. 'Core(TM)2 Duo' |
|
| - brand | X | X | X | e.g. 'Core(TM)2 Duo' |
|
||||||
| - speed | X | X | in GHz e.g. '3.40' |
|
| - speed | X | X | X | in GHz e.g. '3.40' |
|
||||||
| - cores | X | X | # cores |
|
| - cores | X | X | X | # cores |
|
||||||
| si.cpuFlags(cb) | X | X | CPU flags|
|
| si.cpuFlags(cb) | X | X | | CPU flags|
|
||||||
| si.cpuCache(cb) | X | X | CPU cache sizes |
|
| si.cpuCache(cb) | X | X | | CPU cache sizes |
|
||||||
| - l1d | X | X | L1D size |
|
| - l1d | X | X | | L1D size |
|
||||||
| - l1i | X | X | L1I size |
|
| - l1i | X | X | | L1I size |
|
||||||
| - l2 | X | X | L2 size |
|
| - l2 | X | X | | L2 size |
|
||||||
| - l3 | X | X | L3 size |
|
| - l3 | X | X | | L3 size |
|
||||||
| si.cpuCurrentspeed(cb) | X | X | current CPU speed (in GHz)|
|
| si.cpuCurrentspeed(cb) | X | X | | current CPU speed (in GHz)|
|
||||||
| - avg | X | X | avg CPU speed (all cores) |
|
| - avg | X | X | | avg CPU speed (all cores) |
|
||||||
| - min | X | X | min CPU speed (all cores) |
|
| - min | X | X | | min CPU speed (all cores) |
|
||||||
| - max | X | X | max CPU speed (all cores) |
|
| - max | X | X | | max CPU speed (all cores) |
|
||||||
| si.cpuTemperature(cb) | X | X | CPU temperature (if sensors is installed) |
|
| si.cpuTemperature(cb) | X | X | X | CPU temperature (if sensors is installed) |
|
||||||
| - main | X | X | main temperature |
|
| - main | X | X | X | main temperature |
|
||||||
| - cores | X | X | array of temperatures |
|
| - cores | X | X | X | array of temperatures |
|
||||||
| - max | X | X | max temperature |
|
| - max | X | X | X | max temperature |
|
||||||
| si.mem(cb) | X | X | Memory information|
|
| si.mem(cb) | X | X | X | Memory information|
|
||||||
| - total | X | X | total memory |
|
| - total | X | X | X | total memory |
|
||||||
| - free | X | X | not used |
|
| - free | X | X | X | not used |
|
||||||
| - used | X | X | used (incl. buffers/cache) |
|
| - used | X | X | X | used (incl. buffers/cache) |
|
||||||
| - active | X | X | used actively (excl. buffers/cache) |
|
| - active | X | X | X | used actively (excl. buffers/cache) |
|
||||||
| - buffcache | X | X | used by buffers+cache |
|
| - buffcache | X | X | | used by buffers+cache |
|
||||||
| - available | X | X | potentially available (total - active) |
|
| - available | X | X | X | potentially available (total - active) |
|
||||||
| - swaptotal | X | X | |
|
| - swaptotal | X | X | | |
|
||||||
| - swapused | X | X | |
|
| - swapused | X | X | | |
|
||||||
| - swapfree | X | X | |
|
| - swapfree | X | X | | |
|
||||||
| si.battery(cb) | X | X | battery information |
|
| si.battery(cb) | X | X | | battery information |
|
||||||
| - hasbattery | X | X | indicates presence of battery |
|
| - hasbattery | X | X | | indicates presence of battery |
|
||||||
| - ischarging | X | X | indicates if battery is charging |
|
| - ischarging | X | X | | indicates if battery is charging |
|
||||||
| - maxcapacity | X | X | max capacity of battery |
|
| - maxcapacity | X | X | | max capacity of battery |
|
||||||
| - currentcapacity | X | X | current capacity of battery |
|
| - currentcapacity | X | X | | current capacity of battery |
|
||||||
| - percent | X | X | charging level in percent |
|
| - percent | X | X | | charging level in percent |
|
||||||
| si.graphics(cb) | X | X | arrays of graphics controllers and displays |
|
| si.graphics(cb) | X | X | | arrays of graphics controllers and displays |
|
||||||
| - controllers[0].model | X | X | graphics controller model |
|
| - controllers[0].model | X | X | | graphics controller model |
|
||||||
| - controllers[0].vendor | X | X | e.g. ATI |
|
| - controllers[0].vendor | X | X | | e.g. ATI |
|
||||||
| - controllers[0].bus | X | X | on which bus (e.g. PCIe) |
|
| - controllers[0].bus | X | X | | on which bus (e.g. PCIe) |
|
||||||
| - controllers[0].vram | X | X | VRAM size (in MB) |
|
| - controllers[0].vram | X | X | | VRAM size (in MB) |
|
||||||
| - controllers[0].vramDynamic | X | X | true if dynamicly allocated ram |
|
| - controllers[0].vramDynamic | X | X | | true if dynamicly allocated ram |
|
||||||
| - displays[0].model | X | X | Monitor/Display Model |
|
| - displays[0].model | X | X | | Monitor/Display Model |
|
||||||
| - displays[0].main | X | X | true if main monitor |
|
| - displays[0].main | X | X | | true if main monitor |
|
||||||
| - displays[0].builtin | X | X | true if built in monitor |
|
| - displays[0].builtin | X | X | | true if built in monitor |
|
||||||
| - displays[0].connection | X | X | e.g. DisplayPort or HDMI |
|
| - displays[0].connection | X | X | | e.g. DisplayPort or HDMI |
|
||||||
| - displays[0].resolutionx | X | X | pixel horizontal |
|
| - displays[0].resolutionx | X | X | | pixel horizontal |
|
||||||
| - displays[0].resolutiony | X | X | pixel vertical |
|
| - displays[0].resolutiony | X | X | | pixel vertical |
|
||||||
| - displays[0].depth | X | X | color depth in bits |
|
| - displays[0].depth | X | X | | color depth in bits |
|
||||||
| - displays[0].sizex | X | X | size in mm horizontal |
|
| - displays[0].sizex | X | X | | size in mm horizontal |
|
||||||
| - displays[0].sizey | X | X | size in mm vertical |
|
| - displays[0].sizey | X | X | | size in mm vertical |
|
||||||
| si.fsSize(cb) | X | X | returns array of mounted file systems |
|
| si.fsSize(cb) | X | X | X | returns array of mounted file systems |
|
||||||
| - [0].fs | X | X | name of file system |
|
| - [0].fs | X | X | X | name of file system |
|
||||||
| - [0].type | X | X | type of file system |
|
| - [0].type | X | X | X | type of file system |
|
||||||
| - [0].size | X | X | sizes in Bytes |
|
| - [0].size | X | X | X | sizes in Bytes |
|
||||||
| - [0].used | X | X | used in Bytes |
|
| - [0].used | X | X | X | used in Bytes |
|
||||||
| - [0].use | X | X | used in % |
|
| - [0].use | X | X | X | used in % |
|
||||||
| - [0].mount | X | X | mount point |
|
| - [0].mount | X | X | X | mount point |
|
||||||
| si.blockDevices(cb) | 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 | name |
|
| - [0].name | X | X | X | name |
|
||||||
| - [0].type | X | X | type |
|
| - [0].type | X | X | X | type |
|
||||||
| - [0].fstype | X | X | file system type (e.g. ext4) |
|
| - [0].fstype | X | X | X | file system type (e.g. ext4) |
|
||||||
| - [0].mount | X | X | mount point |
|
| - [0].mount | X | X | X | mount point |
|
||||||
| - [0].size | X | X | size in bytes |
|
| - [0].size | X | X | X | size in bytes |
|
||||||
| - [0].physical | X | X | physical type (HDD, SSD, CD/DVD) |
|
| - [0].physical | X | X | X | physical type (HDD, SSD, CD/DVD) |
|
||||||
| - [0].uuid | X | X | UUID |
|
| - [0].uuid | X | X | X | UUID |
|
||||||
| - [0].label | X | X | label |
|
| - [0].label | X | X | X | label |
|
||||||
| - [0].model | X | X | model |
|
| - [0].model | X | X | | model |
|
||||||
| - [0].serial | X | | serial |
|
| - [0].serial | X | | X | serial |
|
||||||
| - [0].removable | 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) |
|
||||||
| si.networkInterfaces(cb) | X | X | array of network interfaces |
|
| si.networkInterfaces(cb) | X | X | | array of network interfaces |
|
||||||
| - [0].iface | X | X | interface name |
|
| - [0].iface | X | X | | interface name |
|
||||||
| - [0].ip4 | X | X | ip4 address |
|
| - [0].ip4 | X | X | | ip4 address |
|
||||||
| - [0].ip6 | X | X | ip6 address |
|
| - [0].ip6 | X | X | | ip6 address |
|
||||||
| - [0].mac | X | X | MAC address |
|
| - [0].mac | X | X | | MAC address |
|
||||||
| - [0].internal | X | X | true if internal interface |
|
| - [0].internal | X | X | | true if internal interface |
|
||||||
| si.networkInterfaceDefault(cb) | X | X | get name of default network interface |
|
| si.networkInterfaceDefault(cb) | X | X | | get name of default network interface |
|
||||||
| si.networkStats(iface,cb) | 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 | | current network stats of given interface<br>iface parameter is optional<br>defaults to first external network interface|
|
||||||
| - iface | X | X | interface |
|
| - iface | X | X | | interface |
|
||||||
| - operstate | X | X | up / down |
|
| - operstate | X | X | | up / down |
|
||||||
| - rx | X | X | received bytes overall |
|
| - rx | X | X | | received bytes overall |
|
||||||
| - tx | X | X | transferred bytes overall|
|
| - tx | X | X | | transferred bytes overall|
|
||||||
| - rx_sec | X | X | received bytes / second (* see notes) |
|
| - rx_sec | X | X | | received bytes / second (* see notes) |
|
||||||
| - tx_sec | X | X | transferred bytes per second (* see notes) |
|
| - tx_sec | X | X | | transferred bytes per second (* see notes) |
|
||||||
| - ms | X | X | interval length (for per second values) |
|
| - ms | X | X | | interval length (for per second values) |
|
||||||
| si.networkConnections(cb) | X | X | current network network connections<br>returns an array of all connections|
|
| si.networkConnections(cb) | X | X | | current network network connections<br>returns an array of all connections|
|
||||||
| - [0].protocol | X | X | tcp or udp |
|
| - [0].protocol | X | X | | tcp or udp |
|
||||||
| - [0].localaddress | X | X | local address |
|
| - [0].localaddress | X | X | | local address |
|
||||||
| - [0].localport | X | X | local port |
|
| - [0].localport | X | X | | local port |
|
||||||
| - [0].peeraddress | X | X | peer address |
|
| - [0].peeraddress | X | X | | peer address |
|
||||||
| - [0].peerport | X | X | peer port |
|
| - [0].peerport | X | X | | peer port |
|
||||||
| - [0].state | X | X | like ESTABLISHED, TIME_WAIT, ... |
|
| - [0].state | X | X | | like ESTABLISHED, TIME_WAIT, ... |
|
||||||
| si.currentLoad(cb) | X | X | CPU-Load |
|
| si.currentLoad(cb) | X | X | | CPU-Load |
|
||||||
| - avgload | X | X | average load |
|
| - avgload | X | X | | average load |
|
||||||
| - currentload | X | X | CPU-Load in % |
|
| - currentload | X | X | | CPU-Load in % |
|
||||||
| - currentload_user | X | X | CPU-Load User in % |
|
| - currentload_user | X | X | | CPU-Load User in % |
|
||||||
| - currentload_nice | X | X | CPU-Load Nice in % |
|
| - currentload_nice | X | X | | CPU-Load Nice in % |
|
||||||
| - currentload_system | X | X | CPU-Load System in % |
|
| - currentload_system | X | X | | CPU-Load System in % |
|
||||||
| - currentload_irq | X | X | CPU-Load System in % |
|
| - currentload_irq | X | X | | CPU-Load System in % |
|
||||||
| - cpus[] | X | X | current loads per CPU in % |
|
| - cpus[] | X | X | | current loads per CPU in % |
|
||||||
| si.fullLoad(cb) | X | X | CPU-full load since bootup in % |
|
| si.fullLoad(cb) | X | X | | CPU-full load since bootup in % |
|
||||||
| si.services('mysql, apache2', cb) | X | X | pass comma separated string of services |
|
| si.services('mysql, apache2', cb) | X | X | | pass comma separated string of services |
|
||||||
| - [0].name | X | X | name of service |
|
| - [0].name | X | X | | name of service |
|
||||||
| - [0].running | X | X | true / false |
|
| - [0].running | X | X | | true / false |
|
||||||
| - [0].pcpu | X | X | process % CPU |
|
| - [0].pcpu | X | X | | process % CPU |
|
||||||
| - [0].pmem | X | X | process % MEM |
|
| - [0].pmem | X | X | | process % MEM |
|
||||||
| si.processes(cb) | X | X | # running processes |
|
| si.processes(cb) | X | X | | # running processes |
|
||||||
| - all | X | X | # of all processes |
|
| - all | X | X | | # of all processes |
|
||||||
| - running | X | X | # of all processes running |
|
| - running | X | X | | # of all processes running |
|
||||||
| - blocked | X | X | # of all processes blocked |
|
| - blocked | X | X | | # of all processes blocked |
|
||||||
| - sleeping | X | X | # of all processes sleeping |
|
| - sleeping | X | X | | # of all processes sleeping |
|
||||||
| - list | X | X | # list of all processes incl. details |
|
| - list[] | X | X | | list of all processes incl. details |
|
||||||
| si.processLoad('apache2',cb) | X | X | detailed information about given process |
|
| - ...[0].pid | X | X | | process PID |
|
||||||
| - proc | X | X | process name |
|
| - ...[0].pcpu | X | X | | process % CPU usage |
|
||||||
| - pid | X | X | PID |
|
| - ...[0].pcpuu | X | X | | process % CPU usage (user) |
|
||||||
| - cpu | X | X | process % CPU |
|
| - ...[0].pcpus | X | X | | process % CPU usage (system) |
|
||||||
| - mem | X | X | process % MEM |
|
| - ...[0].pmem | X | X | | process memory % |
|
||||||
| si.users(cb) | X | X | array of users online |
|
| - ...[0].priority | X | X | | process priotity |
|
||||||
| - [0].user | X | X | user name |
|
| - ...[0].mem_vsz | X | X | | process virtual memory size |
|
||||||
| - [0].tty | X | X | terminal |
|
| - ...[0].mem_rss | X | X | | process mem resident set size |
|
||||||
| - [0].date | X | X | login date |
|
| - ...[0].nice | X | X | | process nice value |
|
||||||
| - [0].time | X | X | login time |
|
| - ...[0].started | X | X | | process start time |
|
||||||
| - [0].ip | X | X | ip address (remote login) |
|
| - ...[0].state | X | X | | process state (e.g. sleeping) |
|
||||||
| - [0].command | X | X | last command or shell |
|
| - ...[0].tty | X | X | | tty from which process was started |
|
||||||
| si.inetChecksite(url, cb) | X | X | response-time (ms) to fetch given URL |
|
| si.processLoad('apache2',cb) | X | X | | detailed information about given process |
|
||||||
| - url | X | X | given url |
|
| - proc | X | X | | process name |
|
||||||
| - ok | X | X | status code OK (2xx, 3xx) |
|
| - pid | X | X | | PID |
|
||||||
| - status | X | X | status code |
|
| - cpu | X | X | | process % CPU |
|
||||||
| - ms | X | X | response time in ms |
|
| - mem | X | X | | process % MEM |
|
||||||
| si.inetLatency(host, cb) | X | X | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)|
|
| si.users(cb) | X | X | | array of users online |
|
||||||
| si.dockerContainers(all, cb) | X | X | returns array of active/all docker containers |
|
| - [0].user | X | X | | user name |
|
||||||
| - [0].id | X | X | ID of container |
|
| - [0].tty | X | X | | terminal |
|
||||||
| - [0].name | X | X | name of container |
|
| - [0].date | X | X | | login date |
|
||||||
| - [0].image | X | X | name of image |
|
| - [0].time | X | X | | login time |
|
||||||
| - [0].imageID | X | X | ID of image |
|
| - [0].ip | X | X | | ip address (remote login) |
|
||||||
| - [0].command | X | X | command |
|
| - [0].command | X | X | | last command or shell |
|
||||||
| - [0].created | X | X | creation time |
|
| si.inetChecksite(url, cb) | X | X | | response-time (ms) to fetch given URL |
|
||||||
| - [0].state | X | X | created, running, exited |
|
| - url | X | X | | given url |
|
||||||
| - [0].ports | X | X | array of ports |
|
| - ok | X | X | | status code OK (2xx, 3xx) |
|
||||||
| - [0].mounts | X | X | array of mounts |
|
| - status | X | X | | status code |
|
||||||
| si.dockerContainerStats(id, cb) | X | X | statistics for a specific container |
|
| - ms | X | X | | response time in ms |
|
||||||
| - id | X | X | Container ID |
|
| si.inetLatency(host, cb) | X | X | | response-time (ms) to external resource<br>host parameter is optional (default 8.8.8.8)|
|
||||||
| - mem_usage | X | X | memory usage in bytes |
|
| si.dockerContainers(all, cb) | X | X | | returns array of active/all docker containers |
|
||||||
| - mem_limit | X | X | memory limit (max mem) in bytes |
|
| - [0].id | X | X | | ID of container |
|
||||||
| - mem_percent | X | X | memory usage in percent |
|
| - [0].name | X | X | | name of container |
|
||||||
| - cpu_percent | X | X | cpu usage in percent |
|
| - [0].image | X | X | | name of image |
|
||||||
| - pids | X | X | number of processes |
|
| - [0].imageID | X | X | | ID of image |
|
||||||
| - netIO.rx | X | X | received bytes via network |
|
| - [0].command | X | X | | command |
|
||||||
| - netIO.wx | X | X | sent bytes via network |
|
| - [0].created | X | X | | creation time |
|
||||||
| - blockIO.r | X | X | bytes read from BlockIO |
|
| - [0].state | X | X | | created, running, exited |
|
||||||
| - blockIO.w | X | X | bytes written to BlockIO |
|
| - [0].ports | X | X | | array of ports |
|
||||||
| - cpu_stats | X | X | detailed cpu stats |
|
| - [0].mounts | X | X | | array of mounts |
|
||||||
| - percpu_stats | X | X | detailed per cpu stats |
|
| si.dockerContainerStats(id, cb) | X | X | | statistics for a specific container |
|
||||||
| - memory_stats | X | X | detailed memory stats |
|
| - id | X | X | | Container ID |
|
||||||
| - networks | X | X | detailed network stats per interface |
|
| - mem_usage | X | X | | memory usage in bytes |
|
||||||
| si.dockerContainerProcesses(id, cb) | X | X | array of processes inside a container |
|
| - mem_limit | X | X | | memory limit (max mem) in bytes |
|
||||||
| - [0].pid_host | X | X | process ID (host) |
|
| - mem_percent | X | X | | memory usage in percent |
|
||||||
| - [0].ppid | X | X | parent process ID |
|
| - cpu_percent | X | X | | cpu usage in percent |
|
||||||
| - [0].pgid | X | X | process group ID |
|
| - pids | X | X | | number of processes |
|
||||||
| - [0].user | X | X | effective user name |
|
| - netIO.rx | X | X | | received bytes via network |
|
||||||
| - [0].ruser | X | X | real user name |
|
| - netIO.wx | X | X | | sent bytes via network |
|
||||||
| - [0].group | X | X | effective group name |
|
| - blockIO.r | X | X | | bytes read from BlockIO |
|
||||||
| - [0].rgroup | X | X | real group name |
|
| - blockIO.w | X | X | | bytes written to BlockIO |
|
||||||
| - [0].stat | X | X | process state |
|
| - cpu_stats | X | X | | detailed cpu stats |
|
||||||
| - [0].time | X | X | accumulated CPU time |
|
| - percpu_stats | X | X | | detailed per cpu stats |
|
||||||
| - [0].elapsed | X | X | elapsed running time |
|
| - memory_stats | X | X | | detailed memory stats |
|
||||||
| - [0].nice | X | X | nice value |
|
| - networks | X | X | | detailed network stats per interface |
|
||||||
| - [0].rss | X | X | resident set size |
|
| si.dockerContainerProcesses(id, cb) | X | X | | array of processes inside a container |
|
||||||
| - [0].vsz | X | X | virtual size in Kbytes |
|
| - [0].pid_host | X | X | | process ID (host) |
|
||||||
| - [0].command | X | X | command and arguments |
|
| - [0].ppid | X | X | | parent process ID |
|
||||||
| si.dockerAll(cb) | X | X | list of all containers including their stats<br>and processes in one single array |
|
| - [0].pgid | X | X | | process group ID |
|
||||||
| si.getStaticData(cb) | X | X | all static data at once |
|
| - [0].user | X | X | | effective user name |
|
||||||
| si.getDynamicData(srv,iface,cb) | X | X | all dynamic data at once |
|
| - [0].ruser | X | X | | real user name |
|
||||||
| si.getAllData(srv,iface,cb) | X | X | all data at once |
|
| - [0].group | X | X | | effective group name |
|
||||||
|
| - [0].rgroup | X | X | | real group name |
|
||||||
|
| - [0].stat | X | X | | process state |
|
||||||
|
| - [0].time | X | X | | accumulated CPU time |
|
||||||
|
| - [0].elapsed | X | X | | elapsed running time |
|
||||||
|
| - [0].nice | X | X | | nice value |
|
||||||
|
| - [0].rss | X | X | | resident set size |
|
||||||
|
| - [0].vsz | X | X | | virtual size in Kbytes |
|
||||||
|
| - [0].command | X | X | | command and arguments |
|
||||||
|
| si.dockerAll(cb) | X | X | | list of all containers including their stats<br>and processes in one single array |
|
||||||
|
| si.getStaticData(cb) | X | X | | all static data at once |
|
||||||
|
| si.getDynamicData(srv,iface,cb) | X | X | | all dynamic data at once |
|
||||||
|
| si.getAllData(srv,iface,cb) | X | X | | all data at once |
|
||||||
|
|
||||||
### cb: Asynchronous Function Calls (callback)
|
### cb: Asynchronous Function Calls (callback)
|
||||||
|
|
||||||
|
|||||||
56
lib/cpu.js
56
lib/cpu.js
@ -61,14 +61,8 @@ function cpuBrandManufacturer(res) {
|
|||||||
|
|
||||||
function getCpu() {
|
function getCpu() {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
manufacturer: 'unknown',
|
manufacturer: 'unknown',
|
||||||
brand: 'unknown',
|
brand: 'unknown',
|
||||||
@ -105,6 +99,20 @@ function getCpu() {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
exec("wmic cpu get name", function (error, stdout) {
|
||||||
|
if (!error) {
|
||||||
|
let lines = stdout.split('\r\n').filter(line => line.trim() != '').filter((line, idx) => idx > 0);
|
||||||
|
let line = (lines && lines[0]) ? lines[0] : '';
|
||||||
|
result.brand = line.split('@')[0].trim();
|
||||||
|
result.speed = line.split('@')[1].trim();
|
||||||
|
result.speed = parseFloat(result.speed.replace(/GHz+/g, ""));
|
||||||
|
_cpu_speed = result.speed;
|
||||||
|
}
|
||||||
|
result = cpuBrandManufacturer(result);
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -116,12 +124,6 @@ function cpu(callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
getCpu().then(result => {
|
getCpu().then(result => {
|
||||||
if (callback) { callback(result) }
|
if (callback) { callback(result) }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
@ -188,12 +190,6 @@ function cpuTemperature(callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
main: -1.0,
|
main: -1.0,
|
||||||
cores: [],
|
cores: [],
|
||||||
@ -280,6 +276,28 @@ function cpuTemperature(callback) {
|
|||||||
if (callback) { callback(result) }
|
if (callback) { callback(result) }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
exec("wmic /namespace:\\\\root\\wmi PATH MSAcpi_ThermalZoneTemperature get CriticalTripPoint,CurrentTemperature /value", function (error, stdout) {
|
||||||
|
if (!error) {
|
||||||
|
let sum = 0;
|
||||||
|
let lines = stdout.trim().split(/\s\s+/);
|
||||||
|
lines.forEach(function (line) {
|
||||||
|
if (line.match('CriticalTripPoint') && !result.max)
|
||||||
|
result.max = (parseInt(line.split('CriticalTripPoint=')[1]) - 2732) / 10;
|
||||||
|
else if (line.match('CurrentTemperature')) {
|
||||||
|
let value = (parseInt(line.split('CurrentTemperature=')[1]) - 2732) / 10;
|
||||||
|
sum = sum + value;
|
||||||
|
result.cores.push(value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (result.cores.length) {
|
||||||
|
result.main = sum / result.cores.length;
|
||||||
|
}
|
||||||
|
if (callback) { callback(result) }
|
||||||
|
resolve(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,14 +34,7 @@ function fsSize(callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
if (_linux || _darwin) {
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) {
|
|
||||||
callback(NOT_SUPPORTED)
|
|
||||||
}
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let cmd = (_darwin ? "df -lkP | grep ^/" : "df -lkPT | grep ^/");
|
let cmd = (_darwin ? "df -lkP | grep ^/" : "df -lkPT | grep ^/");
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, function (error, stdout) {
|
||||||
let data = [];
|
let data = [];
|
||||||
@ -67,6 +60,29 @@ function fsSize(callback) {
|
|||||||
}
|
}
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (_windows) {
|
||||||
|
exec('wmic logicaldisk get Caption,FileSystem,FreeSpace,Size', function (error, stdout) {
|
||||||
|
let lines = stdout.split('\r\n').filter(line => line.trim() != '').filter((line, idx) => idx > 0);
|
||||||
|
lines.forEach(function (line) {
|
||||||
|
if (line != '') {
|
||||||
|
line = line.trim().split(/\s\s+/);
|
||||||
|
data.push({
|
||||||
|
'fs': line[0],
|
||||||
|
'type': line[1],
|
||||||
|
'size': line[3],
|
||||||
|
'used': parseInt(line[3]) - parseInt(line[2]),
|
||||||
|
'use': parseFloat((100.0 * (parseInt(line[3]) - parseInt(line[2]))) / parseInt(line[3])),
|
||||||
|
'mount': line[0]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (callback) {
|
||||||
|
callback(data)
|
||||||
|
}
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -179,14 +195,6 @@ function blockDevices(callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) {
|
|
||||||
callback(NOT_SUPPORTED)
|
|
||||||
}
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_linux) {
|
if (_linux) {
|
||||||
// see https://wiki.ubuntuusers.de/lsblk/
|
// see https://wiki.ubuntuusers.de/lsblk/
|
||||||
// exec("lsblk -bo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,TRAN,SERIAL,LABEL,MODEL,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,SCHED,RQ-SIZE,RA,WSAME", function (error, stdout) {
|
// exec("lsblk -bo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,TRAN,SERIAL,LABEL,MODEL,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,SCHED,RQ-SIZE,RA,WSAME", function (error, stdout) {
|
||||||
@ -227,6 +235,37 @@ function blockDevices(callback) {
|
|||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
exec('wmic logicaldisk get Caption,Description,DeviceID,DriveType,FileSystem,FreeSpace,Name,Size,VolumeName,VolumeSerialNumber /format:csv', function (error, stdout) {
|
||||||
|
if (!error) {
|
||||||
|
let lines = stdout.split('\r\n').filter(line => line.trim() != '').filter((line, idx) => idx > 0);
|
||||||
|
lines.forEach(function (line) {
|
||||||
|
if (line != '') {
|
||||||
|
line = line.replace('\r', '').split(',');
|
||||||
|
data.push({
|
||||||
|
name: line[7],
|
||||||
|
identifier: line[1],
|
||||||
|
type: 'disk',
|
||||||
|
fstype: line[5].toLowerCase(),
|
||||||
|
mount: line[1],
|
||||||
|
size: line[8],
|
||||||
|
physical: line[4] == '5' ? 'CD/DVD' : 'HDD',
|
||||||
|
uuid: line[10],
|
||||||
|
label: line[9],
|
||||||
|
model: '',
|
||||||
|
serial: line[10],
|
||||||
|
removable: line[4] == '2',
|
||||||
|
protocol: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (callback) {
|
||||||
|
callback(data)
|
||||||
|
}
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,6 +82,7 @@
|
|||||||
// --------------------------------
|
// --------------------------------
|
||||||
//
|
//
|
||||||
// version date comment
|
// version date comment
|
||||||
|
// 3.17.0 2017-02-19 windows support for some first functions
|
||||||
// 3.16.0 2017-01-19 blockDevices: added removable attribute + fix
|
// 3.16.0 2017-01-19 blockDevices: added removable attribute + fix
|
||||||
// 3.15.1 2017-01-17 minor cpuTemperature fix (OSX)
|
// 3.15.1 2017-01-17 minor cpuTemperature fix (OSX)
|
||||||
// 3.15.0 2017-01-15 added cpuTemperature also for OSX
|
// 3.15.0 2017-01-15 added cpuTemperature also for OSX
|
||||||
|
|||||||
@ -78,11 +78,6 @@ module.exports = function (callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
total: os.totalmem(),
|
total: os.totalmem(),
|
||||||
|
|||||||
155
lib/osinfo.js
155
lib/osinfo.js
@ -42,34 +42,90 @@ exports.time = time;
|
|||||||
function getLogoFile(distro) {
|
function getLogoFile(distro) {
|
||||||
distro = distro.toLowerCase();
|
distro = distro.toLowerCase();
|
||||||
let result = 'linux';
|
let result = 'linux';
|
||||||
if (_windows) { result = 'windows' }
|
if (_windows) {
|
||||||
else if (distro.indexOf('mac os') != -1) { result = 'apple' }
|
result = 'windows'
|
||||||
else if (distro.indexOf('arch') != -1) { result = 'arch' }
|
}
|
||||||
else if (distro.indexOf('centos') != -1) { result = 'centos' }
|
else if (distro.indexOf('mac os') != -1) {
|
||||||
else if (distro.indexOf('coreos') != -1) { result = 'coreos' }
|
result = 'apple'
|
||||||
else if (distro.indexOf('debian') != -1) { result = 'debian' }
|
}
|
||||||
else if (distro.indexOf('elementary') != -1) { result = 'elementary' }
|
else if (distro.indexOf('arch') != -1) {
|
||||||
else if (distro.indexOf('fedora') != -1) { result = 'fedora' }
|
result = 'arch'
|
||||||
else if (distro.indexOf('gentoo') != -1) { result = 'gentoo' }
|
}
|
||||||
else if (distro.indexOf('mageia') != -1) { result = 'mageia' }
|
else if (distro.indexOf('centos') != -1) {
|
||||||
else if (distro.indexOf('mandriva') != -1) { result = 'mandriva' }
|
result = 'centos'
|
||||||
else if (distro.indexOf('manjaro') != -1) { result = 'manjaro' }
|
}
|
||||||
else if (distro.indexOf('mint') != -1) { result = 'mint' }
|
else if (distro.indexOf('coreos') != -1) {
|
||||||
else if (distro.indexOf('openbsd') != -1) { result = 'openbsd' }
|
result = 'coreos'
|
||||||
else if (distro.indexOf('opensuse') != -1) { result = 'opensuse' }
|
}
|
||||||
else if (distro.indexOf('pclinuxos') != -1) { result = 'pclinuxos' }
|
else if (distro.indexOf('debian') != -1) {
|
||||||
else if (distro.indexOf('puppy') != -1) { result = 'puppy' }
|
result = 'debian'
|
||||||
else if (distro.indexOf('raspbian') != -1) { result = 'raspbian' }
|
}
|
||||||
else if (distro.indexOf('reactos') != -1) { result = 'reactos' }
|
else if (distro.indexOf('elementary') != -1) {
|
||||||
else if (distro.indexOf('redhat') != -1) { result = 'redhat' }
|
result = 'elementary'
|
||||||
else if (distro.indexOf('slackware') != -1) { result = 'slackware' }
|
}
|
||||||
else if (distro.indexOf('sugar') != -1) { result = 'sugar' }
|
else if (distro.indexOf('fedora') != -1) {
|
||||||
else if (distro.indexOf('steam') != -1) { result = 'steam' }
|
result = 'fedora'
|
||||||
else if (distro.indexOf('suse') != -1) { result = 'suse' }
|
}
|
||||||
else if (distro.indexOf('mate') != -1) { result = 'ubuntu-mate' }
|
else if (distro.indexOf('gentoo') != -1) {
|
||||||
else if (distro.indexOf('lubuntu') != -1) { result = 'lubuntu' }
|
result = 'gentoo'
|
||||||
else if (distro.indexOf('xubuntu') != -1) { result = 'xubuntu' }
|
}
|
||||||
else if (distro.indexOf('ubuntu') != -1) { result = 'ubuntu' }
|
else if (distro.indexOf('mageia') != -1) {
|
||||||
|
result = 'mageia'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('mandriva') != -1) {
|
||||||
|
result = 'mandriva'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('manjaro') != -1) {
|
||||||
|
result = 'manjaro'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('mint') != -1) {
|
||||||
|
result = 'mint'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('openbsd') != -1) {
|
||||||
|
result = 'openbsd'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('opensuse') != -1) {
|
||||||
|
result = 'opensuse'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('pclinuxos') != -1) {
|
||||||
|
result = 'pclinuxos'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('puppy') != -1) {
|
||||||
|
result = 'puppy'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('raspbian') != -1) {
|
||||||
|
result = 'raspbian'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('reactos') != -1) {
|
||||||
|
result = 'reactos'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('redhat') != -1) {
|
||||||
|
result = 'redhat'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('slackware') != -1) {
|
||||||
|
result = 'slackware'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('sugar') != -1) {
|
||||||
|
result = 'sugar'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('steam') != -1) {
|
||||||
|
result = 'steam'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('suse') != -1) {
|
||||||
|
result = 'suse'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('mate') != -1) {
|
||||||
|
result = 'ubuntu-mate'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('lubuntu') != -1) {
|
||||||
|
result = 'lubuntu'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('xubuntu') != -1) {
|
||||||
|
result = 'xubuntu'
|
||||||
|
}
|
||||||
|
else if (distro.indexOf('ubuntu') != -1) {
|
||||||
|
result = 'ubuntu'
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,17 +134,11 @@ function getLogoFile(distro) {
|
|||||||
|
|
||||||
function osInfo(callback) {
|
function osInfo(callback) {
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
|
|
||||||
platform: _platform,
|
platform: (_platform == 'Windows_NT' ? 'Windows' : _platform),
|
||||||
distro: 'unknown',
|
distro: 'unknown',
|
||||||
release: 'unknown',
|
release: 'unknown',
|
||||||
codename: '',
|
codename: '',
|
||||||
@ -122,7 +172,9 @@ function osInfo(callback) {
|
|||||||
result.release = (release.DISTRIB_RELEASE || release.VERSION_ID || 'unknown').replace(/"/g, '');
|
result.release = (release.DISTRIB_RELEASE || release.VERSION_ID || 'unknown').replace(/"/g, '');
|
||||||
result.codename = (release.DISTRIB_CODENAME || '').replace(/"/g, '');
|
result.codename = (release.DISTRIB_CODENAME || '').replace(/"/g, '');
|
||||||
//}
|
//}
|
||||||
if (callback) { callback(result) }
|
if (callback) {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -136,10 +188,23 @@ function osInfo(callback) {
|
|||||||
}
|
}
|
||||||
if (line.indexOf('ProductVersion') != -1) result.release = line.split(':')[1].trim();
|
if (line.indexOf('ProductVersion') != -1) result.release = line.split(':')[1].trim();
|
||||||
});
|
});
|
||||||
if (callback) { callback(result) }
|
if (callback) {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
result.logofile = getLogoFile();
|
||||||
|
result.release = result.kernel;
|
||||||
|
exec("wmic os get Caption", function (error, stdout) {
|
||||||
|
result.distro = result.codename = stdout.slice(stdout.indexOf('\r\n') + 2).trim();
|
||||||
|
if (callback) {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -166,10 +231,12 @@ function versions(callback) {
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
lines = stdout.toString().split('\n');
|
lines = stdout.toString().split('\n');
|
||||||
if (lines.length >= 2) {
|
if (lines.length >= 2) {
|
||||||
result.pm2 = lines[lines.length-2];
|
result.pm2 = lines[lines.length - 2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (callback) { callback(result) }
|
if (callback) {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -184,7 +251,9 @@ function shell(callback) {
|
|||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
if (_windows) {
|
||||||
let error = new Error(NOT_SUPPORTED);
|
let error = new Error(NOT_SUPPORTED);
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
if (callback) {
|
||||||
|
callback(NOT_SUPPORTED)
|
||||||
|
}
|
||||||
reject(error);
|
reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +262,9 @@ function shell(callback) {
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
result = stdout.toString().split('\n')[0];
|
result = stdout.toString().split('\n')[0];
|
||||||
}
|
}
|
||||||
if (callback) { callback(result) }
|
if (callback) {
|
||||||
|
callback(result)
|
||||||
|
}
|
||||||
resolve(result);
|
resolve(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -27,7 +27,8 @@ const NOT_SUPPORTED = 'not supported';
|
|||||||
let _process_cpu = {
|
let _process_cpu = {
|
||||||
all: 0,
|
all: 0,
|
||||||
list: {},
|
list: {},
|
||||||
ms: 0
|
ms: 0,
|
||||||
|
result: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
@ -158,21 +159,25 @@ function processes(callback) {
|
|||||||
let priority = parseInt(line.substring(parsedhead[3].from, parsedhead[3].to));
|
let priority = parseInt(line.substring(parsedhead[3].from, parsedhead[3].to));
|
||||||
let vsz = parseInt(line.substring(parsedhead[4].from, parsedhead[4].to));
|
let vsz = parseInt(line.substring(parsedhead[4].from, parsedhead[4].to));
|
||||||
let rss = parseInt(line.substring(parsedhead[5].from, parsedhead[5].to));
|
let rss = parseInt(line.substring(parsedhead[5].from, parsedhead[5].to));
|
||||||
let started = line.substring(parsedhead[6].from, parsedhead[6].to).trim();
|
let nice = parseInt(line.substring(parsedhead[6].from, parsedhead[6].to));
|
||||||
let state = line.substring(parsedhead[7].from, parsedhead[7].to).trim();
|
let started = line.substring(parsedhead[7].from, parsedhead[7].to).trim();
|
||||||
|
let state = line.substring(parsedhead[8].from, parsedhead[8].to).trim();
|
||||||
state = (state[0] == 'R' ? 'running' : (state[0] == 'S' ? 'sleeping' : (state[0] == 'T' ? 'stopped' : (state[0] == 'W' ? 'paging' : (state[0] == 'X' ? 'dead' : (state[0] == 'Z' ? 'zombie' : ((state[0] == 'D' || state[0] == 'U') ? 'blocked' : 'unknown')))))));
|
state = (state[0] == 'R' ? 'running' : (state[0] == 'S' ? 'sleeping' : (state[0] == 'T' ? 'stopped' : (state[0] == 'W' ? 'paging' : (state[0] == 'X' ? 'dead' : (state[0] == 'Z' ? 'zombie' : ((state[0] == 'D' || state[0] == 'U') ? 'blocked' : 'unknown')))))));
|
||||||
let tty = line.substring(parsedhead[8].from, parsedhead[8].to).trim();
|
let tty = line.substring(parsedhead[9].from, parsedhead[9].to).trim();
|
||||||
if (tty == '?' || tty == '??') tty = '';
|
if (tty == '?' || tty == '??') tty = '';
|
||||||
let user = line.substring(parsedhead[9].from, parsedhead[9].to).trim();
|
let user = line.substring(parsedhead[10].from, parsedhead[10].to).trim();
|
||||||
let command = line.substring(parsedhead[10].from, parsedhead[10].to).trim().replace(/\[/g, "").replace(/]/g, "");
|
let command = line.substring(parsedhead[11].from, parsedhead[11].to).trim().replace(/\[/g, "").replace(/]/g, "");
|
||||||
|
|
||||||
return ({
|
return ({
|
||||||
pid: pid,
|
pid: pid,
|
||||||
pcpu: pcpu,
|
pcpu: pcpu,
|
||||||
|
pcpuu: 0,
|
||||||
|
pcpus: 0,
|
||||||
pmem: pmem,
|
pmem: pmem,
|
||||||
priority: priority,
|
priority: priority,
|
||||||
mem_vsz: vsz,
|
mem_vsz: vsz,
|
||||||
mem_rss: rss,
|
mem_rss: rss,
|
||||||
|
nice: nice,
|
||||||
started: started,
|
started: started,
|
||||||
state: state,
|
state: state,
|
||||||
tty: tty,
|
tty: tty,
|
||||||
@ -212,13 +217,15 @@ function processes(callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseProcPidStat(line, all) {
|
function parseProcPidStat(line, all) {
|
||||||
let parts = line.replace(/ +/g, " ").split(' ');
|
let statparts = line.replace(/ +/g, " ").split(')');
|
||||||
if (parts.length >= 17) {
|
if (statparts.length >= 2) {
|
||||||
let pid = parseInt(parts[0]);
|
let parts = statparts[1].split(' ');
|
||||||
let utime = parseInt(parts[13]);
|
if (parts.length >= 16) {
|
||||||
let stime = parseInt(parts[14]);
|
let pid = parseInt(statparts[0].split(' ')[0]);
|
||||||
let cutime = parseInt(parts[15]);
|
let utime = parseInt(parts[12]);
|
||||||
let cstime = parseInt(parts[16]);
|
let stime = parseInt(parts[13]);
|
||||||
|
let cutime = parseInt(parts[14]);
|
||||||
|
let cstime = parseInt(parts[15]);
|
||||||
|
|
||||||
// calc
|
// calc
|
||||||
let pcpuu = 0;
|
let pcpuu = 0;
|
||||||
@ -250,6 +257,17 @@ function processes(callback) {
|
|||||||
pcpus: 0
|
pcpus: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
pid: 0,
|
||||||
|
utime: 0,
|
||||||
|
stime: 0,
|
||||||
|
cutime: 0,
|
||||||
|
cstime: 0,
|
||||||
|
pcpuu: 0,
|
||||||
|
pcpus: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -268,8 +286,10 @@ function processes(callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let cmd = "";
|
let cmd = "";
|
||||||
if (_linux) cmd = "ps axo pid:10,pcpu:6,pmem:6,pri:5,vsz:10,rss:10,start:20,state:20,tty:20,user:20,command";
|
|
||||||
if (_darwin) cmd = "ps acxo pid,pcpu,pmem,pri,vsz,rss,start,state,tty,user,command -r";
|
if ((_process_cpu.ms && Date.now() - _process_cpu.ms >= 500) || _process_cpu.ms == 0) {
|
||||||
|
if (_linux) cmd = "ps axo pid:10,pcpu:6,pmem:6,pri:5,vsz:10,rss:10,ni:5,start:20,state:20,tty:20,user:20,command";
|
||||||
|
if (_darwin) cmd = "ps acxo pid,pcpu,pmem,pri,vsz,rss,nice,start,state,tty,user,command -r";
|
||||||
exec(cmd, function (error, stdout) {
|
exec(cmd, function (error, stdout) {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
result.list = parseProcesses(stdout.toString().split('\n'));
|
result.list = parseProcesses(stdout.toString().split('\n'));
|
||||||
@ -307,7 +327,9 @@ function processes(callback) {
|
|||||||
// store pcpu in outer array
|
// store pcpu in outer array
|
||||||
let listPos = result.list.map(function (e) { return e.pid; }).indexOf(resultProcess.pid);
|
let listPos = result.list.map(function (e) { return e.pid; }).indexOf(resultProcess.pid);
|
||||||
if (listPos >= 0) {
|
if (listPos >= 0) {
|
||||||
result.list[listPos].pcpu = resultProcess.pcpuu + resultProcess.pcpus
|
result.list[listPos].pcpu = resultProcess.pcpuu + resultProcess.pcpus;
|
||||||
|
result.list[listPos].pcpuu = resultProcess.pcpuu;
|
||||||
|
result.list[listPos].pcpus = resultProcess.pcpus;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save new values
|
// save new values
|
||||||
@ -326,6 +348,7 @@ function processes(callback) {
|
|||||||
_process_cpu.all = all;
|
_process_cpu.all = all;
|
||||||
_process_cpu.list = list_new;
|
_process_cpu.list = list_new;
|
||||||
_process_cpu.ms = Date.now() - _process_cpu.ms;
|
_process_cpu.ms = Date.now() - _process_cpu.ms;
|
||||||
|
_process_cpu.result = result;
|
||||||
if (callback) { callback(result) }
|
if (callback) { callback(result) }
|
||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
@ -335,6 +358,10 @@ function processes(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
if (callback) { callback(_process_cpu.result) }
|
||||||
|
resolve(_process_cpu.result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,11 +28,6 @@ module.exports = function (callback) {
|
|||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
process.nextTick(() => {
|
process.nextTick(() => {
|
||||||
if (_windows) {
|
|
||||||
let error = new Error(NOT_SUPPORTED);
|
|
||||||
if (callback) { callback(NOT_SUPPORTED) }
|
|
||||||
reject(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
let result = {
|
let result = {
|
||||||
manufacturer: '',
|
manufacturer: '',
|
||||||
@ -148,6 +143,20 @@ module.exports = function (callback) {
|
|||||||
resolve(result);
|
resolve(result);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if (_windows) {
|
||||||
|
exec("wmic csproduct get", function (error, stdout) {
|
||||||
|
if (!error) {
|
||||||
|
let lines = stdout.split('\r\n').filter(line => line.trim() != '').filter((line, idx) => idx > 0)[0].trim().split(/\s\s+/);
|
||||||
|
result.manufacturer = lines[5];
|
||||||
|
result.model = lines[3];
|
||||||
|
result.version = lines[6];
|
||||||
|
result.serial = lines[2];
|
||||||
|
result.uuid = lines[4];
|
||||||
|
}
|
||||||
|
if (callback) { callback(result) }
|
||||||
|
resolve(result);
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
"os",
|
"os",
|
||||||
"linux",
|
"linux",
|
||||||
"osx",
|
"osx",
|
||||||
|
"windows",
|
||||||
"cpu",
|
"cpu",
|
||||||
"cpuload",
|
"cpuload",
|
||||||
"memory",
|
"memory",
|
||||||
@ -45,7 +46,8 @@
|
|||||||
},
|
},
|
||||||
"os": [
|
"os": [
|
||||||
"darwin",
|
"darwin",
|
||||||
"linux"
|
"linux",
|
||||||
|
"win32"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.0.0"
|
"node": ">=4.0.0"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user