Merge branch 'master' of https://github.com/sebhildebrandt/systeminformation
This commit is contained in:
commit
3fbd71261a
1
.gitignore
vendored
1
.gitignore
vendored
@ -65,5 +65,4 @@ yarn.lock
|
|||||||
test/
|
test/
|
||||||
dist/
|
dist/
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
tslint.json
|
|
||||||
typings.d.ts
|
typings.d.ts
|
||||||
|
|||||||
@ -30,6 +30,9 @@ For major (breaking) changes - version 3 and 2 see end of page.
|
|||||||
|
|
||||||
| Version | Date | Comment |
|
| Version | Date | Comment |
|
||||||
| -------------- | -------------- | -------- |
|
| -------------- | -------------- | -------- |
|
||||||
|
| 4.25.1 | 2020-05-07 | `get()` minor bounds test fix, updated docs |
|
||||||
|
| 4.25.0 | 2020-05-07 | `get()` added function to get partial system info |
|
||||||
|
| 4.24.2 | 2020-05-06 | `cpu()` fix (BSD), `networkStats()` fix BSD |
|
||||||
| 4.24.1 | 2020-05-03 | `processes()` fix parsing command and params |
|
| 4.24.1 | 2020-05-03 | `processes()` fix parsing command and params |
|
||||||
| 4.24.0 | 2020-05-01 | `networkInterfaces()` added subnet mask ip4 and ip6 |
|
| 4.24.0 | 2020-05-01 | `networkInterfaces()` added subnet mask ip4 and ip6 |
|
||||||
| 4.23.10 | 2020-05-01 | `cpuTemperature()` optimized parsing linux |
|
| 4.23.10 | 2020-05-01 | `cpuTemperature()` optimized parsing linux |
|
||||||
|
|||||||
@ -87,13 +87,13 @@ si.cpu()
|
|||||||
|
|
||||||
(last 7 major and minor version releases)
|
(last 7 major and minor version releases)
|
||||||
|
|
||||||
|
- Version 4.25.0: `get()` added function to get partial system info
|
||||||
- Version 4.24.0: `networkInterfaces()` added subnet mask ip4 and ip6
|
- Version 4.24.0: `networkInterfaces()` added subnet mask ip4 and ip6
|
||||||
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
|
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
|
||||||
- Version 4.22.0: `services()` added pids (windows)
|
- Version 4.22.0: `services()` added pids (windows)
|
||||||
- Version 4.21.0: added npx copmpatibility
|
- Version 4.21.0: added npx copmpatibility
|
||||||
- Version 4.20.0: `battery()` added designcapacity, voltage, unit
|
- Version 4.20.0: `battery()` added designcapacity, voltage, unit
|
||||||
- Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup)
|
- Version 4.19.0: `osInfo()` added uefi (OS uses UEFI during startup)
|
||||||
- Version 4.18.0: `networkInterfaces()` added dhcp for mac os, added dhcp linux fallback
|
|
||||||
- ...
|
- ...
|
||||||
|
|
||||||
You can find all changes here: [detailed changelog][changelog-url]
|
You can find all changes here: [detailed changelog][changelog-url]
|
||||||
@ -639,6 +639,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
|
|||||||
| si.getStaticData(cb) | {...} | X | X | X | X | X | all static data at once |
|
| si.getStaticData(cb) | {...} | X | X | X | X | X | all static data at once |
|
||||||
| si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | X | all dynamic data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
|
| si.getDynamicData(srv,iface,cb) | {...} | X | X | X | X | X | all dynamic data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
|
||||||
| si.getAllData(srv,iface,cb) | {...} | X | X | X | X | X | all data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
|
| si.getAllData(srv,iface,cb) | {...} | X | X | X | X | X | all data at once<br>Specify services and interfaces to monitor<br>Defaults to first external network interface<br>Pass "*" for ALL services (linux/win only)<br>Pass "*" for ALL network interfaces |
|
||||||
|
| si.get(valueObject,cb) | {...} | X | X | X | X | X | get partial system info data at once<br>In valueObject you can define<br>all values, you want to get back <br>(see documentation for details) |
|
||||||
|
|
||||||
### cb: Asynchronous Function Calls (callback)
|
### cb: Asynchronous Function Calls (callback)
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
<div class="col-12 sectionheader">
|
<div class="col-12 sectionheader">
|
||||||
<div class="title">General</div>
|
<div class="title">General</div>
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<p>In this section you will learn how to get general systeminformation data. We will also cover the "get-all" functions to get all data at once.</p>
|
<p>In this section you will learn how to get general systeminformation data. We will also cover the "get" and "get-all" functions to get partial or all data with one single call.</p>
|
||||||
<p>For function reference and examples we assume, that we imported <span class="code">systeminformation</span> as follows:</p>
|
<p>For function reference and examples we assume, that we imported <span class="code">systeminformation</span> as follows:</p>
|
||||||
<pre><code class="js">const si = require('systeminformation');</code></pre>
|
<pre><code class="js">const si = require('systeminformation');</code></pre>
|
||||||
<h2>Lib-Version and Time/Timezone</h2>
|
<h2>Lib-Version and Time/Timezone</h2>
|
||||||
@ -128,6 +128,81 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p>Keep in mind, that there is another function <span class="code">si.versions()</span> that will return versions of other system libraries and software packages</p>
|
<p>Keep in mind, that there is another function <span class="code">si.versions()</span> that will return versions of other system libraries and software packages</p>
|
||||||
|
<h2>Get Defined Result Object</h2>
|
||||||
|
<p>Normally you would call each of the functions (where you want to have detailed system information) seperately. The docs pages contain a full reference (with examples) for each available function. But there is also another really handy way to get a self-defined information object in one single call:</p>
|
||||||
|
<p>The <span class="code">si.get()</span> function is an alternative, where you can obtain several system information data in one call. You can define a json object which represents the data structure you are expecting and the <span class="code">si.get()</span> call will then return all of the requested data in a single result object</p>
|
||||||
|
<table class="table table-sm table-bordered table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Function</th>
|
||||||
|
<th>Result object</th>
|
||||||
|
<th>Linux</th>
|
||||||
|
<th>BSD</th>
|
||||||
|
<th>Mac</th>
|
||||||
|
<th>Win</th>
|
||||||
|
<th>Sun</th>
|
||||||
|
<th>Comments</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr>
|
||||||
|
<td>si.get(valueObject,cb)</td>
|
||||||
|
<td>{...}</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>X</td>
|
||||||
|
<td>get partial data at once<br>Specify return object for all<br>values that should be returned:</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="example">
|
||||||
|
<td></td>
|
||||||
|
<td colspan="7">
|
||||||
|
<h5>Example</h5>
|
||||||
|
<pre><code class="js">const si = require('systeminformation');
|
||||||
|
|
||||||
|
// define all values, you want to get back
|
||||||
|
valueObject = {
|
||||||
|
cpu: '*',
|
||||||
|
osInfo: 'platform, release',
|
||||||
|
system: 'model, manufacturer'
|
||||||
|
}
|
||||||
|
|
||||||
|
si.get(valueObject).then(data => console.log(data));</code></pre class="example">
|
||||||
|
<pre class="example">
|
||||||
|
{
|
||||||
|
cpu: {
|
||||||
|
manufacturer: 'Intel®',
|
||||||
|
brand: 'Core™ i7-8569U',
|
||||||
|
vendor: 'GenuineIntel',
|
||||||
|
family: '6',
|
||||||
|
model: '142',
|
||||||
|
stepping: '10',
|
||||||
|
revision: '',
|
||||||
|
voltage: '',
|
||||||
|
speed: '2.80',
|
||||||
|
speedmin: '2.80',
|
||||||
|
speedmax: '2.80',
|
||||||
|
governor: '',
|
||||||
|
cores: 8,
|
||||||
|
physicalCores: 4,
|
||||||
|
processors: 1,
|
||||||
|
socket: '',
|
||||||
|
cache: { l1d: 32768, l1i: 32768, l2: 262144, l3: 8388608 }
|
||||||
|
},
|
||||||
|
osInfo: {
|
||||||
|
platform: 'darwin',
|
||||||
|
release: '10.15.4'
|
||||||
|
},
|
||||||
|
system: {
|
||||||
|
model: 'MacBookPro15,2',
|
||||||
|
manufacturer: 'Apple Inc.'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p>The key names of the <span class="code">valueObject</span> must be exactly the same as the representing function within systeminformation.</p>
|
||||||
<h2>Get All At Once</h2>
|
<h2>Get All At Once</h2>
|
||||||
<p>The following three functions <span class="code">si.getStaticData()</span>, <span class="code">si.getDynamicData()</span> and <span class="code">si.getAllData()</span> will return most of the available data in a single result object:</p>
|
<p>The following three functions <span class="code">si.getStaticData()</span>, <span class="code">si.getDynamicData()</span> and <span class="code">si.getAllData()</span> will return most of the available data in a single result object:</p>
|
||||||
<table class="table table-sm table-bordered table-striped">
|
<table class="table table-sm table-bordered table-striped">
|
||||||
|
|||||||
@ -83,6 +83,21 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">4.25.1</th>
|
||||||
|
<td>2020-05-07</td>
|
||||||
|
<td><span class="code">get()</span> minor bounds test fix, updated docs /td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">4.25.0</th>
|
||||||
|
<td>2020-05-07</td>
|
||||||
|
<td><span class="code">get()</span> added function to get partial system info /td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">4.24.2</th>
|
||||||
|
<td>2020-05-06</td>
|
||||||
|
<td><span class="code">cpu()</span> fix BSD, <span class="code">networkStats()</span> fix BSD </td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">4.24.1</th>
|
<th scope="row">4.24.1</th>
|
||||||
<td>2020-05-03</td>
|
<td>2020-05-03</td>
|
||||||
|
|||||||
@ -168,7 +168,7 @@
|
|||||||
<img class="logo" src="assets/logo.png">
|
<img class="logo" src="assets/logo.png">
|
||||||
<div class="title">systeminformation</div>
|
<div class="title">systeminformation</div>
|
||||||
<div class="subtitle"><span id="typed"></span></div>
|
<div class="subtitle"><span id="typed"></span></div>
|
||||||
<div class="version">Current Version: <span id="version">4.24.1</span></div>
|
<div class="version">Current Version: <span id="version">4.25.1</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>
|
<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>
|
||||||
<div class="down">
|
<div class="down">
|
||||||
|
|||||||
@ -506,12 +506,12 @@ function getCpu() {
|
|||||||
let modelline = '';
|
let modelline = '';
|
||||||
let lines = [];
|
let lines = [];
|
||||||
if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model;
|
if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model;
|
||||||
exec('export LC_ALL=C; dmidecode -t 4 2>/dev/null; dmidecode -t 7 2>/dev/null; unset LC_ALL', function (error, stdout) {
|
exec('export LC_ALL=C; dmidecode -t 4; dmidecode -t 7 unset LC_ALL', function (error, stdout) {
|
||||||
let cache = [];
|
let cache = [];
|
||||||
if (!error) {
|
if (!error) {
|
||||||
const data = stdout.toString().split('# dmidecode');
|
const data = stdout.toString().split('# dmidecode');
|
||||||
const processor = data.length > 0 ? data[1] : '';
|
const processor = data.length > 1 ? data[1] : '';
|
||||||
cache = data.length > 1 ? data[2].split('Cache Information') : [];
|
cache = data.length > 2 ? data[2].split('Cache Information') : [];
|
||||||
|
|
||||||
lines = processor.split('\n');
|
lines = processor.split('\n');
|
||||||
}
|
}
|
||||||
|
|||||||
1
lib/index.d.ts
vendored
1
lib/index.d.ts
vendored
@ -681,3 +681,4 @@ export function vboxInfo(cb?: (data: Systeminformation.VboxInfoData[]) => any):
|
|||||||
export function getStaticData(cb?: (data: Systeminformation.StaticData) => any): Promise<Systeminformation.StaticData>;
|
export function getStaticData(cb?: (data: Systeminformation.StaticData) => any): Promise<Systeminformation.StaticData>;
|
||||||
export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
|
export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
|
||||||
export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
|
export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<any>;
|
||||||
|
export function get(valuesObject: any, cb?: (data: any) => any): Promise<any>;
|
||||||
|
|||||||
36
lib/index.js
36
lib/index.js
@ -315,6 +315,40 @@ function getAllData(srv, iface, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get(valueObject, callback) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
process.nextTick(() => {
|
||||||
|
const allPromises = Object.keys(valueObject)
|
||||||
|
.filter(func => ({}.hasOwnProperty.call(exports, func)))
|
||||||
|
.map(func => exports[func]());
|
||||||
|
|
||||||
|
Promise.all(allPromises).then(data => {
|
||||||
|
const result = {};
|
||||||
|
let i = 0;
|
||||||
|
for (let key in valueObject) {
|
||||||
|
if ({}.hasOwnProperty.call(valueObject, key) && {}.hasOwnProperty.call(exports, key) && data.length > i) {
|
||||||
|
if (valueObject[key] === '*' || valueObject[key] === 'all') {
|
||||||
|
result[key] = data[i];
|
||||||
|
} else {
|
||||||
|
const keys = valueObject[key].replace(/,/g, ' ').replace(/ +/g, ' ').split(' ');
|
||||||
|
const partialRes = {};
|
||||||
|
keys.forEach(k => {
|
||||||
|
if ({}.hasOwnProperty.call(data[i], k)) {
|
||||||
|
partialRes[k] = data[i][k];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result[key] = partialRes;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (callback) { callback(result); }
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
// export all libs
|
// export all libs
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
@ -381,3 +415,5 @@ exports.vboxInfo = vbox.vboxInfo;
|
|||||||
exports.getStaticData = getStaticData;
|
exports.getStaticData = getStaticData;
|
||||||
exports.getDynamicData = getDynamicData;
|
exports.getDynamicData = getDynamicData;
|
||||||
exports.getAllData = getAllData;
|
exports.getAllData = getAllData;
|
||||||
|
exports.get = get;
|
||||||
|
|
||||||
|
|||||||
@ -1081,11 +1081,11 @@ function networkStatsSingle(iface) {
|
|||||||
const line = lines[i].replace(/ +/g, ' ').split(' ');
|
const line = lines[i].replace(/ +/g, ' ').split(' ');
|
||||||
if (line && line[0] && line[7] && line[10]) {
|
if (line && line[0] && line[7] && line[10]) {
|
||||||
rx_bytes = rx_bytes + parseInt(line[7]);
|
rx_bytes = rx_bytes + parseInt(line[7]);
|
||||||
if (stats[6].trim() !== '-') { rx_dropped = rx_dropped + parseInt(stats[6]); }
|
if (line[6].trim() !== '-') { rx_dropped = rx_dropped + parseInt(line[6]); }
|
||||||
if (stats[5].trim() !== '-') { rx_errors = rx_errors + parseInt(stats[5]); }
|
if (line[5].trim() !== '-') { rx_errors = rx_errors + parseInt(line[5]); }
|
||||||
tx_bytes = tx_bytes + parseInt(line[10]);
|
tx_bytes = tx_bytes + parseInt(line[10]);
|
||||||
if (stats[12].trim() !== '-') { tx_dropped = tx_dropped + parseInt(stats[12]); }
|
if (line[12].trim() !== '-') { tx_dropped = tx_dropped + parseInt(line[12]); }
|
||||||
if (stats[9].trim() !== '-') { tx_errors = tx_errors + parseInt(stats[9]); }
|
if (line[9].trim() !== '-') { tx_errors = tx_errors + parseInt(line[9]); }
|
||||||
operstate = 'up';
|
operstate = 'up';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "systeminformation",
|
"name": "systeminformation",
|
||||||
"version": "4.24.1",
|
"version": "4.25.1",
|
||||||
"description": "Simple system and OS information library",
|
"description": "Simple system and OS information library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|
"author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",
|
||||||
|
|||||||
51
tslint.json
Normal file
51
tslint.json
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
{
|
||||||
|
"defaultSeverity": "error",
|
||||||
|
"extends": [
|
||||||
|
"tslint:recommended"
|
||||||
|
],
|
||||||
|
"jsRules": {},
|
||||||
|
"rules": {
|
||||||
|
"no-trailing-whitespace": false,
|
||||||
|
"quotemark": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"comment-format": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"member-access": false,
|
||||||
|
"whitespace": [
|
||||||
|
true
|
||||||
|
],
|
||||||
|
"object-literal-shorthand": false,
|
||||||
|
"ordered-imports": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"one-line": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"max-line-length": [
|
||||||
|
true,
|
||||||
|
140
|
||||||
|
],
|
||||||
|
"only-arrow-functions": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"object-literal-sort-keys": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"array-type": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"variable-name": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"interface-name": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"one-variable-per-declaration": [
|
||||||
|
false
|
||||||
|
],
|
||||||
|
"no-console": false
|
||||||
|
},
|
||||||
|
"rulesDirectory": []
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user