3.18.1 • Published 7 years ago

paw-info v3.18.1

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
7 years ago

systeminformation

Simple system and OS information library for node.js

NPM Version NPM Downloads Git Issues deps status MIT license

Quick Start

Collection of 30+ functions to retrieve detailed hardware, system and OS information (Linux, OSX and now partial Windows support)

Installation

$ npm install systeminformation --save

Usage

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

var si = require('systeminformation');

// callback style
si.cpu(function(data) {
	console.log('CPU-Information:');
	console.log(data);
})

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

News and Changes

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.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.13.0: added shell (returns standard shell)
  • Version 3.12.0: refactoring and extended currentLoad (better OSX coverage and added irq load).
  • Version 3.11.0: blockDevices now also for OSX and also extended (+ label, model, serial, protocol).
  • Version 3.10.0: added blockDevices (list of disks, partitions, raids and roms).
  • Version 3.9.0: extended networkInterfaces (added MAC address).
  • Version 3.8.0: added dockerContainerProcesses (array of processes inside a docker container).
  • Version 3.7.0: extended dockerContainerStats.
  • Version 3.6.0: added versions (kernel, ssl, node, npm, pm2, ...).
  • Version 3.5.0: added graphics info (controller and display).
  • Version 3.4.0: rewritten currentLoad and CPU load for processes (linux). This is now much more accurate.
  • Version 3.3.0: added processes.list. Get full process list including details like cpu and mem usage, status, command, ...
  • Version 3.2.0: added battery support. If a battery is installed, you get information about status and current capacity level
  • Version 3.1.0: added Docker support. Now you can scan your docker containers and get their stats
  • Version 3.0.0: added disksIO - overall diskIO and IOPS values for all mounted volumes

Changelog

You can find all changes here: detailed changelog

Core concept

Node.js comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still work in progress. 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 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). 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!

I also created a little command line tool called mmon (micro-monitor), also available via github and npm

Reference

Sections

This library is splitted in several sections:

  1. General
  2. System (HW)
  3. Operating System
  4. CPU
  5. Memory
  6. File System
  7. Network
  8. Processes
  9. Users
  10. Internet
  11. Docker
  12. GetAll

Function Reference and OS Support

FunctionLinuxOSXWinComments
si.version()XXXlibrary version (no callback/promise)
si.time()XXXtime information (no callback/promise)
- currentXXXlocal time
- uptimeXXXuptime
si.system(cb)XXXhardware information
- manufacturerXXXe.g. 'MSI'
- modelXXXmodel/product e.g. 'MS-7823'
- versionXXXversion e.g. '1.0'
- serialXXXserial number
- uuidXXXUUID
si.osInfo(cb)XXXOS information
- platformXXX'Linux', 'Darwin', 'Windows'
- distroXXX
- releaseXXX
- codenameX
- kernelXXXkernel release - same as os.release()
- archXXXsame as os.arch()
- hostnameXXXsame as os.hostname()
- logofileXXXe.g. 'apple', 'debian', 'fedora', ...
si.versions(cb)XXXVersion information (kernel, ssl, node, ...)
si.shell(cb)XXstandard shell
si.cpu(cb)XXXCPU information
- manufacturerXXXe.g. 'Intel(R)'
- brandXXXe.g. 'Core(TM)2 Duo'
- speedXXXin GHz e.g. '3.40'
- coresXXX# cores
si.cpuFlags(cb)XXCPU flags
si.cpuCache(cb)XXCPU cache sizes
- l1dXXL1D size
- l1iXXL1I size
- l2XXL2 size
- l3XXL3 size
si.cpuCurrentspeed(cb)XXcurrent CPU speed (in GHz)
- avgXXavg CPU speed (all cores)
- minXXmin CPU speed (all cores)
- maxXXmax CPU speed (all cores)
si.cpuTemperature(cb)XXXCPU temperature (if sensors is installed)
- mainXXXmain temperature
- coresXXXarray of temperatures
- maxXXXmax temperature
si.mem(cb)XXXMemory information
- totalXXXtotal memory
- freeXXXnot used
- usedXXXused (incl. buffers/cache)
- activeXXXused actively (excl. buffers/cache)
- buffcacheXXused by buffers+cache
- availableXXXpotentially available (total - active)
- swaptotalXX
- swapusedXX
- swapfreeXX
si.battery(cb)XXbattery information
- hasbatteryXXindicates presence of battery
- ischargingXXindicates if battery is charging
- maxcapacityXXmax capacity of battery
- currentcapacityXXcurrent capacity of battery
- percentXXcharging level in percent
si.graphics(cb)XXarrays of graphics controllers and displays
- controllers0.modelXXgraphics controller model
- controllers0.vendorXXe.g. ATI
- controllers0.busXXon which bus (e.g. PCIe)
- controllers0.vramXXVRAM size (in MB)
- controllers0.vramDynamicXXtrue if dynamicly allocated ram
- displays0.modelXXMonitor/Display Model
- displays0.mainXXtrue if main monitor
- displays0.builtinXXtrue if built in monitor
- displays0.connectionXXe.g. DisplayPort or HDMI
- displays0.resolutionxXXpixel horizontal
- displays0.resolutionyXXpixel vertical
- displays0.depthXXcolor depth in bits
- displays0.sizexXXsize in mm horizontal
- displays0.sizeyXXsize in mm vertical
si.fsSize(cb)XXXreturns array of mounted file systems
- 0.fsXXXname of file system
- 0.typeXXXtype of file system
- 0.sizeXXXsizes in Bytes
- 0.usedXXXused in Bytes
- 0.useXXXused in %
- 0.mountXXXmount point
si.blockDevices(cb)XXXreturns array of disks, partitions,raids and roms
- 0.nameXXXname
- 0.typeXXXtype
- 0.fstypeXXXfile system type (e.g. ext4)
- 0.mountXXXmount point
- 0.sizeXXXsize in bytes
- 0.physicalXXXphysical type (HDD, SSD, CD/DVD)
- 0.uuidXXXUUID
- 0.labelXXXlabel
- 0.modelXXmodel
- 0.serialXXserial
- 0.removableXXXserial
- 0.protocolXXprotocol (SATA, PCI-Express, ...)
si.fsStats(cb)XXcurrent transfer stats
- rxXXbytes read since startup
- wxXXbytes written since startup
- txXXtotal bytes read + written since startup
- rx_secXXbytes read / second (* see notes)
- wx_secXXbytes written / second (* see notes)
- tx_secXXtotal bytes reads + written / second
- msXXinterval length (for per second values)
si.disksIO(cb)XXcurrent transfer stats
- rIOXXread IOs on all mounted drives
- wIOXXwrite IOs on all mounted drives
- tIOXXwrite IOs on all mounted drives
- rIO_secXXread IO per sec (* see notes)
- wIO_secXXwrite IO per sec (* see notes)
- tIO_secXXtotal IO per sec (* see notes)
- msXXinterval length (for per second values)
si.networkInterfaces(cb)XXarray of network interfaces
- 0.ifaceXXinterface name
- 0.ip4XXip4 address
- 0.ip6XXip6 address
- 0.macXXMAC address
- 0.internalXXtrue if internal interface
si.networkInterfaceDefault(cb)XXget name of default network interface
si.networkStats(iface,cb)XXcurrent network stats of given interfaceiface parameter is optionaldefaults to first external network interface
- ifaceXXinterface
- operstateXXup / down
- rxXXreceived bytes overall
- txXXtransferred bytes overall
- rx_secXXreceived bytes / second (* see notes)
- tx_secXXtransferred bytes per second (* see notes)
- msXXinterval length (for per second values)
si.networkConnections(cb)XXcurrent network network connectionsreturns an array of all connections
- 0.protocolXXtcp or udp
- 0.localaddressXXlocal address
- 0.localportXXlocal port
- 0.peeraddressXXpeer address
- 0.peerportXXpeer port
- 0.stateXXlike ESTABLISHED, TIME_WAIT, ...
si.currentLoad(cb)XXCPU-Load
- avgloadXXaverage load
- currentloadXXCPU-Load in %
- currentload_userXXCPU-Load User in %
- currentload_niceXXCPU-Load Nice in %
- currentload_systemXXCPU-Load System in %
- currentload_irqXXCPU-Load System in %
- cpus[]XXcurrent loads per CPU in %
si.fullLoad(cb)XXCPU-full load since bootup in %
si.services('mysql, apache2', cb)XXpass comma separated string of services
- 0.nameXXname of service
- 0.runningXXtrue / false
- 0.pcpuXXprocess % CPU
- 0.pmemXXprocess % MEM
si.processes(cb)XX# running processes
- allXX# of all processes
- runningXX# of all processes running
- blockedXX# of all processes blocked
- sleepingXX# of all processes sleeping
- list[]XXlist of all processes incl. details
- ...0.pidXXprocess PID
- ...0.pcpuXXprocess % CPU usage
- ...0.pcpuuXXprocess % CPU usage (user)
- ...0.pcpusXXprocess % CPU usage (system)
- ...0.pmemXXprocess memory %
- ...0.priorityXXprocess priotity
- ...0.mem_vszXXprocess virtual memory size
- ...0.mem_rssXXprocess mem resident set size
- ...0.niceXXprocess nice value
- ...0.startedXXprocess start time
- ...0.stateXXprocess state (e.g. sleeping)
- ...0.ttyXXtty from which process was started
si.processLoad('apache2',cb)XXdetailed information about given process
- procXXprocess name
- pidXXPID
- cpuXXprocess % CPU
- memXXprocess % MEM
si.users(cb)XXarray of users online
- 0.userXXuser name
- 0.ttyXXterminal
- 0.dateXXlogin date
- 0.timeXXlogin time
- 0.ipXXip address (remote login)
- 0.commandXXlast command or shell
si.inetChecksite(url, cb)XXresponse-time (ms) to fetch given URL
- urlXXgiven url
- okXXstatus code OK (2xx, 3xx)
- statusXXstatus code
- msXXresponse time in ms
si.inetLatency(host, cb)XXresponse-time (ms) to external resourcehost parameter is optional (default 8.8.8.8)
si.dockerContainers(all, cb)XXreturns array of active/all docker containers
- 0.idXXID of container
- 0.nameXXname of container
- 0.imageXXname of image
- 0.imageIDXXID of image
- 0.commandXXcommand
- 0.createdXXcreation time
- 0.stateXXcreated, running, exited
- 0.portsXXarray of ports
- 0.mountsXXarray of mounts
si.dockerContainerStats(id, cb)XXstatistics for a specific container
- idXXContainer ID
- mem_usageXXmemory usage in bytes
- mem_limitXXmemory limit (max mem) in bytes
- mem_percentXXmemory usage in percent
- cpu_percentXXcpu usage in percent
- pidsXXnumber of processes
- netIO.rxXXreceived bytes via network
- netIO.wxXXsent bytes via network
- blockIO.rXXbytes read from BlockIO
- blockIO.wXXbytes written to BlockIO
- cpu_statsXXdetailed cpu stats
- percpu_statsXXdetailed per cpu stats
- memory_statsXXdetailed memory stats
- networksXXdetailed network stats per interface
si.dockerContainerProcesses(id, cb)XXarray of processes inside a container
- 0.pid_hostXXprocess ID (host)
- 0.ppidXXparent process ID
- 0.pgidXXprocess group ID
- 0.userXXeffective user name
- 0.ruserXXreal user name
- 0.groupXXeffective group name
- 0.rgroupXXreal group name
- 0.statXXprocess state
- 0.timeXXaccumulated CPU time
- 0.elapsedXXelapsed running time
- 0.niceXXnice value
- 0.rssXXresident set size
- 0.vszXXvirtual size in Kbytes
- 0.commandXXcommand and arguments
si.dockerAll(cb)XXlist of all containers including their statsand processes in one single array
si.getStaticData(cb)XXall static data at once
si.getDynamicData(srv,iface,cb)XXall dynamic data at once
si.getAllData(srv,iface,cb)XXall data at once

cb: Asynchronous Function Calls (callback)

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

Callback Style

var si = require('systeminformation');

si.networkStats('eth1', function(data) {
	console.log('Network Interface Stats (eth1):');
	console.log('- is up: ' + data.operstate);
	console.log('- RX bytes overall: ' + data.rx);
	console.log('- TX bytes overall: ' + data.tx);
	console.log('- RX bytes/sec: ' + data.rx_sec);
	console.log('- TX bytes/sec: ' + data.tx_sec);
})

Promises

Promises Style is new in version 3.0.

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

si.networkStats('eth1')
	.then(data => {
		console.log('Network Interface Stats (eth1):');
		console.log('- is up: ' + data.operstate);
		console.log('- RX bytes overall: ' + data.rx);
		console.log('- TX bytes overall: ' + data.tx);
		console.log('- RX bytes/sec: ' + data.rx_sec);
		console.log('- TX bytes/sec: ' + data.tx_sec);
	})
	.catch(error => console.error(error));

*: Additional Notes

In fsStats, disksIO and networkStats the results per second values (rx_sec, IOPS, ...) are calculated beginning with the second call of the function. It is determined by calculating the difference of transferred bytes / IOs divided by the time between two calls of the function.

Known Issues

I am happy to discuss any comments and suggestions. Please feel free to contact me if you see any possibility of improvement!

Comments

If you have ideas or comments, please do not hesitate to contact me.

Happy monitoring!

Sincerely,

Sebastian Hildebrandt, +innovations

Credits

Written by Sebastian Hildebrandt sebhildebrandt

Contributers

OSX Temperature: Credits here are going to:

Copyright Information

Linux is a registered trademark of Linus Torvalds, OS X is a registered trademark of Apple Inc., Windows is a registered trademark of Microsoft Corporation. Node.js is a trademark of Joyent Inc., Intel is a trademark of Intel Corporation, 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., Docker is a trademark of Docker, Inc. All other trademarks are the property of their respective owners.

License MIT license

The MIT License (MIT)

Copyright © 2014-2017 Sebastian Hildebrandt, +innovations.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Further details see LICENSE file.