osInfo() added uefi (OS uses UEFI during startup)

This commit is contained in:
Sebastian Hildebrandt 2020-01-12 10:33:04 +01:00
parent f85d518f34
commit cf85b2f1b6
7 changed files with 73 additions and 18 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.19.0 | 2020-01-12 | `osInfo()` added uefi |
| 4.18.3 | 2020-01-10 | `fsSize()` fix excluding loop/snap devices |
| 4.18.2 | 2020-01-10 | `memLayout()` fix memsize linux (modules >= 32 GB) |
| 4.18.1 | 2020-01-07 | updated docs |

View File

@ -98,13 +98,13 @@ si.cpu()
(last 7 major and minor version releases)
- 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
- Version 4.17.0: `networkInterfaces()` added dhcp, dnsSuffix, ieee8021xAuth, ieee8021xState
- Version 4.16.0: `networkGatewayDefault()` added
- 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
- ...
You can find all changes here: [detailed changelog][changelog-url]
@ -303,6 +303,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (
| | serial | X | X | X | X | | OS/Host serial number |
| | build | X | | X | X | | OS build version |
| | servicepack | | | | X | | service pack version |
| | uefi | X | X | X | X | | OS started via UEFI |
| si.uuid(cb) | {...} | X | X | X | X | X | object of several UUIDs |
| | os | X | X | X | X | | os specific UUID |
| si.versions(cb) | {...} | X | X | X | X | X | version information (kernel, ssl, node, ...) |

View File

@ -51,9 +51,9 @@
</ul>
<h4>Breaking Changes</h4>
<ul>
<li><span class="code">networkStats()</span>: will provide an **array** of stats for all given interfaces. In previous versions only one interface was provided as a parameter. Pass '*' for all interfaces</li>
<li><span class="code">networkStats()</span>: will provide an <strong>array</strong> of stats for all given interfaces. In previous versions only one interface was provided as a parameter. Pass '*' for all interfaces</li>
<li><span class="code">networkStats()</span>: <span class="code">rx</span> and <span class="code">tx</span> changed to <span class="code">rx_bytes</span> and <span class="code">tx_bytes</span></li>
<li><span class="code">dockerContainerStats()</span> will provide an **array** of stats for all given docker containers. In previous versions only one interface was provided as a parameter. Pass '*' for all docker containers</li>
<li><span class="code">dockerContainerStats()</span> will provide an <strong>array</strong> of stats for all given docker containers. In previous versions only one interface was provided as a parameter. Pass '*' for all docker containers</li>
</ul>
<h4>Other Changes</h4>
<ul>
@ -65,7 +65,7 @@
<li><span class="code">networkStats()</span> added <span class="code">operstate</span>, <span class="code">type</span>, <span class="code">duplex</span>, <span class="code">mtu</span>, <span class="code">speed</span>, <span class="code">carrierChanges</span></li>
<li>added TypeScript definitions </li>
</ul>
<p>Be aware**, that the new version 4.x is **NOT fully backward compatible** to version 3.x ...</p>
<p><strong>Be aware</strong>, that the new version 4.x is <strong>NOT fully backward compatible</strong> to version 3.x ...</p>
<h3>Major (breaking) Changes - Version 3</h3>
<ul>
@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.19.0</th>
<td>2020-01-12</td>
<td><span class="code">osInfo()</span> uefi (OS uses UEFI on startup)</td>
</tr>
<tr>
<th scope="row">4.18.3</th>
<td>2020-01-10</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.18.3</span></div>
<div class="version">Current Version: <span id="version">4.19.0</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">

View File

@ -195,6 +195,16 @@
<td></td>
<td>service pack version</td>
</tr>
<tr>
<td></td>
<td>uefi</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td></td>
<td>OS uses UEFI on startup</td>
</tr>
<tr>
<td>si.uuid(cb)</td>
<td>{...}</td>

1
lib/index.d.ts vendored
View File

@ -203,6 +203,7 @@ export namespace Systeminformation {
serial: string;
build: string;
servicepack: string;
uefi: boolean;
}
interface UuidData {

View File

@ -180,7 +180,8 @@ function osInfo(callback) {
logofile: '',
serial: '',
build: '',
servicepack: ''
servicepack: '',
uefi: false
};
if (_linux) {
@ -214,19 +215,22 @@ function osInfo(callback) {
result.codename = codename;
result.codepage = util.getCodepage();
result.build = (release.BUILD_ID || '').replace(/"/g, '').trim();
uuid().then(data => {
result.serial = data.os;
if (callback) {
callback(result);
}
resolve(result);
isUefiLinux().then(uefi => {
result.uefi = uefi;
uuid().then(data => {
result.serial = data.os;
if (callback) {
callback(result);
}
resolve(result);
});
});
//}
});
}
if (_freebsd || _openbsd || _netbsd) {
exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid', function (error, stdout) {
exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid machdep.bootmethod', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
result.distro = util.getValue(lines, 'kern.ostype');
@ -235,6 +239,7 @@ function osInfo(callback) {
result.serial = util.getValue(lines, 'kern.uuid');
result.codename = '';
result.codepage = util.getCodepage();
result.uefi = util.getValue(lines, 'machdep.bootmethod').toLowerCase().indexOf('uefi') >= 0;
}
if (callback) {
callback(result);
@ -265,7 +270,7 @@ function osInfo(callback) {
result.codename = (result.release.indexOf('10.13') > -1 ? 'macOS High Sierra' : result.codename);
result.codename = (result.release.indexOf('10.14') > -1 ? 'macOS Mojave' : result.codename);
result.codename = (result.release.indexOf('10.15') > -1 ? 'macOS Catalina' : result.codename);
result.uefi = true;
result.codepage = util.getCodepage();
if (callback) {
callback(result);
@ -294,10 +299,13 @@ function osInfo(callback) {
result.build = util.getValue(lines, 'BuildNumber', '=').trim();
result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', '=').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', '=').trim();
result.codepage = util.getCodepage();
if (callback) {
callback(result);
}
resolve(result);
isUefiWindows().then(uefi => {
result.uefi = uefi;
if (callback) {
callback(result);
}
resolve(result);
});
});
} catch (e) {
if (callback) { callback(result); }
@ -310,6 +318,35 @@ function osInfo(callback) {
exports.osInfo = osInfo;
function isUefiLinux() {
return new Promise((resolve) => {
process.nextTick(() => {
fs.stat('/sys/firmware/efi', function (err) {
if (!err) {
resolve(true);
}
else {
resolve(false);
}
});
});
});
}
function isUefiWindows() {
return new Promise((resolve) => {
process.nextTick(() => {
exec('%windir%\\Panther\\setupact.log | findstr "Detected boot environment" ', util.execOptsWin, function (error, stdout) {
if (!error) {
const line = stdout.toString().split('\n\r')[0];
resolve(line.toLowerCase().indexOf('uefi') >= 0);
}
resolve(false);
});
});
});
}
function versions(callback) {
return new Promise((resolve) => {
process.nextTick(() => {