osInfo() added FQDN

This commit is contained in:
Sebastian Hildebrandt 2020-12-06 15:50:04 +01:00
parent f6f5e83a2d
commit f94b6020eb
7 changed files with 48 additions and 3 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.31.0 | 2020-12-06 | `osInfo()` added FQDN |
| 4.30.11 | 2020-12-02 | `cpu()` bug fix speed parsing |
| 4.30.10 | 2020-12-01 | `cpu()` handled speed parsing error (Apple Silicon) |
| 4.30.9 | 2020-12-01 | `cpu()` corrected processor names (Raspberry Pi) |

View File

@ -93,6 +93,7 @@ si.cpu()
(last 7 major and minor version releases)
- Version 4.31.0: `osInfo()` added FQDN
- Version 4.30.0: `get()` added possibility to provide parameters
- Version 4.29.0: `fsSize()` correct fs type detection macOS (HFS, APFS, NFS)
- Version 4.28.0: `graphics()` added deviceName (Windows)
@ -100,7 +101,6 @@ si.cpu()
- 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.24.0: `networkInterfaces()` added subnet mask ip4 and ip6
- Version 4.23.0: `versions()` added param to specify which program/lib versions to detect
- ...
You can find all changes here: [detailed changelog][changelog-url]
@ -298,6 +298,7 @@ I also created a nice little command line tool called [mmon][mmon-github-url] (m
| | kernel | X | X | X | X | X | kernel release - same as os.release() |
| | arch | X | X | X | X | X | same as os.arch() |
| | hostname | X | X | X | X | X | same as os.hostname() |
| | fqdn | X | X | X | X | X | FQDN fully qualified domain name |
| | codepage | X | X | X | X | | OS build version |
| | logofile | X | X | X | X | X | e.g. 'apple', 'debian', 'fedora', ... |
| | serial | X | X | X | X | | OS/Host serial number |

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.31.0</th>
<td>2020-12-06</td>
<td><span class="code">osInfo()</span> added FQDN</td>
</tr>
<tr>
<th scope="row">4.30.11</th>
<td>2020-12-02</td>

View File

@ -169,7 +169,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.30.11</span></div>
<div class="version">Current Version: <span id="version">4.31.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">
@ -208,7 +208,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">359</div>
<div class="numbers">364</div>
<div class="title">Dependents</div>
</div>
</div>

View File

@ -145,6 +145,16 @@
<td>X</td>
<td>same as os.hostname()</td>
</tr>
<tr>
<td></td>
<td>fqdn</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>X</td>
<td>fully qualfied domain name</td>
</tr>
<tr>
<td></td>
<td>codepage</td>
@ -220,6 +230,7 @@ si.osInfo().then(data => console.log(data));</code></pre class="example">
kernel: '19.3.0',
arch: 'x64',
hostname: 'hostname.local',
fqdn: 'hostname.local',
codepage: 'UTF-8',
logofile: 'apple',
serial: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',

1
lib/index.d.ts vendored
View File

@ -285,6 +285,7 @@ export namespace Systeminformation {
kernel: string;
arch: string;
hostname: string;
fqdn: string;
codepage: string;
logofile: string;
serial: string;

View File

@ -17,6 +17,7 @@ const os = require('os');
const exec = require('child_process').exec;
const util = require('./util');
const fs = require('fs');
const { execSync } = require('child_process');
let _platform = process.platform;
@ -160,6 +161,30 @@ function getLogoFile(distro) {
return result;
}
// --------------------------
// FQDN
function getFQDN() {
let fqdn = os.hostname;
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) {
try {
const stdout = execSync('hostname -f');
fqdn = stdout.toString().split(os.EOL)[0];
} catch (e) {
util.noop();
}
}
if (_windows) {
try {
const stdout = execSync('echo %COMPUTERNAME%.%USERDNSDOMAIN%');
fqdn = stdout.toString().split(os.EOL)[0];
} catch (e) {
util.noop();
}
}
return fqdn;
}
// --------------------------
// OS Information
@ -176,6 +201,7 @@ function osInfo(callback) {
kernel: os.release(),
arch: os.arch(),
hostname: os.hostname(),
fqdn: getFQDN(),
codepage: '',
logofile: '',
serial: '',