This commit is contained in:
Sebastian Hildebrandt 2020-05-19 14:57:13 +02:00
commit 147550532a
11 changed files with 169 additions and 40 deletions

View File

@ -30,6 +30,8 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.26.1 | 2020-05-13 | code cleanup |
| 4.26.0 | 2020-05-12 | `diskLayout()` added full smart data where supported |
| 4.25.2 | 2020-05-12 | `getDynamicData()` added wifiNetworks() | | 4.25.2 | 2020-05-12 | `getDynamicData()` added wifiNetworks() |
| 4.25.1 | 2020-05-07 | `get()` minor bounds test fix, updated docs | | 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.25.0 | 2020-05-07 | `get()` added function to get partial system info |

View File

@ -87,13 +87,13 @@ si.cpu()
(last 7 major and minor version releases) (last 7 major and minor version releases)
- Version 4.26.0: `diskLayout()` added full S.M.A.R.T data (linux)
- Version 4.25.0: `get()` added function to get partial system info - 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)
- ... - ...
You can find all changes here: [detailed changelog][changelog-url] You can find all changes here: [detailed changelog][changelog-url]
@ -382,6 +382,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | [0].serialNum | X | | X | X | | serial number | | | [0].serialNum | X | | X | X | | serial number |
| | [0].interfaceType | X | | | X | | SATA, PCIe, ... | | | [0].interfaceType | X | | | X | | SATA, PCIe, ... |
| | [0].smartStatus | X | | X | X | | S.M.A.R.T Status (see Known Issues) | | | [0].smartStatus | X | | X | X | | S.M.A.R.T Status (see Known Issues) |
| | [0].smartData | X | | | | | full S.M.A.R.T data from smartctl<br>requires at least smartmontools 7.0 |
| si.blockDevices(cb) | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids and roms | | si.blockDevices(cb) | [{...}] | X | | X | X | | returns array of disks, partitions,<br>raids and roms |
| | [0].name | X | | X | X | | name | | | [0].name | X | | X | X | | name |
| | [0].type | X | | X | X | | type | | | [0].type | X | | X | X | | type |
@ -801,6 +802,7 @@ Written by Sebastian Hildebrandt [sebhildebrandt](https://github.com/sebhildebra
- Nathan Patten [nrpatten](https://github.com/nrpatten) - Nathan Patten [nrpatten](https://github.com/nrpatten)
- Juan Campuzano [juancampuzano](https://github.com/juancampuzano) - Juan Campuzano [juancampuzano](https://github.com/juancampuzano)
- Ricardo Polo [ricardopolo](https://github.com/ricardopolo) - Ricardo Polo [ricardopolo](https://github.com/ricardopolo)
- Miłosz Dźwigała [mily20001]https://github.com/mily20001
OSX Temperature: credits here are going to: OSX Temperature: credits here are going to:

View File

@ -60,6 +60,7 @@
<li>Nathan Patten <a href="https://github.com/nrpatten" rel="nofollow">nrpatten</a></li> <li>Nathan Patten <a href="https://github.com/nrpatten" rel="nofollow">nrpatten</a></li>
<li>Juan Campuzano <a href="https://github.com/juancampuzano" rel="nofollow">juancampuzano</a></li> <li>Juan Campuzano <a href="https://github.com/juancampuzano" rel="nofollow">juancampuzano</a></li>
<li>Ricardo Polo <a href="https://github.com/ricardopolo" rel="nofollow">ricardopolo</a></li> <li>Ricardo Polo <a href="https://github.com/ricardopolo" rel="nofollow">ricardopolo</a></li>
<li>Miłosz Dźwigała <a href="https://github.com/mily20001" rel="nofollow">mily20001</a></li>
</ul> </ul>
<p>OSX Temperature: credits here are going to:</p> <p>OSX Temperature: credits here are going to:</p>
<ul> <ul>

View File

@ -235,6 +235,16 @@
<td></td> <td></td>
<td>S.M.A.R.T Status (see Known Issues)</td> <td>S.M.A.R.T Status (see Known Issues)</td>
</tr> </tr>
<tr>
<td></td>
<td>[0].smartData</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>full S.M.A.R.T data from smartctl<br>requires at least smartmontools 7.0<br>(see Known Issues)</td>
</tr>
<tr class="example"> <tr class="example">
<td></td> <td></td>
<td colspan="7"> <td colspan="7">
@ -259,7 +269,15 @@ si.diskLayout().then(data => console.log(data));</code></pre class="example">
firmwareRevision: '', firmwareRevision: '',
serialNum: '...serial....', serialNum: '...serial....',
interfaceType: 'PCIe', interfaceType: 'PCIe',
smartStatus: 'unknown' smartStatus: 'unknown',
smartData: {
json_format_version: [Array],
smartctl: [Object],
device: [Object],
model_name: 'SAMSUNG xxxxxxxxxxxx-xxxx',
serial_number: '...serial....',
...
}
}, },
{ {
... ...

View File

@ -129,7 +129,7 @@
</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> <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>Normally you would call each of the functions (where you want to get 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 result 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> <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"> <table class="table table-sm table-bordered table-striped">
<thead> <thead>

View File

@ -83,6 +83,16 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.26.1</th>
<td>2020-05-13</td>
<td>code cleanup </td>
</tr>
<tr>
<th scope="row">4.26.0</th>
<td>2020-05-12</td>
<td><span class="code">diskLayout()</span> added full smart data (where supported) </td>
</tr>
<tr> <tr>
<th scope="row">4.25.2</th> <th scope="row">4.25.2</th>
<td>2020-05-12</td> <td>2020-05-12</td>

View File

@ -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.25.2</span></div> <div class="version">Current Version: <span id="version">4.26.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">

View File

@ -68,6 +68,7 @@
<p>To be able to detect S.M.A.R.T. status on Linux you need to install <span class="code">smartmontools</span>. On DEBIAN based linux distributions you can install it by running:</p> <p>To be able to detect S.M.A.R.T. status on Linux you need to install <span class="code">smartmontools</span>. On DEBIAN based linux distributions you can install it by running:</p>
<pre>$ sudo apt-get install smartmontools</pre> <pre>$ sudo apt-get install smartmontools</pre>
<p>If you have smartmontools version >= 7.0 then you will get also full smart data in diskLayout()</p>
<h4>Stats Functions</h4> <h4>Stats Functions</h4>
<p>To get correct values with <span class="code">fsStats()</span>, <span class="code">disksIO()</span> and <span class="code">networkStats()</span> please check <a href="statsfunctions.html">this guide</a></p> <p>To get correct values with <span class="code">fsStats()</span>, <span class="code">disksIO()</span> and <span class="code">networkStats()</span> please check <a href="statsfunctions.html">this guide</a></p>

View File

@ -739,6 +739,17 @@ function diskLayout(callback) {
let cmd = ''; let cmd = '';
if (_linux) { if (_linux) {
let cmdFullSmart = '';
const commitResult = res => {
for (let i = 0; i < res.length; i++) {
delete res[i].BSDName;
}
if (callback) {
callback(res);
}
resolve(res);
};
exec('export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL', function (error, stdout) { exec('export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL', function (error, stdout) {
if (!error) { if (!error) {
try { try {
@ -789,13 +800,30 @@ function diskLayout(callback) {
smartStatus: 'unknown', smartStatus: 'unknown',
BSDName: BSDName BSDName: BSDName
}); });
cmd = cmd + 'printf "\n' + BSDName + '|"; smartctl -H ' + BSDName + ' | grep overall;'; cmd += `printf "\n${BSDName}|"; smartctl -H ${BSDName} | grep overall;`;
cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
}); });
} catch (e) { } catch (e) {
util.noop(); util.noop();
} }
} }
// check S.M.A.R.T. status // check S.M.A.R.T. status
if (cmdFullSmart) {
exec(cmdFullSmart, function (error, stdout) {
try {
const data = JSON.parse(`[${stdout}]`);
data.forEach(disk => {
const diskBSDName = disk.smartctl.argv[disk.smartctl.argv.length - 1];
for (let i = 0; i < result.length; i++) {
if (result[i].BSDName === diskBSDName) {
result[i].smartStatus = (disk.smart_status.passed ? 'Ok' : (disk.smart_status.passed === false ? 'Predicted Failure' : 'unknown'));
result[i].smartData = disk;
}
}
});
commitResult(result);
} catch (e) {
if (cmd) { if (cmd) {
cmd = cmd + 'printf "\n"'; cmd = cmd + 'printf "\n"';
exec(cmd, function (error, stdout) { exec(cmd, function (error, stdout) {
@ -819,22 +847,13 @@ function diskLayout(callback) {
} }
} }
}); });
for (let i = 0; i < result.length; i++) { commitResult(result);
delete result[i].BSDName;
}
if (callback) {
callback(result);
}
resolve(result);
}); });
} else { } else {
for (let i = 0; i < result.length; i++) { commitResult(result);
delete result[i].BSDName;
} }
if (callback) {
callback(result);
} }
resolve(result); });
} }
}); });
} }

76
lib/index.d.ts vendored
View File

@ -123,6 +123,81 @@ export namespace Systeminformation {
voltageMax: number; voltageMax: number;
} }
interface SmartData {
smartctl: {
version: number[];
platform_info: string;
build_info: string;
argv: string[];
exit_status: number;
};
json_format_version: number[];
device: {
name: string;
info_name: string;
type: string;
protocol: string;
}
smart_status: {
passed: boolean;
}
ata_smart_attributes: {
revision: number;
table: {
id: number;
name: string;
value: number;
worst: number;
thresh: number;
when_failed: string;
flags: {
value: number;
string: string;
prefailure: boolean;
updated_online: boolean;
performance: boolean;
error_rate: boolean;
event_count: boolean;
auto_keep: boolean;
};
raw: { value: number; string: string }
}[];
};
power_on_time: {
hours: number;
};
power_cycle_count: number;
temperature: {
current: number;
};
ata_smart_error_log: {
summary: {
revision: number;
count: number;
};
};
ata_smart_self_test_log: {
standard: {
revision: number;
table: {
type: {
value: number;
string: string;
},
status: {
value: number;
string: string;
passed: boolean;
},
lifetime_hours: number;
}[];
count: number;
error_count_total: number;
error_count_outdated: number;
};
}
}
interface DiskLayoutData { interface DiskLayoutData {
device: string; device: string;
type: string; type: string;
@ -140,6 +215,7 @@ export namespace Systeminformation {
serialNum: string; serialNum: string;
interfaceType: string; interfaceType: string;
smartStatus: string; smartStatus: string;
smartData?: SmartData;
} }
interface BatteryData { interface BatteryData {

View File

@ -1,6 +1,6 @@
{ {
"name": "systeminformation", "name": "systeminformation",
"version": "4.25.2", "version": "4.26.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)",