Merge pull request #1 from sebhildebrandt/master

Get lastest changes
This commit is contained in:
Esteban Garcia 2019-11-20 08:49:48 -05:00 committed by GitHub
commit 417432b125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 426 additions and 123 deletions

1
.gitignore vendored
View File

@ -60,6 +60,7 @@ npm*
CVS
.eslintrc.json
package-lock.json
yarn.lock
test/
dist/

View File

@ -30,6 +30,16 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.15.2 | 2019-11-10 | type definitions and docs update |
| 4.15.2 | 2019-11-10 | `mem()` improved calculation linux |
| 4.15.1 | 2019-11-10 | `diskLayout()` added support for older lsblk versions (linux) |
| 4.15.0 | 2019-11-10 | `cpu()` added governor (linux) |
| 4.14.17 | 2019-10-22 | `graphics()` improved display detection (windows) |
| 4.14.16 | 2019-10-19 | `graphics()` improved display detection (windows) |
| 4.14.15 | 2019-10-18 | `graphics()` fallback display detection (windows) |
| 4.14.14 | 2019-10-18 | `powerShell()` fixed error handling (windows) |
| 4.14.13 | 2019-10-15 | `networkConnections()` fixed parsing (linux) |
| 4.14.12 | 2019-10-14 | `getCpu()` fixed multi socket detection (linux) |
| 4.14.11 | 2019-10-01 | type definitions fix dockerInfo |
| 4.14.10 | 2019-10-01 | type definitions fix memLayout |
| 4.14.9 | 2019-10-01 | `processLoad()` fix windows |

View File

@ -29,7 +29,7 @@
[![Caretaker][caretaker-image]][caretaker-url]
[![MIT license][license-img]][license-url]
**2019-03-12** - 5th birthday of systeminformation. This is amazing. Started as a small projekt just for myself, it now has > 8,000 lines of code, > 200 versions published, up to 100,000 downloads per month, > 1 Mio downloads overall. Thank you to all who contributed to this project!
This is amazing. Started as a small project just for myself, it now has > 9,000 lines of code, > 250 versions published, up to 900,000 downloads per month, > 2 Mio downloads overall. Thank you to all who contributed to this project!
## New Version 4.0
@ -84,13 +84,13 @@ si.cpu()
(last 7 major and minor version releases)
- Version 4.15.0: `cpu()` added governor (linux)
- Version 4.14.0: `processes()` added process path and params
- Version 4.13.0: `networkConnections()` added PID, process
- Version 4.12.0: `networkInterfaces()` added property virtual
- Version 4.11.0: `wifiNetworks()` added available wifi networks
- Version 4.10.0: `graphics()` added windows multiple display support, added display size, connection, ...
- Version 4.9.0: `graphics()` added vendor, refresh rate, current resolution
- Version 4.8.0: added `vboxInfo()` detailed virtual box info
- ...
You can find all changes here: [detailed changelog][changelog-url]
@ -162,6 +162,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | speed | X | X | X | X | | in GHz e.g. '3.40' |
| | speedmin | X | | X | X | | in GHz e.g. '0.80' |
| | speedmax | X | X | X | X | | in GHz e.g. '3.90' |
| | governor | X | | | | | e.g. 'powersave' |
| | cores | X | X | X | X | | # cores |
| | physicalCores | X | X | X | X | | # physical cores |
| | processors | X | X | X | X | | # processors |
@ -203,6 +204,9 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | used | X | X | X | X | X | used (incl. buffers/cache) |
| | active | X | X | X | X | X | used actively (excl. buffers/cache) |
| | buffcache | X | X | X | | X | used by buffers+cache |
| | buffers | X | | | | | used by buffers |
| | cached | X | | | | | used by cache |
| | slab | X | | | | | used by slab |
| | available | X | X | X | X | X | potentially available (total - active) |
| | swaptotal | X | X | X | X | X | |
| | swapused | X | X | X | X | X | |
@ -302,7 +306,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| Function | Result object | Linux | BSD | Mac | Win | Sun | Comments |
| --------------- | ------------- | ----- | ------- | --- | --- | --- | -------- |
| si.currentLoad(cb) | {...} | X | | X | X | X | CPU-Load |
| | avgload | X | | X | X | X | average load |
| | avgload | X | | X | | X | average load |
| | currentload | X | | X | X | X | CPU load in % |
| | currentload_user | X | | X | X | X | CPU load user in % |
| | currentload_system | X | | X | X | X | CPU load system in % |
@ -431,6 +435,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].speed | X | | X | X | | speed in MBit / s |
| | [0].carrierChanges | X | | | | | # changes up/down |
| si.networkInterfaceDefault(cb) | : string | X | X | X | X | X | get name of default network interface |
| si.networkGatewayDefault(cb) | : string | X | X | X | X | X | get default network gateway |
| si.networkStats(ifaces,cb) | [{...}] | X | X | X | X | | current network stats of given interfaces<br>iface list: space or comma separated<br>iface parameter is optional<br>defaults to first external network interface,<br />Pass '*' for all interfaces |
| | [0].iface | X | X | X | X | | interface |
| | [0].operstate | X | X | X | X | | up / down |

View File

@ -125,6 +125,16 @@
<td></td>
<td>in GHz e.g. '3.90'</td>
</tr>
<tr>
<td></td>
<td>governor</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>e.g. 'powersave'</td>
</tr>
<tr>
<td></td>
<td>cores</td>

View File

@ -83,6 +83,56 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.15.3</th>
<td>2019-11-10</td>
<td><span class="code">type definitions</span> and docs update</td>
</tr>
<tr>
<th scope="row">4.15.2</th>
<td>2019-11-10</td>
<td><span class="code">mem()</span> improved calculation linux</td>
</tr>
<tr>
<th scope="row">4.15.1</th>
<td>2019-11-10</td>
<td><span class="code">diskLayout()</span> added support for older lsblk versions (linux)</td>
</tr>
<tr>
<th scope="row">4.15.0</th>
<td>2019-11-10</td>
<td><span class="code">cpu()</span> added governor (linux)</td>
</tr>
<tr>
<th scope="row">4.14.17</th>
<td>2019-10-22</td>
<td><span class="code">graphics()</span> improved display detection (windows)</td>
</tr>
<tr>
<th scope="row">4.14.16</th>
<td>2019-10-19</td>
<td><span class="code">graphics()</span> improved display detection (windows)</td>
</tr>
<tr>
<th scope="row">4.14.15</th>
<td>2019-10-18</td>
<td><span class="code">graphics()</span> fallback display detection (windows)</td>
</tr>
<tr>
<th scope="row">4.14.14</th>
<td>2019-10-18</td>
<td><span class="code">powershell()</span> fixed error handling (windows)</td>
</tr>
<tr>
<th scope="row">4.14.13</th>
<td>2019-10-15</td>
<td><span class="code">networkConnections()</span> fixed parsing (linux)</td>
</tr>
<tr>
<th scope="row">4.14.12</th>
<td>2019-10-14</td>
<td><span class="code">getCpu()</span> fixed multi socket detection (linux)</td>
</tr>
<tr>
<th scope="row">4.14.11</th>
<td>2019-10-01</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.14.11</span></div>
<div class="version">Current Version: <span id="version">4.15.3</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
@ -191,7 +191,7 @@
</div>
<div class="row number-section">
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">9,273</div>
<div class="numbers">9,445</div>
<div class="title">Lines of code</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
@ -199,7 +199,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">192</div>
<div class="numbers">215</div>
<div class="title">Dependends</div>
</div>
</div>

View File

@ -125,6 +125,36 @@
<td>X</td>
<td>used by buffers+cache</td>
</tr>
<tr>
<td></td>
<td>buffers</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>used by buffers</td>
</tr>
<tr>
<td></td>
<td>cached</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>used by cache</td>
</tr>
<tr>
<td></td>
<td>slab</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>used by slab</td>
</tr>
<tr>
<td></td>
<td>available</td>

View File

@ -215,6 +215,16 @@
<td>X</td>
<td>get name of default network interface</td>
</tr>
<tr>
<td>si.networkGatewayDefault(cb)</td>
<td>: string</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>get default network gateway</td>
</tr>
<tr>
<td>si.networkStats(iface,cb)</td>
<td>[{...}]</td>

View File

@ -81,7 +81,7 @@
<td>X</td>
<td></td>
<td>X</td>
<td>X</td>
<td></td>
<td>X</td>
<td>average load</td>
</tr>

View File

@ -122,7 +122,61 @@ const AMDBaseFrequencies = {
'7251': '2.1',
'7551P': '2.0',
'7401P': '2.0',
'7351P': '2.4'
'7351P': '2.4',
'2300X': '3.5',
'2500X': '3.6',
'2600': '3.1',
'2600E': '3.1',
'2600X': '3.6',
'2700': '3.2',
'2700E': '2.8',
'2700X': '3.7',
'Pro 2700X': '3.6',
'2920': '3.5',
'2950': '3.5',
'2970WX': '3.0',
'2990WX': '3.0',
'3200U': '2.6',
'3300U': '2.1',
'3500U': '2.1',
'3550H': '2.1',
'3580U': '2.1',
'3700U': '2.3',
'3750H': '2.3',
'3780U': '2.3',
'3500X': '3.6',
'3600': '3.6',
'Pro 3600': '3.6',
'3600X': '3.8',
'Pro 3700': '3.6',
'3700X': '3.6',
'3800X': '3.9',
'3900': '3.1',
'Pro 3900': '3.1',
'3900X': '3.8',
'3950X': '3.5',
'3960X': '3.8',
'3970X': '3.7',
'7232P': '3.1',
'7302P': '3.0',
'7402P': '2.8',
'7502P': '2.5',
'7702P': '2.0',
'7252': '3.1',
'7262': '3.2',
'7272': '2.9',
'7282': '2.8',
'7302': '3.0',
'7352': '2.3',
'7402': '2.8',
'7452': '2.35',
'7502': '2.5',
'7542': '2.9',
'7552': '2.2',
'7642': '2.3',
'7702': '2.0',
'7742': '2.25',
'7H12': '2.6'
};
const socketTypes = {
@ -240,6 +294,7 @@ function getCpu() {
speed: '0.00',
speedmin: '',
speedmax: '',
governor: '',
cores: util.cores(),
physicalCores: util.cores(),
processors: 1,
@ -283,7 +338,7 @@ function getCpu() {
let modelline = '';
let lines = [];
if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model;
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
exec('export LC_ALL=C; lscpu; echo -n "Governor: "; cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null; echo; unset LC_ALL', function (error, stdout) {
if (!error) {
lines = stdout.toString().split('\n');
}
@ -321,38 +376,22 @@ function getCpu() {
result.cache.l3 = util.getValue(lines, 'l3 cache');
if (result.cache.l3) { result.cache.l3 = parseInt(result.cache.l3) * (result.cache.l3.indexOf('K') !== -1 ? 1024 : 1); }
// socket type
lines = [];
exec('export LC_ALL=C; dmidecode t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) {
lines = stdout2.toString().split('\n');
if (lines && lines.length) {
result.socket = util.getValue(lines, 'Upgrade').replace('Socket', '').trim();
}
const threadsPerCore = util.getValue(lines, 'thread(s) per core') || '1';
const processors = util.getValue(lines, 'socket(s)') || '1';
let threadsPerCoreInt = parseInt(threadsPerCore, 10);
let processorsInt = parseInt(processors, 10);
result.physicalCores = result.cores / threadsPerCoreInt;
result.processors = processorsInt;
result.governor = util.getValue(lines, 'governor') || '';
// # processurs & # threads/core - method 1
let threadsPerCoreInt = 0;
lines = [];
exec('cat /proc/cpuinfo | grep -E "physical id|core id"', function (error2, stdout3) {
lines = stdout3.toString().split('\n');
if (lines && lines.length) {
result.processors = util.countUniqueLines(lines, 'physical id') || 1;
result.physicalCores = util.countUniqueLines(lines, 'core id') / result.processors;
if (result.physicalCores) {
threadsPerCoreInt = result.cores / result.physicalCores;
}
}
// # threads/core - method 2
if (threadsPerCoreInt === 0) {
const threadsPerCore = util.getValue(lines, 'thread(s) per core');
if (threadsPerCore) {
threadsPerCoreInt = parseInt(threadsPerCore, 10);
if (!isNaN(threadsPerCoreInt)) {
result.physicalCores = result.cores / threadsPerCoreInt;
}
}
}
resolve(result);
});
// socket type
let lines2 = [];
exec('export LC_ALL=C; dmidecode t 4 2>/dev/null | grep "Upgrade: Socket"; unset LC_ALL', function (error2, stdout2) {
lines2 = stdout2.toString().split('\n');
if (lines2 && lines2.length) {
result.socket = util.getValue(lines2, 'Upgrade').replace('Socket', '').trim();
}
resolve(result);
});
});
}

View File

@ -244,7 +244,8 @@ function parseBlk(lines) {
'model': disk.model,
'serial': disk.serial,
'removable': disk.rm === '1',
'protocol': disk.tran
'protocol': disk.tran,
'group': disk.group,
});
});
@ -269,6 +270,7 @@ function blkStdoutToObject(stdout) {
.replace(/LABEL=/g, ',"label":')
.replace(/MODEL=/g, ',"model":')
.replace(/OWNER=/g, ',"owner":')
.replace(/GROUP=/g, ',"group":')
.replace(/\n/g, '}\n');
}
@ -715,45 +717,54 @@ function diskLayout(callback) {
if (!error) {
try {
const out = stdout.toString().trim();
const outJSON = JSON.parse(out);
if (outJSON && outJSON.hasOwnProperty('blockdevices')) {
let devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; });
devices.forEach((device) => {
let mediumType = '';
const BSDName = '/dev/' + device.name;
const logical = device.name;
try {
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0];
} catch (e) {
util.noop();
}
let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
if (interfaceType === 'NVME') {
mediumType = '2';
interfaceType = 'PCIe';
}
result.push({
device: BSDName,
type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (mediumType === '2' ? 'NVMe' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : (device.model && device.model.indexOf('NVM') > -1 ? 'NVMe' : 'HD'))))),
name: device.model || '',
vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''),
size: device.size || 0,
bytesPerSector: -1,
totalCylinders: -1,
totalHeads: -1,
totalSectors: -1,
totalTracks: -1,
tracksPerCylinder: -1,
sectorsPerTrack: -1,
firmwareRevision: device.rev ? device.rev.trim() : '',
serialNum: device.serial ? device.serial.trim() : '',
interfaceType: interfaceType,
smartStatus: 'unknown',
BSDName: BSDName
});
cmd = cmd + 'printf "\n' + BSDName + '|"; smartctl -H ' + BSDName + ' | grep overall;';
});
let devices = [];
try {
const outJSON = JSON.parse(out);
if (outJSON && outJSON.hasOwnProperty('blockdevices')) {
devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; });
}
} catch (e) {
// fallback to older version of lsblk
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP; unset LC_ALL').toString();
let lines = blkStdoutToObject(out2).split('\n');
const data = parseBlk(lines);
devices = data.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null && item.model !== ''; });
}
devices.forEach((device) => {
let mediumType = '';
const BSDName = '/dev/' + device.name;
const logical = device.name;
try {
mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational').toString().split('\n')[0];
} catch (e) {
util.noop();
}
let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
if (interfaceType === 'NVME') {
mediumType = '2';
interfaceType = 'PCIe';
}
result.push({
device: BSDName,
type: (mediumType === '0' ? 'SSD' : (mediumType === '1' ? 'HD' : (mediumType === '2' ? 'NVMe' : (device.model && device.model.indexOf('SSD') > -1 ? 'SSD' : (device.model && device.model.indexOf('NVM') > -1 ? 'NVMe' : 'HD'))))),
name: device.model || '',
vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''),
size: device.size || 0,
bytesPerSector: -1,
totalCylinders: -1,
totalHeads: -1,
totalSectors: -1,
totalTracks: -1,
tracksPerCylinder: -1,
sectorsPerTrack: -1,
firmwareRevision: device.rev ? device.rev.trim() : '',
serialNum: device.serial ? device.serial.trim() : '',
interfaceType: interfaceType,
smartStatus: 'unknown',
BSDName: BSDName
});
cmd = cmd + 'printf "\n' + BSDName + '|"; smartctl -H ' + BSDName + ' | grep overall;';
});
} catch (e) {
util.noop();
}
@ -811,7 +822,6 @@ function diskLayout(callback) {
if (callback) { callback(result); }
resolve(result);
}
if (_darwin) {
exec('system_profiler SPSerialATADataType SPNVMeDataType', function (error, stdout) {
if (!error) {

View File

@ -561,6 +561,7 @@ function graphics(callback) {
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
workload.push(util.powerShell('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}'));
Promise.all(
workload
@ -587,19 +588,34 @@ function graphics(callback) {
let tsections = data[4].split(/\n\s*\n/);
tsections.shift();
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections);
// monitor ID (powershell) - model / vendor
const res = data[5].split(/\r\n/);
let isections = [];
res.forEach(element => {
const parts = element.split('|');
if (parts.length === 5) {
isections.push({
vendor: parts[0],
code: parts[1],
model: parts[2],
serial: parts[3],
instanceId: parts[4]
});
}
});
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
if (result.controllers.length === 1 && result.displays.length === 1) {
if (result.displays.length === 1) {
if (_resolutionx) {
result.displays[0].currentResX = _resolutionx;
if (!result.displays[0].resolutionx) {
result.displays[0].resolutionx = _resolutionx;
result.displays[0].resolutionx = _resolutionx;
if (!result.displays[0].currentResX) {
result.displays[0].currentResX = _resolutionx;
}
}
if (_resolutiony) {
result.displays[0].currentResY = _resolutiony;
if (result.displays[0].resolutiony === 0) {
result.displays[0].resolutiony = _resolutiony;
result.displays[0].resolutiony = _resolutiony;
if (result.displays[0].currentResY === 0) {
result.displays[0].currentResY = _resolutiony;
}
}
if (_pixeldepth) {
@ -643,10 +659,10 @@ function graphics(callback) {
vram: parseInt(util.getValue(lines, 'AdapterRAM', '='), 10) / 1024 / 1024,
vramDynamic: (util.getValue(lines, 'VideoMemoryType', '=') === '2')
});
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '='));
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '='));
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '='));
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '='));
_resolutionx = util.toInt(util.getValue(lines, 'CurrentHorizontalResolution', '=')) || _resolutionx;
_resolutiony = util.toInt(util.getValue(lines, 'CurrentVerticalResolution', '=')) || _resolutiony;
_refreshrate = util.toInt(util.getValue(lines, 'CurrentRefreshRate', '=')) || _refreshrate;
_pixeldepth = util.toInt(util.getValue(lines, 'CurrentBitsPerPixel', '=')) || _pixeldepth;
}
}
}
@ -677,18 +693,21 @@ function graphics(callback) {
// return displays;
// }
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) {
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) {
let displays = [];
let vendor = '';
let model = '';
let deviceID = '';
let resolutionx = 0;
let resolutiony = 0;
if (dsections && dsections.length) {
let linesDisplay = dsections[0].split(os.EOL);
vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '=');
model = util.getValue(linesDisplay, 'Name', '=');
deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&amp;/g, '&').toLowerCase();
resolutionx = util.toInt(util.getValue(linesDisplay, 'ScreenWidth', '='));
resolutiony = util.toInt(util.getValue(linesDisplay, 'ScreenHeight', '='));
}
for (let i = 0; i < ssections.length; i++) {
if (ssections[i].trim() !== '') {
ssections[i] = 'BitsPerPixel ' + ssections[i];
@ -704,9 +723,17 @@ function graphics(callback) {
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
let displayVendor = '';
let displayModel = '';
isections.forEach(element => {
if (element.instanceId.toLowerCase().startsWith(instanceName) && vendor.startsWith('(') && model.startsWith('PnP')) {
displayVendor = element.vendor;
displayModel = element.model;
}
});
displays.push({
vendor: instanceName.startsWith(deviceID) ? vendor : '',
model: instanceName.startsWith(deviceID) ? model : '',
vendor: instanceName.startsWith(deviceID) && displayVendor === '' ? vendor : displayVendor,
model: instanceName.startsWith(deviceID) && displayModel === '' ? model : displayModel,
main: primary.toLowerCase() === 'true',
builtin: videoOutputTechnology === '2147483648',
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
@ -722,6 +749,22 @@ function graphics(callback) {
});
}
}
if (ssections.length === 0) {
displays.push({
vendor,
model,
main: true,
resolutionx,
resolutiony,
sizex: -1,
sizey: -1,
pixeldepth: -1,
currentResX: resolutionx,
currentResY: resolutiony,
positionX: 0,
positionY: 0
});
}
return displays;
}

5
lib/index.d.ts vendored
View File

@ -63,6 +63,7 @@ export namespace Systeminformation {
speed: string;
speedmin: string;
speedmax: string;
governor: string;
cores: number;
physicalCores: number;
processors: number;
@ -101,6 +102,9 @@ export namespace Systeminformation {
active: number;
available: number;
buffcache: number;
buffers: number;
cached: number;
slab: number;
swaptotal: number;
swapused: number;
swapfree: number;
@ -639,6 +643,7 @@ export function disksIO(cb?: (data: Systeminformation.DisksIoData) => any): Prom
export function diskLayout(cb?: (data: Systeminformation.DiskLayoutData[]) => any): Promise<Systeminformation.DiskLayoutData[]>;
export function networkInterfaceDefault(cb?: (data: string) => any): Promise<string>;
export function networkGatewayDefault(cb?: (data: string) => any): Promise<string>;
export function networkInterfaces(cb?: (data: Systeminformation.NetworkInterfacesData[]) => any): Promise<Systeminformation.NetworkInterfacesData[]>;
export function networkStats(ifaces?: string, cb?: (data: Systeminformation.NetworkStatsData[]) => any): Promise<Systeminformation.NetworkStatsData[]>;

View File

@ -347,6 +347,7 @@ exports.disksIO = filesystem.disksIO;
exports.diskLayout = filesystem.diskLayout;
exports.networkInterfaceDefault = network.networkInterfaceDefault;
exports.networkGatewayDefault = network.networkGatewayDefault;
exports.networkInterfaces = network.networkInterfaces;
exports.networkStats = network.networkStats;
exports.networkConnections = network.networkConnections;

View File

@ -93,17 +93,30 @@ const OSX_RAM_manufacturers = {
// /procs/meminfo - sample (all in kB)
//
// MemTotal: 32806380 kB
// MemFree: 19220948 kB
// MemAvailable: 20851100 kB
// Buffers: 532892 kB
// Cached: 1935000 kB
// SwapCached: 0 kB
// Active: 11953672 kB
// Inactive: 1069288 kB
// SwapTotal: 16768892 kB
// SwapFree: 16768892 kB
// MemTotal: 32806380 kB
// MemFree: 17977744 kB
// MemAvailable: 19768972 kB
// Buffers: 517028 kB
// Cached: 2161876 kB
// SwapCached: 456 kB
// Active: 12081176 kB
// Inactive: 2164616 kB
// Active(anon): 10832884 kB
// Inactive(anon): 1477272 kB
// Active(file): 1248292 kB
// Inactive(file): 687344 kB
// Unevictable: 0 kB
// Mlocked: 0 kB
// SwapTotal: 16768892 kB
// SwapFree: 16768304 kB
// Dirty: 268 kB
// Writeback: 0 kB
// AnonPages: 11568832 kB
// Mapped: 719992 kB
// Shmem: 743272 kB
// Slab: 335716 kB
// SReclaimable: 256364 kB
// SUnreclaim: 79352 kB
function mem(callback) {
@ -117,6 +130,9 @@ function mem(callback) {
active: os.totalmem() - os.freemem(), // temporarily (fallback)
available: os.freemem(), // temporarily (fallback)
buffers: 0,
cached: 0,
slab: 0,
buffcache: 0,
swaptotal: 0,
@ -134,20 +150,17 @@ function mem(callback) {
result.free = result.free ? result.free * 1024 : os.freemem();
result.used = result.total - result.free;
let buffers = parseInt(util.getValue(lines, 'buffers'), 10);
buffers = buffers ? buffers * 1024 : 0;
let cached = parseInt(util.getValue(lines, 'cached'), 10);
cached = cached ? cached * 1024 : 0;
result.buffcache = buffers + cached;
result.buffers = parseInt(util.getValue(lines, 'buffers'), 10);
result.buffers = result.buffers ? result.buffers * 1024 : 0;
result.cached = parseInt(util.getValue(lines, 'cached'), 10);
result.cached = result.cached ? result.cached * 1024 : 0;
result.slab = parseInt(util.getValue(lines, 'slab'), 10);
result.slab = result.slab ? result.slab * 1024 : 0;
result.buffcache = result.buffers + result.cached + result.slab;
result.available = parseInt(util.getValue(lines, 'memavailable'), 10);
result.available = result.available ? result.available * 1024 : os.freemem();
// result.active = result.total - result.free - result.buffcache;
result.active = parseInt(util.getValue(lines, 'active'), 10);
result.active = result.active ? result.active * 1024 : 0;
result.buffcache = result.total - result.free - result.active;
let available = parseInt(util.getValue(lines, 'memavailable'), 10);
result.available = available ? available * 1024 : result.free + result.buffcache;
result.active = result.total - result.available;
result.swaptotal = parseInt(util.getValue(lines, 'swaptotal'), 10);
result.swaptotal = result.swaptotal ? result.swaptotal * 1024 : 0;

View File

@ -1070,7 +1070,7 @@ function networkConnections(callback) {
let lines = stdout.toString().split('\n');
lines.forEach(function (line) {
line = line.replace(/ +/g, ' ').split(' ');
if (line.length >= 6) {
if (line.length >= 7) {
let localip = line[3];
let localport = '';
let localaddress = line[3].split(':');
@ -1287,3 +1287,73 @@ function networkConnections(callback) {
}
exports.networkConnections = networkConnections;
function networkGatewayDefault(callback) {
return new Promise((resolve) => {
process.nextTick(() => {
let result = '';
if (_linux || _freebsd || _openbsd || _netbsd) {
let cmd = 'ip route get 1';
try {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
const line = lines && lines[0] ? lines[0] : '';
let parts = line.split(' via ');
if (parts && parts[1]) {
parts = parts[1].split(' ');
result = parts[0];
}
if (callback) {
callback(result);
}
resolve(result);
}
});
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
}
if (_darwin) {
let cmd = 'route -n get default';
try {
exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n').map(line => line.trim());
result = util.getValue(lines, 'gateway');
if (callback) {
callback(result);
}
resolve(result);
}
});
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
}
if (_windows) {
try {
util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }).InterfaceIndex')
.then(data => {
let lines = data.toString().split('\r\n');
result = lines && lines[0] ? lines[0] : '';
if (callback) {
callback(result);
}
resolve(result);
});
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
}
});
});
}
exports.networkGatewayDefault = networkGatewayDefault;

View File

@ -178,7 +178,7 @@ function parseDateTime(dt) {
// Dateformat: mm/dd/yyyy
result.date = dtparts[2] + '-' + ('0' + dtparts[0]).substr(-2) + '-' + ('0' + dtparts[1]).substr(-2);
} else {
// Dateformat: dd/mm/yyyy
// Dateformat: dd/mm/yyyy
result.date = dtparts[2] + '-' + ('0' + dtparts[1]).substr(-2) + '-' + ('0' + dtparts[0]).substr(-2);
}
}
@ -321,6 +321,11 @@ function powerShell(cmd) {
stdio: 'pipe'
});
if (child && !child.pid) {
child.on('error', function () {
resolve(result);
});
}
if (child && child.pid) {
child.stdout.on('data', function (data) {
result = result + data.toString('utf8');
@ -454,6 +459,7 @@ function countUniqueLines(lines, startingWith) {
});
return uniqueLines.length;
}
function noop() { }
exports.toInt = toInt;

View File

@ -1,6 +1,6 @@
{
"name": "systeminformation",
"version": "4.14.11",
"version": "4.15.3",
"description": "Simple system and OS information library",
"license": "MIT",
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",