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

systeminformation

Package Overview
Dependencies
Maintainers
1
Versions
653
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

systeminformation - npm Package Compare versions

Comparing version 3.10.2 to 3.11.0

7

CHANGELOG.md

@@ -1,2 +0,2 @@

# Changelog
# Changelog

@@ -9,6 +9,6 @@ ### Major (breaking) Changes - Version 3

- `mem`: now supports also newer versions of `free` (Version 3.3.10 and above); extended information `avaliable` (potentially available memory)
- `fsStats`: added information sum bytes read + write (tx) and sum transfer rate/sec (tx_sec)
- `fsStats`: added information sum bytes read + write (tx) and sum transfer rate/sec (tx_sec)
- `networkInterfaces`: now providing one more detail: internal - true if this is an internal interface like "lo"
- `networkConnections`: instead of only counting sockets, you now get an array of objects with connection details for each socket (protocol, local and peer address, state)
- `users`: now provides an array of objects with users online including detailed session information (login date/time, ip address, terminal, command)
- `users`: now provides an array of objects with users online including detailed session information (login date/time, ip address, terminal, command)
- `inetLatency`: now you can provide a host against which you want to test latency (default is 8.8.8.8)

@@ -93,2 +93,3 @@ - `getDynamicData`: changed order of parameters (callback - if provided - is now the last one): `getDynamicData(srv, network, callback)`

| -------------- | -------------- | -------- |
| 3.11.0 | 2016-11-15 | blockDevices for OSX and extended blockDevices |
| 3.10.2 | 2016-11-14 | bug fix fsSize on OSX |

@@ -95,0 +96,0 @@ | 3.10.1 | 2016-11-14 | optimization fsStats, disksIO, networkStats |

@@ -55,3 +55,3 @@ 'use strict';

var result = {
let result = {
manufacturer: 'unknown',

@@ -187,3 +187,3 @@ brand: 'unknown',

var result = {
let result = {
main: -1.0,

@@ -190,0 +190,0 @@ cores: [],

@@ -24,4 +24,4 @@ 'use strict';

var _docker_container_stats = {};
var _docker_socket;
let _docker_container_stats = {};
let _docker_socket;

@@ -52,3 +52,3 @@

all = all || false;
var result = [];
let result = [];
return new Promise((resolve, reject) => {

@@ -67,3 +67,3 @@ process.nextTick(() => {

_docker_socket.listContainers(all, data => {
var docker_containers = {};
let docker_containers = {};
// let cmd = "curl --unix-socket /var/run/docker.sock http:/containers/json" + (all ? "?all=1" : "");

@@ -74,3 +74,3 @@ // exec(cmd, function (error, stdout) {

// let jsonString = stdout.toString();
// var docker_containers = JSON.parse(jsonString);
// let docker_containers = JSON.parse(jsonString);
docker_containers = data;

@@ -116,3 +116,3 @@ if (docker_containers && Object.prototype.toString.call(docker_containers) === '[object Array]' && docker_containers.length > 0) {

// GC in _docker_container_stats
for (var key in _docker_container_stats) {
for (let key in _docker_container_stats) {
if (_docker_container_stats.hasOwnProperty(key)) {

@@ -144,7 +144,7 @@ if (!inContainers(docker_containers, key)) delete _docker_container_stats[key];

var cpuPercent = 0.0;
let cpuPercent = 0.0;
// calculate the change for the cpu usage of the container in between readings
var cpuDelta = cpu_stats.cpu_usage.total_usage - (_docker_container_stats[id] && _docker_container_stats[id].prev_CPU ? _docker_container_stats[id].prev_CPU : 0);
let cpuDelta = cpu_stats.cpu_usage.total_usage - (_docker_container_stats[id] && _docker_container_stats[id].prev_CPU ? _docker_container_stats[id].prev_CPU : 0);
// calculate the change for the entire system between readings
var systemDelta = cpu_stats.system_cpu_usage - (_docker_container_stats[id] && _docker_container_stats[id].prev_system ? _docker_container_stats[id].prev_system : 0);
let systemDelta = cpu_stats.system_cpu_usage - (_docker_container_stats[id] && _docker_container_stats[id].prev_system ? _docker_container_stats[id].prev_system : 0);

@@ -162,5 +162,5 @@ if (systemDelta > 0.0 && cpuDelta > 0.0) {

function docker_calcNetworkIO(networks) {
var rx;
var tx;
for (var key in networks) {
let rx;
let tx;
for (let key in networks) {
// skip loop if the property is from prototype

@@ -174,3 +174,3 @@ if (!networks.hasOwnProperty(key)) continue;

*/
var obj = networks[key];
let obj = networks[key];
rx = +obj.rx_bytes;

@@ -219,3 +219,3 @@ tx = +obj.tx_bytes;

containerID = containerID || '';
var result = {
let result = {
id: containerID,

@@ -303,3 +303,3 @@ mem_usage: 0,

containerID = containerID || '';
var result = [];
let result = [];
return new Promise((resolve, reject) => {

@@ -329,16 +329,16 @@ process.nextTick(() => {

});
var pos_pid = titles.indexOf('PID');
var pos_ppid = titles.indexOf('PPID');
var pos_pgid = titles.indexOf('PGID');
var pos_vsz = titles.indexOf('VSZ');
var pos_time = titles.indexOf('TIME');
var pos_elapsed = titles.indexOf('ELAPSED');
var pos_ni = titles.indexOf('NI');
var pos_ruser = titles.indexOf('RUSER');
var pos_user = titles.indexOf('USER');
var pos_rgroup = titles.indexOf('RGROUP');
var pos_group = titles.indexOf('GROUP');
var pos_stat = titles.indexOf('STAT');
var pos_rss = titles.indexOf('RSS');
var pos_command = titles.indexOf('COMMAND');
let pos_pid = titles.indexOf('PID');
let pos_ppid = titles.indexOf('PPID');
let pos_pgid = titles.indexOf('PGID');
let pos_vsz = titles.indexOf('VSZ');
let pos_time = titles.indexOf('TIME');
let pos_elapsed = titles.indexOf('ELAPSED');
let pos_ni = titles.indexOf('NI');
let pos_ruser = titles.indexOf('RUSER');
let pos_user = titles.indexOf('USER');
let pos_rgroup = titles.indexOf('RGROUP');
let pos_group = titles.indexOf('GROUP');
let pos_stat = titles.indexOf('STAT');
let pos_rss = titles.indexOf('RSS');
let pos_command = titles.indexOf('COMMAND');

@@ -389,3 +389,3 @@ data.Processes.forEach(process => {

if (result && Object.prototype.toString.call(result) === '[object Array]' && result.length > 0) {
var l = result.length;
let l = result.length;
result.forEach(function (element) {

@@ -392,0 +392,0 @@ dockerContainerStats(element.id).then(res => {

@@ -75,2 +75,64 @@ 'use strict';

function parseBytes(s) {
return parseInt(s.substr(s.indexOf(' (')+2, s.indexOf(' Bytes)')-10))
}
function parseDevices (lines) {
let devices = [];
let i = 0;
lines.forEach(line => {
if (line.length > 0) {
if (line[0] == '*') {
i++;
} else {
let parts = line.split(':');
if (parts.length > 1) {
if (!devices[i]) devices[i] = {
name: '',
identifier: '',
type: 'disk',
fstype: '',
mount: '',
size: 0,
physical: 'HDD',
uuid: '',
label: '',
model: '',
serial: '',
protocol: ''
};
parts[0] = parts[0].trim().toUpperCase().replace(/ +/g, '');
parts[1] = parts[1].trim();
if ('DEVICEIDENTIFIER' == parts[0]) devices[i].identifier = parts[1];
if ('DEVICENODE' == parts[0]) devices[i].name = parts[1];
if ('VOLUMENAME' == parts[0]) { if (parts[1].indexOf('Not applicable') == -1) devices[i].label = parts[1]; }
if ('PROTOCOL' == parts[0]) devices[i].protocol = parts[1];
if ('DISKSIZE' == parts[0]) devices[i].size = parseBytes(parts[1]);
if ('FILESYSTEMPERSONALITY' == parts[0]) devices[i].fstype = parts[1];
if ('MOUNTPOINT' == parts[0]) devices[i].mount = parts[1];
if ('VOLUMEUUID' == parts[0]) devices[i].uuid = parts[1];
if ('READ-ONLYMEDIA' == parts[0] && parts[1] == 'Yes') devices[i].physical = 'CD/DVD';
if ('SOLIDSTATE' == parts[0] && parts[1] == 'Yes') devices[i].physical = 'SSD';
if ('VIRTUAL' == parts[0]) devices[i].type = 'virtual';
if ('PARTITIONTYPE' == parts[0]) devices[i].type = 'part';
if ('DEVICE/MEDIANAME' == parts[0]) devices[i].model = parts[1];
}
}
}
});
return devices;
}
function fromTo(header, label) {
let from = header.indexOf(label);
let to = from + label.length;
for (let i = to; i < header.length && header[i] == ' '; i++) {
to = i
}
console.log(label + ' - ' + from + ' ' + to);
return {
from: from,
to: to
}
}
function blockDevices(callback) {

@@ -87,3 +149,4 @@

if (_linux) {
exec("lsblk -bo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,OWNER,GROUP,MODE,LABEL,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,SCHED,RQ-SIZE,RA,WSAME", function (error, stdout) {
// 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) {
let data = [];

@@ -93,9 +156,13 @@ if (!error) {

let header = lines[0];
let ft_label = fromTo(header, 'LABEL');
let ft_model = fromTo(header, 'MODEL');
let ft_serial = fromTo(header, 'SERIAL');
lines.splice(0, 1);
lines.forEach(function (line) {
if (line != '') {
if (line.substr(header.indexOf('FSTYPE'), 1) == ' ') { line = line.substr(0, header.indexOf('FSTYPE')) + '-' + line.substr(header.indexOf('FSTYPE') + 1, 1000)}
if (line.substr(header.indexOf('MOUNTPOINT'), 1) == ' ') { line = line.substr(0, header.indexOf('MOUNTPOINT')) + '-' + line.substr(header.indexOf('MOUNTPOINT') + 1, 1000)}
if (line.substr(header.indexOf('UUID'), 1) == ' ') { line = line.substr(0, header.indexOf('UUID')) + '-' + line.substr(header.indexOf('UUID') + 1, 1000)}
line = line.replace(/[├─│└]+/g, "");
lines.forEach(orgline => {
if (orgline != '') {
if (orgline.substr(header.indexOf('FSTYPE'), 1) == ' ') { orgline = orgline.substr(0, header.indexOf('FSTYPE')) + '-' + orgline.substr(header.indexOf('FSTYPE') + 1, 1000)}
if (orgline.substr(header.indexOf('MOUNTPOINT'), 1) == ' ') { orgline = orgline.substr(0, header.indexOf('MOUNTPOINT')) + '-' + orgline.substr(header.indexOf('MOUNTPOINT') + 1, 1000)}
if (orgline.substr(header.indexOf('UUID'), 1) == ' ') { orgline = orgline.substr(0, header.indexOf('UUID')) + '-' + orgline.substr(header.indexOf('UUID') + 1, 1000)}
if (orgline.substr(header.indexOf('TRAN'), 1) == ' ') { orgline = orgline.substr(0, header.indexOf('TRAN')) + '-' + orgline.substr(header.indexOf('TRAN') + 1, 1000)}
let line = orgline.replace(/[├─│└]+/g, "");
line = line.replace(/ +/g, " ").trim().split(' ');

@@ -109,3 +176,7 @@ data.push({

'physical': (line[1] == 'disk' ? (line[6] == '0' ? 'SSD' : 'HDD') : (line[1] == 'rom' ? 'CD/DVD' : '')),
'uuid': (line[5] == '-' ? '' : line[5])
'uuid': (line[5] == '-' ? '' : line[5]),
'label': orgline.substring(ft_label.from, ft_label.to).trim(),
'model': orgline.substring(ft_model.from, ft_model.to).trim(),
'serial': orgline.substring(ft_serial.from, ft_serial.to).trim(),
'protocol': (line[8] == '-' ? '' : line[8])
})

@@ -125,7 +196,14 @@ }

// last minute decision to remove code ... not stable
let data = [];
if (callback) {
callback(data)
}
resolve(data);
exec("diskutil info -all", function (error, stdout) {
let data = [];
if (!error) {
let lines = stdout.toString().split('\n');
// parse lines into temp array of devices
data = parseDevices(lines);
}
if (callback) {
callback(data)
}
resolve(data);
});
}

@@ -132,0 +210,0 @@ });

@@ -84,2 +84,3 @@ 'use strict';

// version date comment
// 3.11.0 2016-11-15 blockDevices for OSX and extended blockDevices
// 3.10.2 2016-11-14 bug fix fsSize on OSX

@@ -150,4 +151,4 @@ // 3.10.1 2016-11-14 optimization fsStats, disksIO, networkStats

var _platform = os.type();
var _windows = (_platform == 'Windows_NT');
let _platform = os.type();
let _windows = (_platform == 'Windows_NT');

@@ -181,3 +182,3 @@ const NOT_SUPPORTED = 'not supported';

var data = {};
let data = {};

@@ -241,4 +242,4 @@ data.version = version();

// use closure to track ƒ completion
var functionProcessed = (function () {
var totalFunctions = 14;
let functionProcessed = (function () {
let totalFunctions = 14;

@@ -261,3 +262,3 @@ return function () {

var data = {};
let data = {};

@@ -366,3 +367,3 @@ // get time

var data = {};
let data = {};

@@ -372,3 +373,3 @@ getStaticData().then(res => {

getDynamicData(srv, iface).then(res => {
for (var key in res) {
for (let key in res) {
if (res.hasOwnProperty(key)) {

@@ -375,0 +376,0 @@ data[key] = res[key];

@@ -39,3 +39,3 @@ 'use strict';

var result = {
let result = {
url: url,

@@ -47,3 +47,3 @@ ok: false,

if (url) {
var t = Date.now();
let t = Date.now();
let args = " -I --connect-timeout 5 -m 5 " + url + " 2>/dev/null | head -n 1 | cut -d ' ' -f2";

@@ -90,3 +90,3 @@ let cmd = "curl";

var t = Date.now();
let t = Date.now();
let cmd;

@@ -93,0 +93,0 @@ if (_linux) {

@@ -87,3 +87,3 @@ 'use strict';

var result = {
let result = {
total: os.totalmem(),

@@ -90,0 +90,0 @@ free: os.freemem(),

@@ -275,3 +275,3 @@ 'use strict';

var result = [];
let result = [];
if (_linux) {

@@ -281,3 +281,3 @@ let cmd = "netstat -tuna | grep 'ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN'";

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -325,3 +325,3 @@ line = line.replace(/ +/g, " ").split(' ');

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -328,0 +328,0 @@ line = line.replace(/ +/g, " ").split(' ');

@@ -93,3 +93,3 @@ 'use strict';

var result = {
let result = {

@@ -118,4 +118,4 @@ platform: _platform,

*/
var release = {};
var lines = stdout.toString().split('\n');
let release = {};
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -137,3 +137,3 @@ if (line.indexOf('=') != -1) {

exec("sw_vers", function (error, stdout) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -140,0 +140,0 @@ if (line.indexOf('ProductName') != -1) {

@@ -228,11 +228,11 @@ 'use strict';

srv = srv.trim().replace(/,+/g, " ").replace(/ +/g, " ").replace(/ +/g, "|");
var srvs = srv.split('|');
var comm = (_darwin) ? "ps -caxm -o pcpu,pmem,comm" : "ps axo pcpu,pmem,comm";
var data = [];
let srvs = srv.split('|');
let comm = (_darwin) ? "ps -caxm -o pcpu,pmem,comm" : "ps axo pcpu,pmem,comm";
let data = [];
if (srv != '' && srvs.length > 0) {
exec(comm + " | grep -v grep | egrep '" + srv + "'", function (error, stdout) {
if (!error) {
var lines = stdout.toString().replace(/ +/g, " ").replace(/,+/g, ".").split('\n');
let lines = stdout.toString().replace(/ +/g, " ").replace(/,+/g, ".").split('\n');
srvs.forEach(function (srv) {
var ps = lines.filter(function (e) {
let ps = lines.filter(function (e) {
return e.indexOf(srv) != -1

@@ -539,3 +539,3 @@ });

var result = {
let result = {
'proc': proc,

@@ -542,0 +542,0 @@ 'pid': -1,

@@ -42,3 +42,3 @@ 'use strict';

var result = {
let result = {
manufacturer: '',

@@ -54,3 +54,3 @@ model: 'Computer',

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -74,3 +74,3 @@ if (line.indexOf(':') != -1) {

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -128,3 +128,3 @@ if (line.indexOf(':') != -1) {

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
if (lines.length > 0) result.model = 'Virtual machine'

@@ -144,3 +144,3 @@ }

if (!error) {
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {

@@ -163,2 +163,2 @@ line = line.replace(/[<>"]/g, "");

});
}
};

@@ -30,12 +30,12 @@ 'use strict';

function parseUsers1(lines) {
var result = [];
var result_who = [];
var result_w = {};
var w_first = true;
var w_header = [];
var w_pos = [];
var w_headerline = '';
var who_line = {};
let result = [];
let result_who = [];
let result_w = {};
let w_first = true;
let w_header = [];
let w_pos = [];
let w_headerline = '';
let who_line = {};
var is_whopart = true;
let is_whopart = true;
lines.forEach(function (line) {

@@ -45,3 +45,3 @@ if (line == '---') {

} else {
var l = line.replace(/ +/g, " ").split(' ');
let l = line.replace(/ +/g, " ").split(' ');

@@ -94,8 +94,8 @@ // who part

function parseUsers2(lines) {
var result = [];
var result_who = [];
var result_w = {};
var who_line = {};
let result = [];
let result_who = [];
let result_w = {};
let who_line = {};
var is_whopart = true;
let is_whopart = true;
lines.forEach(function (line) {

@@ -105,3 +105,3 @@ if (line == '---') {

} else {
var l = line.replace(/ +/g, " ").split(' ');
let l = line.replace(/ +/g, " ").split(' ');

@@ -153,3 +153,3 @@ // who part

var result = [];
let result = [];

@@ -161,3 +161,3 @@ // linux

// lines / split
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
result = parseUsers1(lines);

@@ -192,3 +192,3 @@ if (result.length == 0) {

// lines / split
var lines = stdout.toString().split('\n');
let lines = stdout.toString().split('\n');
result = parseUsers2(lines);

@@ -195,0 +195,0 @@

@@ -19,3 +19,3 @@ 'use strict';

function isFunction(functionToCheck) {
var getType = {};
let getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';

@@ -25,9 +25,9 @@ }

function unique(obj){
var uniques=[];
var stringify={};
for(var i=0;i<obj.length;i++){
var keys=Object.keys(obj[i]);
let uniques=[];
let stringify={};
for(let i=0;i<obj.length;i++){
let keys=Object.keys(obj[i]);
keys.sort(function(a,b) {return a-b});
var str='';
for(var j=0;j<keys.length;j++){
let str='';
for(let j=0;j<keys.length;j++){
str+= JSON.stringify(keys[j]);

@@ -34,0 +34,0 @@ str+= JSON.stringify(obj[i][keys[j]]);

{
"name": "systeminformation",
"version": "3.10.2",
"version": "3.11.0",
"description": "Simple system and OS information library",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -13,3 +13,3 @@ # systeminformation

Collection of 25+ 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 and OSX only)

@@ -46,2 +46,3 @@ ### Installation

- 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).

@@ -51,8 +52,8 @@ - Version 3.9.0: extended networkInterfaces (added MAC address).

- Version 3.7.0: extended docker stats.
- 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 process 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][docker-url] support. Now you can scan your docker containers and get their stats
- 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 process 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][docker-url] 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

@@ -180,2 +181,6 @@

| - [0].uuid | X | X | UUID |
| - [0].label | X | X | label |
| - [0].model | X | X | model |
| - [0].serial | X | | serial |
| - [0].protocol | X | X | protocol (SATA, PCI-Express, ...) |
| si.fsStats(cb) | X | X | current transfer stats |

@@ -321,3 +326,3 @@ | - rx | X | X | bytes read since startup |

**Promises Style** is new in version 3.0.
**Promises Style** is new in version 3.0.

@@ -324,0 +329,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:

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