systeminformation
Advanced tools
Comparing version 3.9.0 to 3.10.0
@@ -19,2 +19,3 @@ # Changelog | ||
- `blockDevices`: returns array of block devices like disks, partitions, raids, roms (new in version 3.10) | ||
- `dockerContainerProcesses`: returns processes for a specific docker container (new in version 3.8) | ||
@@ -92,2 +93,3 @@ - `versions`: returns object of versions - kernel, ssl, node, npm, ...(new in version 3.6) | ||
| -------------- | -------------- | -------- | | ||
| 3.10.0 | 2016-11-12 | added blockDevices, fixed fsSize, added file system type | | ||
| 3.9.0 | 2016-11-11 | added MAC address to networkInterfaces, fixed currentLoad | | ||
@@ -94,0 +96,0 @@ | 3.8.1 | 2016-11-04 | updated docs | |
@@ -31,3 +31,3 @@ 'use strict'; | ||
// -------------------------- | ||
// FS - devices | ||
// FS - mounted file systems | ||
@@ -44,3 +44,3 @@ function fsSize(callback) { | ||
exec("df -lk | grep ^/", function (error, stdout) { | ||
exec("df -lkPT | grep ^/", function (error, stdout) { | ||
let data = []; | ||
@@ -55,5 +55,6 @@ if (!error) { | ||
'fs': line[0], | ||
'size': parseInt(line[1]) * 1024, | ||
'used': parseInt(line[2]) * 1024, | ||
'use': parseFloat((100.0 * line[2] / line[1]).toFixed(2)), | ||
'type': line[1], | ||
'size': parseInt(line[2]) * 1024, | ||
'used': parseInt(line[3]) * 1024, | ||
'use': parseFloat((100.0 * line[3] / line[2]).toFixed(2)), | ||
'mount': line[line.length - 1] | ||
@@ -74,2 +75,63 @@ }) | ||
// -------------------------- | ||
// disks | ||
function blockDevices(callback) { | ||
return new Promise((resolve, reject) => { | ||
process.nextTick(() => { | ||
if (_windows) { | ||
let error = new Error(NOT_SUPPORTED); | ||
if (callback) { callback(NOT_SUPPORTED) } | ||
reject(error); | ||
} | ||
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) { | ||
let data = []; | ||
if (!error) { | ||
let lines = stdout.toString().split('\n'); | ||
let header = lines[0]; | ||
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, ""); | ||
line = line.replace(/ +/g, " ").trim().split(' '); | ||
data.push({ | ||
'name': line[0], | ||
'type': line[1], | ||
'fstype': (line[3] == '-' ? '' : line[3]), | ||
'mount': (line[4] == '-' ? '' : line[4]), | ||
'size': parseInt(line[2]), | ||
'physical': (line[1] == 'disk' ? (line[6] == '0' ? 'SSD' : 'HDD') : (line[1] == 'rom' ? 'CD/DVD' : '')), | ||
'uuid': (line[5] == '-' ? '' : line[5]) | ||
}) | ||
} | ||
}); | ||
data = util.unique(data); | ||
data = util.sortByKey(data, ['type', 'name']); | ||
} | ||
if (callback) { | ||
callback(data) | ||
} | ||
resolve(data); | ||
}); | ||
} | ||
if (_darwin) { | ||
// last minute decision to remove code ... not stable | ||
let data = []; | ||
if (callback) { | ||
callback(data) | ||
} | ||
resolve(data); | ||
} | ||
}); | ||
}); | ||
} | ||
exports.blockDevices = blockDevices; | ||
// -------------------------- | ||
// FS - speed | ||
@@ -76,0 +138,0 @@ |
@@ -84,2 +84,3 @@ 'use strict'; | ||
// version date comment | ||
// 3.10.0 2016-11-12 added blockDevices, fixed fsSize, added file system type | ||
// 3.9.0 2016-11-11 added MAC address to networkInterfaces, fixed currentLoad | ||
@@ -400,2 +401,3 @@ // 3.8.1 2016-11-04 updated docs | ||
exports.fsSize = filesystem.fsSize; | ||
exports.blockDevices = filesystem.blockDevices; | ||
exports.fsStats = filesystem.fsStats; | ||
@@ -402,0 +404,0 @@ exports.disksIO = filesystem.disksIO; |
@@ -23,2 +23,32 @@ 'use strict'; | ||
function unique(obj){ | ||
var uniques=[]; | ||
var stringify={}; | ||
for(var i=0;i<obj.length;i++){ | ||
var keys=Object.keys(obj[i]); | ||
keys.sort(function(a,b) {return a-b}); | ||
var str=''; | ||
for(var j=0;j<keys.length;j++){ | ||
str+= JSON.stringify(keys[j]); | ||
str+= JSON.stringify(obj[i][keys[j]]); | ||
} | ||
if(!stringify.hasOwnProperty(str)){ | ||
uniques.push(obj[i]); | ||
stringify[str]=true; | ||
} | ||
} | ||
return uniques; | ||
} | ||
function sortByKey(array, keys) { | ||
return array.sort(function(a, b) { | ||
let x =''; | ||
let y =''; | ||
keys.forEach(function (key) { | ||
x = x + a[key]; y = y + b[key]; | ||
}); | ||
return ((x < y) ? -1 : ((x > y) ? 1 : 0)); | ||
}); | ||
} | ||
function cores() { | ||
@@ -32,2 +62,4 @@ if (_cores == 0) { | ||
exports.isFunction = isFunction; | ||
exports.unique = unique; | ||
exports.sortByKey= sortByKey; | ||
exports.cores = cores; |
{ | ||
"name": "systeminformation", | ||
"version": "3.9.0", | ||
"version": "3.10.0", | ||
"description": "Simple system and OS information library", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -45,2 +45,3 @@ # systeminformation | ||
- Version 3.10.0: added blockDevices (list of disks, partitions, raids and roms). | ||
- Version 3.9.0: extended networkInterfaces (added MAC address). | ||
@@ -164,2 +165,3 @@ - Version 3.8.0: added dockerContainerProcesses (array of processes inside a docker container). | ||
| - [0].fs | X | X | name of file system | | ||
| - [0].type | X | X | type of file system | | ||
| - [0].size | X | X | sizes in Bytes | | ||
@@ -169,2 +171,10 @@ | - [0].used | X | X | used in Bytes | | ||
| - [0].mount | X | X | mount point | | ||
| si.blockDevices(cb) | X | X | returns array of disks, partitions,<br>raids and roms | | ||
| - [0].name | X | X | name | | ||
| - [0].type | X | X | type | | ||
| - [0].fstype | X | X | file system type (e.g. ext4) | | ||
| - [0].mount | X | X | mount point | | ||
| - [0].size | X | X | size in bytes | | ||
| - [0].physical | X | X | physical type (HDD, SSD, CD/DVD) | | ||
| - [0].uuid | X | X | UUID | | ||
| si.fsStats(cb) | X | X | current transfer stats | | ||
@@ -171,0 +181,0 @@ | - rx | X | X | bytes read since startup | |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158986
3417
427