Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jedithepro/system-info

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jedithepro/system-info

System and OS information library for Node.js, and SystemInfo API.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

systeminformation logo

@jedithepro/system-info

System and OS information library for Node.js, and SystemInfo API

Quick Start

Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information.

  • Simple to use
  • Get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes
  • Supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support
  • No npm dependencies (for production)

Attention: this is a node.js library. It is supposed to be used as a backend/server-side library and will definitely not work within a browser.

Installation

$ npm install @jedithepro/system-info --save

Usage

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

const si = require('@jedithepro/system-info');

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

Reference

Function Reference and OS Support

1. General
FunctionResult objectLinuxBSDMacWinSunComments
si.version(): stringXXXXXlib version (no callback/promise)
si.time(){...}XXXXX(no callback/promise)
currentXXXXXlocal (server) time
uptimeXXXXXuptime in number of seconds
timezoneXXXXXe.g. GMT+0200
timezoneNameXXXXXe.g. CEST
2. System (HW)
FunctionResult objectLinuxBSDMacWinSunComments
si.system(cb){...}XXXXhardware information
manufacturerXXXXe.g. 'MSI'
modelXXXXmodel/product e.g. 'MS-7823'
versionXXXXversion e.g. '1.0'
serialXXXXserial number
uuidXXXXUUID
skuXXXXSKU number
si.bios(cb){...}XXXXbios information
vendorXXXXe.g. 'AMI'
versionXXXversion
releaseDateXXXrelease date
revisionXXXrevision
si.baseboard(cb){...}XXXXbaseboard information
manufacturerXXXXe.g. 'ASUS'
modelXXXXmodel / product name
versionXXXXversion
serialXXXXserial number
assetTagXXXXasset tag
si.chassis(cb){...}XXXXchassis information
manufacturerXXXXe.g. 'MSI'
modelXXXXmodel / product name
typeXXXXmodel / product name
versionXXXXversion
serialXXXXserial number
assetTagXXXXasset tag
skuXSKU number
3. CPU
FunctionResult objectLinuxBSDMacWinSunComments
si.cpu(cb){...}XXXXCPU information
manufacturerXXXXe.g. 'Intel(R)'
brandXXXXe.g. 'Core(TM)2 Duo'
speedXXXXin GHz e.g. '3.40'
speedminXXXin GHz e.g. '0.80'
speedmaxXXXXin GHz e.g. '3.90'
governorXe.g. 'powersave'
coresXXXX# cores
physicalCoresXXXX# physical cores
processorsXXXX# processors
socketXXXsocket type e.g. "LGA1356"
vendorXXXXvendor ID
familyXXXXprocessor family
modelXXXXprocessor model
steppingXXXXprocessor stepping
revisionXXXrevision
voltageXvoltage
cacheXXXXcache in bytes (object)
cache.l1dXXXXL1D (data) size
cache.l1iXXXXL1I (instruction) size
cache.l2XXXXL2 size
cache.l3XXXXL3 size
si.cpuFlags(cb): stringXXXXCPU flags
si.cpuCache(cb){...}XXXXCPU cache sizes
l1dXXXXL1D size
l1iXXXXL1I size
l2XXXXL2 size
l3XXXXL3 size
si.cpuCurrentspeed(cb){...}XXXXXcurrent CPU speed (in GHz)
avgXXXXXavg CPU speed (all cores)
minXXXXXmin CPU speed (all cores)
maxXXXXXmax CPU speed (all cores)
coresXXXXXCPU speed per core (array)
si.cpuTemperature(cb){...}XXX*XCPU temperature (if supported)
mainXXXXmain temperature (avg)
coresXXXXarray of temperatures
maxXXXXmax temperature
4. Memory
FunctionResult objectLinuxBSDMacWinSunComments
si.mem(cb){...}XXXXXMemory information (in bytes)
totalXXXXXtotal memory in bytes
freeXXXXXnot used in bytes
usedXXXXXused (incl. buffers/cache)
activeXXXXXused actively (excl. buffers/cache)
buffcacheXXXXused by buffers+cache
buffersXused by buffers
cachedXused by cache
slabXused by slab
availableXXXXXpotentially available (total - active)
swaptotalXXXXX
swapusedXXXXX
swapfreeXXXXX
si.memLayout(cb)[{...}]XXXXMemory Layout (array)
[0].sizeXXXXsize in bytes
[0].bankXXXmemory bank
[0].typeXXXXmemory type
[0].clockSpeedXXXXclock speed
[0].formFactorXXXform factor
[0].manufacturerXXXXmanufacturer
[0].partNumXXXXpart number
[0].serialNumXXXXserial number
[0].voltageConfiguredXXXvoltage conf.
[0].voltageMinXXXvoltage min
[0].voltageMaxXXXvoltage max
5. Battery
FunctionResult objectLinuxBSDMacWinSunComments
si.battery(cb){...}XXXXbattery information
hasbatteryXXXXindicates presence of battery
cyclecountXXnumbers of recharges
ischargingXXXXindicates if battery is charging
designedcapacityXXXmax capacity of battery (mWh)
maxcapacityXXXmax capacity of battery (mWh)
currentcapacityXXXcurrent capacity of battery (mWh)
capacityUnitXXXcapacity unit (mWh)
voltageXXXcurrent voltage of battery (V)
percentXXXXcharging level in percent
timeremainingXXminutes left (if discharging)
acconnectedXXXXAC connected
typeXXbattery type
modelXXmodel
manufacturerXXmanufacturer
serialXXbattery serial
  • See known issues if you have problem with macOS temperature or windows temperature
6. Graphics
FunctionResult objectLinuxBSDMacWinSunComments
si.graphics(cb){...}XXXarrays of graphics controllers and displays
controllers[]XXXgraphics controllers array
...[0].modelXXXgraphics controller model
...[0].vendorXXXe.g. ATI
...[0].deviceNameXe.g. \\.\DISPLAY1
...[0].busXXXon which bus (e.g. PCIe)
...[0].vramXXXVRAM size (in MB)
...[0].vramDynamicXXXtrue if dynamicly allocated ram
displays[]XXXmonitor/display array
...[0].vendorXmonitor/display vendor
...[0].modelXXXmonitor/display model
...[0].mainXXXtrue if main monitor
...[0].builtinXXtrue if built in monitor
...[0].connectionXXXe.g. DisplayPort or HDMI
...[0].sizexXXXsize in mm horizontal
...[0].sizeyXXXsize in mm vertical
...[0].pixeldepthXXXcolor depth in bits
...[0].resolutionxXXXpixel horizontal
...[0].resolutionyXXXpixel vertical
...[0].currentResXXXXcurrent pixel horizontal
...[0].currentResYXXXcurrent pixel vertical
...[0].positionXXdisplay position X
...[0].positionYXdisplay position Y
...[0].currentRefreshRateXXXcurrent screen refresh rate
7. Operating System
FunctionResult objectLinuxBSDMacWinSunComments
si.osInfo(cb){...}XXXXXOS information
platformXXXXX'linux', 'darwin', 'win32', ...
distroXXXXX
releaseXXXXX
codenameX
kernelXXXXXkernel release - same as os.release()
archXXXXXsame as os.arch()
hostnameXXXXXsame as os.hostname()
codepageXXXXOS build version
logofileXXXXXe.g. 'apple', 'debian', 'fedora', ...
serialXXXXOS/Host serial number
buildXXXOS build version
servicepackXservice pack version
uefiXXXXOS started via UEFI
si.uuid(cb){...}XXXXXobject of several UUIDs
osXXXXos specific UUID
si.versions(apps, cb){...}XXXXXversion information (kernel, ssl, node, ...)
apps param is optional for detecting
only specific apps/libs
(string, comma separated)
si.shell(cb): stringXXXstandard shell
si.users(cb)[{...}]XXXXXarray of users online
[0].userXXXXXuser name
[0].ttyXXXXXterminal
[0].dateXXXXXlogin date
[0].timeXXXXXlogin time
[0].ipXXXXip address (remote login)
[0].commandXXXXlast command or shell
8. Current Load, Processes & Services
FunctionResult objectLinuxBSDMacWinSunComments
si.currentLoad(cb){...}XXXXCPU-Load
avgloadXXXaverage load
currentloadXXXXCPU load in %
currentload_userXXXXCPU load user in %
currentload_systemXXXXCPU load system in %
currentload_niceXXXXCPU load nice in %
currentload_idleXXXXCPU load idle in %
currentload_irqXXXXCPU load system in %
raw_currentload...XXXXCPU load raw values (ticks)
cpus[]XXXXcurrent loads per CPU in % + raw ticks
si.fullLoad(cb): integerXXXCPU full load since bootup in %
si.processes(cb){...}XXXXX# running processes
allXXXXX# of all processes
runningXXXXX# of all processes running
blockedXXXXX# of all processes blocked
sleepingXXXXX# of all processes sleeping
unknownX# of all processes unknown status
list[]XXXXXlist of all processes incl. details
...[0].pidXXXXXprocess PID
...[0].parentPidXXXXXparent process PID
...[0].nameXXXXXprocess name
...[0].pcpuXXXXXprocess % CPU usage
...[0].pcpuuXXXprocess % CPU usage (user)
...[0].pcpusXXXprocess % CPU usage (system)
...[0].pmemXXXXXprocess memory %
...[0].priorityXXXXXprocess priotity
...[0].mem_vszXXXXXprocess virtual memory size
...[0].mem_rssXXXXXprocess mem resident set size
...[0].niceXXXXprocess nice value
...[0].startedXXXXXprocess start time
...[0].stateXXXXXprocess state (e.g. sleeping)
...[0].ttyXXXXtty from which process was started
...[0].userXXXXuser who started process
...[0].commandXXXXXprocess starting command
...[0].paramsXXXXprocess params
...[0].pathXXXXXprocess path
procXXXXprocess name
pidXXXXPID
pidsXXXXadditional pids
cpuXXXXprocess % CPU
memXXXXprocess % MEM
si.services('mysql, apache2', cb)[{...}]XXXXpass comma separated string of services
pass "*" for ALL services (linux/win only)
[0].nameXXXXname of service
[0].runningXXXXtrue / false
[0].startmodeXmanual, automatic, ...
[0].pidsXXXXpids
[0].pcpuXXXprocess % CPU
[0].pmemXXXprocess % MEM
9. File System
FunctionResult objectLinuxBSDMacWinSunComments
si.diskLayout(cb)[{...}]XXXphysical disk layout (array)
[0].deviceXXe.g. /dev/sda
[0].typeXXXHD, SSD, NVMe
[0].nameXXXdisk name
[0].vendorXXvendor/producer
[0].sizeXXXsize in bytes
[0].bytesPerSectorXbytes per sector
[0].totalCylindersXtotal cylinders
[0].totalHeadsXtotal heads
[0].totalSectorsXtotal sectors
[0].totalTracksXtotal tracks
[0].tracksPerCylinderXtracks per cylinder
[0].sectorsPerTrackXsectors per track
[0].firmwareRevisionXXXfirmware revision
[0].serialNumXXXserial number
[0].interfaceTypeXXSATA, PCIe, ...
[0].smartStatusXXXS.M.A.R.T Status (see Known Issues)
[0].smartDataXfull S.M.A.R.T data from smartctl
requires at least smartmontools 7.0
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.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.fsSize(cb)[{...}]XXXXreturns array of mounted file systems
[0].fsXXXXname of file system
[0].typeXXXXtype of file system
[0].sizeXXXXsizes in bytes
[0].usedXXXXused in bytes
[0].useXXXXused in %
[0].mountXXXXmount point
si.fsOpenFiles(cb){...}XXXcount max/allocated file descriptors
maxXXXmax file descriptors
allocatedXXXcurrent open files count
availableXXXcount available
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)
FunctionResult objectLinuxBSDMacWinSunComments
si.networkInterfaces(cb)[{...}]XXXXXarray of network interfaces
[0].ifaceXXXXXinterface
[0].ifaceNameXXXXXinterface name (differs on Windows)
[0].ip4XXXXXip4 address
[0].ip4subnetXXXXXip4 subnet mask
[0].ip6XXXXXip6 address
[0].ip6subnetXXXXXip6 subnet mask
[0].macXXXXXMAC address
[0].internalXXXXXtrue if internal interface
[0].virtualXXXXXtrue if virtual interface
[0].operstateXXXup / down
[0].typeXXXwireless / wired
[0].duplexXXduplex
[0].mtuXXmaximum transmission unit
[0].speedXXXspeed in MBit / s
[0].dhcpXXXIP address obtained by DHCP
[0].dnsSuffixXXDNS suffix
[0].ieee8021xAuthXXIEEE 802.1x auth
[0].ieee8021xStateXXIEEE 802.1x state
[0].carrierChangesX# changes up/down
si.networkInterfaceDefault(cb): stringXXXXXget name of default network interface
si.networkGatewayDefault(cb): stringXXXXXget default network gateway
si.networkStats(ifaces,cb)[{...}]XXXXcurrent network stats of given interfaces
iface list: space or comma separated
iface parameter is optional
defaults to first external network interface,
Pass '*' for all interfaces
[0].ifaceXXXXinterface
[0].operstateXXXXup / down
[0].rx_bytesXXXXreceived bytes overall
[0].rx_droppedXXXXreceived dropped overall
[0].rx_errorsXXXXreceived errors overall
[0].tx_bytesXXXXtransferred bytes overall
[0].tx_droppedXXXXtransferred dropped overall
[0].tx_errorsXXXXtransferred errors overall
[0].rx_secXXXXreceived bytes / second (* see notes)
[0].tx_secXXXXtransferred bytes per second (* see notes)
[0].msXXXXinterval length (for per second values)
si.networkConnections(cb)[{...}]XXXXcurrent network network connections
returns an array of all connections
[0].protocolXXXXtcp or udp
[0].localaddressXXXXlocal address
[0].localportXXXXlocal port
[0].peeraddressXXXXpeer address
[0].peerportXXXXpeer port
[0].stateXXXXlike ESTABLISHED, TIME_WAIT, ...
[0].pidXXXXprocess ID
[0].processXXprocess name
si.inetChecksite(url, cb){...}XXXXXresponse-time (ms) to fetch given URL
urlXXXXXgiven url
okXXXXXstatus code OK (2xx, 3xx)
statusXXXXXstatus code
msXXXXXresponse time in ms
si.inetLatency(host, cb): numberXXXXXresponse-time (ms) to external resource
host parameter is optional (default 8.8.8.8)
11. Wifi networks
FunctionResult objectLinuxBSDMacWinSunComments
si.wifiNetworks(cb)[{...}]XXXarray of available wifi networks
[0].ssidXXXWifi network SSID
[0].bssidXXXBSSID (mac)
[0].modeXmode
[0].channelXXXchannel
[0].frequencyXXXfrequengy in MHz
[0].signalLevelXXXsignal level in dB
[0].qualityXXXquaility in %
[0].securityXXXarray e.g. WPA, WPA-2
[0].wpaFlagsXXXarray of WPA flags
[0].rsnFlagsXarray of RDN flags
12. Docker
FunctionResult objectLinuxBSDMacWinSunComments
si.dockerInfo(cb){...}XXXXXreturns general docker info
idXXXXXDocker ID
containersXXXXXnumber of containers
containersRunningXXXXXnumber of running containers
containersPausedXXXXXnumber of paused containers
containersStoppedXXXXXnumber of stopped containers
imagesXXXXXnumber of images
driverXXXXXdriver (e.g. 'devicemapper', 'overlay2')
memoryLimitXXXXXhas memory limit
swapLimitXXXXXhas swap limit
kernelMemoryXXXXXhas kernal memory
cpuCfsPeriodXXXXXhas CpuCfsPeriod
cpuCfsQuotaXXXXXhas CpuCfsQuota
cpuSharesXXXXXhas CPUShares
cpuSetXXXXXhas CPUShares
ipv4ForwardingXXXXXhas IPv4Forwarding
bridgeNfIptablesXXXXXhas BridgeNfIptables
bridgeNfIp6tablesXXXXXhas BridgeNfIp6tables
debugXXXXXDebug on
nfdXXXXXnamed data networking forwarding daemon
oomKillDisableXXXXXout-of-memory kill disabled
ngoroutinesXXXXXnumber NGoroutines
systemTimeXXXXXdocker SystemTime
loggingDriverXXXXXlogging driver e.g. 'json-file'
cgroupDriverXXXXXcgroup driver e.g. 'cgroupfs'
nEventsListenerXXXXXnumber NEventsListeners
kernelVersionXXXXXdocker kernel version
operatingSystemXXXXXdocker OS e.g. 'Docker for Mac'
osTypeXXXXXOSType e.g. 'linux'
architectureXXXXXarchitecture e.g. x86_64
ncpuXXXXXnumber of CPUs
memTotalXXXXXmemory total
dockerRootDirXXXXXdocker root directory
httpProxyXXXXXhttp proxy
httpsProxyXXXXXhttps proxy
noProxyXXXXXNoProxy
nameXXXXXName
labelsXXXXXarray of labels
experimentalBuildXXXXXis experimental build
serverVersionXXXXXserver version
clusterStoreXXXXXcluster store
clusterAdvertiseXXXXXcluster advertise
defaultRuntimeXXXXXdefault runtime e.g. 'runc'
liveRestoreEnabledXXXXXlive store enabled
isolationXXXXXisolation
initBinaryXXXXXinit binary
productLicenseXXXXXproduct license
si.dockerContainers(all, cb)[{...}]XXXXXreturns array of active/all docker containers
[0].idXXXXXID of container
[0].nameXXXXXname of container
[0].imageXXXXXname of image
[0].imageIDXXXXXID of image
[0].commandXXXXXcommand
[0].createdXXXXXcreation time (unix)
[0].startedXXXXXcreation time (unix)
[0].finishedXXXXXcreation time (unix)
[0].createdAtXXXXXcreation date time string
[0].startedAtXXXXXcreation date time string
[0].finishedAtXXXXXcreation date time string
[0].stateXXXXXcreated, running, exited
[0].portsXXXXXarray of ports
[0].mountsXXXXXarray of mounts
si.dockerContainerStats(ids, cb)[{...}]XXXXXstatistics for specific containers
container IDs: space or comma separated,
pass '*' for all containers
[0].idXXXXXContainer ID
[0].mem_usageXXXXXmemory usage in bytes
[0].mem_limitXXXXXmemory limit (max mem) in bytes
[0].mem_percentXXXXXmemory usage in percent
[0].cpu_percentXXXXXcpu usage in percent
[0].pidsXXXXXnumber of processes
[0].netIO.rxXXXXXreceived bytes via network
[0].netIO.wxXXXXXsent bytes via network
[0].blockIO.rXXXXXbytes read from BlockIO
[0].blockIO.wXXXXXbytes written to BlockIO
[0].cpu_statsXXXXXdetailed cpu stats
[0].percpu_statsXXXXXdetailed per cpu stats
[0].memory_statsXXXXXdetailed memory stats
[0].networksXXXXXdetailed network stats per interface
si.dockerContainerProcesses(id, cb)[{...}]XXXXXarray of processes inside a container
[0].pid_hostXXXXXprocess ID (host)
[0].ppidXXXXXparent process ID
[0].pgidXXXXXprocess group ID
[0].userXXXXXeffective user name
[0].ruserXXXXXreal user name
[0].groupXXXXXeffective group name
[0].rgroupXXXXXreal group name
[0].statXXXXXprocess state
[0].timeXXXXXaccumulated CPU time
[0].elapsedXXXXXelapsed running time
[0].niceXXXXXnice value
[0].rssXXXXXresident set size
[0].vszXXXXXvirtual size in Kbytes
[0].commandXXXXXcommand and arguments
si.dockerAll(cb){...}XXXXXlist of all containers including their stats
and processes in one single array
13. Virtual Box
FunctionResult objectLinuxBSDMacWinSunComments
si.vboxInfo(cb)[{...}]XXXXXreturns array general virtual box info
[0].idXXXXXvirtual box ID
[0].nameXXXXXname
[0].runningXXXXXvbox is running
[0].startedXXXXXstarted date time
[0].runningSinceXXXXXrunning since (secs)
[0].stoppedXXXXXstopped date time
[0].stoppedSinceXXXXXstopped since (secs)
[0].guestOSXXXXXGuest OS
[0].hardwareUUIDXXXXXHardware UUID
[0].memoryXXXXXMemory in MB
[0].vramXXXXXVRAM in MB
[0].cpusXXXXXCPUs
[0].cpuExepCapXXXXXCPU exec cap
[0].cpuProfileXXXXXCPU profile
[0].chipsetXXXXXchipset
[0].firmwareXXXXXfirmware
[0].pageFusionXXXXXpage fusion
[0].configFileXXXXXconfig file
[0].snapshotFolderXXXXXsnapshot folder
[0].logFolderXXXXXlog folder path
[0].HPETXXXXXHPET
[0].PAEXXXXXPAE
[0].longModeXXXXXlong mode
[0].tripleFaultResetXXXXXtriple fault reset
[0].APICXXXXXAPIC
[0].X2APICXXXXXX2APIC
[0].ACPIXXXXXACPI
[0].IOAPICXXXXXIOAPIC
[0].biosAPICmodeXXXXXBIOS APIC mode
[0].bootMenuModeXXXXXboot menu Mode
[0].bootDevice1XXXXXbootDevice1
[0].bootDevice2XXXXXbootDevice2
[0].bootDevice3XXXXXbootDevice3
[0].bootDevice4XXXXXbootDevice4
[0].timeOffsetXXXXXtime Offset
[0].RTCXXXXXRTC
14. "Get All / Observe" - functions
FunctionResult objectLinuxBSDMacWinSunComments
si.getStaticData(cb){...}XXXXXall static data at once
si.getDynamicData(srv,iface,cb){...}XXXXXall dynamic data at once
Specify services and interfaces to monitor
Defaults to first external network interface
Pass "" for ALL services (linux/win only)
Pass "
" for ALL network interfaces
si.getAllData(srv,iface,cb){...}XXXXXall data at once
Specify services and interfaces to monitor
Defaults to first external network interface
Pass "" for ALL services (linux/win only)
Pass "
" for ALL network interfaces
si.get(valueObject,cb){...}XXXXXget partial system info data at once
In valueObject you can define
all values, you want to get back
(see documentation for details)
si.observe(valueObject,interval,cb)-XXXXXObserve a defined value object
call callback on changes
polling interval in milliseconds

cb: Asynchronous Function Calls (callback)

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

Callback Style

const si = require('@jedithepro/system-info');

si.cpu(function(data) {
  console.log('CPU Information:');
  console.log('- manufucturer: ' + data.manufacturer);
  console.log('- brand: ' + data.brand);
  console.log('- speed: ' + data.speed);
  console.log('- cores: ' + data.cores);
  console.log('- physical cores: ' + data.physicalCores);
  console.log('...');
})

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 (except of version and time) are returning a promise, that you can consume:

const si = require('@jedithepro/system-info');

si.cpu()
  .then(data => {
    console.log('CPU Information:');
    console.log('- manufucturer: ' + data.manufacturer);
    console.log('- brand: ' + data.brand);
    console.log('- speed: ' + data.speed);
    console.log('- cores: ' + data.cores);
    console.log('- physical cores: ' + data.physicalCores);
    console.log('...');
  })
  .catch(error => console.error(error));

Async / Await

Using async / await (available since node v7.6)

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

const si = require('@jedithepro/system-info');

async function cpuData() {
  try {
    const data = await si.cpu();
    console.log('CPU Information:');
    console.log('- manufucturer: ' + data.manufacturer);
    console.log('- brand: ' + data.brand);
    console.log('- speed: ' + data.speed);
    console.log('- cores: ' + data.cores);
    console.log('- physical cores: ' + data.physicalCores);
    console.log('...');
  } catch (e) {
    console.log(e)
  }
}

Known Issues

macOS - Temperature Sensor

To be able to measure temperature on macOS I created a little additional package. Due to some difficulties in NPM with optionalDependencies I unfortunately was getting unexpected warnings on other platforms. So I decided to drop this optional dependency for macOS - so by default, you will not get correct values.

But if you need to detect macOS temperature just run the following additional installation command:

$ npm install osx-temperature-sensor --save

@jedithepro/system-info will then detect this additional library and return the temperature when calling systeminformations standard function cpuTemperature()

Windows Temperature, Battery, ...

wmic - which is used to determine temperature and battery sometimes needs to be run with admin privileges. So if you do not get any values, try to run it again with according privileges. If you still do not get any values, your system might not support this feature. In some cases we also discovered that wmic returned incorrect temperature values.

Linux Temperature

In some cases you need to install the Linux sensors package to be able to measure temperature e.g. on DEBIAN based systems by running sudo apt-get install lm-sensors

Linux S.M.A.R.T. Status

To be able to detect S.M.A.R.T. status on Linux you need to install smartmontools. On DEBIAN based Linux distributions you can install it by running sudo apt-get install smartmontools

*: Additional Notes

In fsStats(), disksIO() and networkStats() the results / sec. values (rx_sec, IOPS, ...) are calculated correctly 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.

The first time you are calling one of these functions, you will get -1 for transfer rates. The second time, you should then get statistics based on the time between the two calls ...

So basically, if you e.g. need a value for network stats every second, your code should look like this:

const si = require('@jedithepro/system-info');

setInterval(function() {
  si.networkStats().then(data => {
    console.log(data);
  })
}, 1000)

Beginning with the second call, you get network transfer values per second.

Linux is a registered trademark of Linus Torvalds. Apple, macOS, OS X are registered trademarks 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, 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, Ubuntu is a trademark of Canonical Ltd., FreeBSD is a registered trademark of The FreeBSD Foundation, NetBSD is a registered trademark of The NetBSD Foundation, 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.

Keywords

FAQs

Package last updated on 15 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc