diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b43ea5..463b31e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.7.0 | 2019-05-29 | partial netBSD support | | 4.6.1 | 2019-05-29 | get wmic path - fic windows | | 4.6.0 | 2019-05-27 | added `dockerInfo()` | | 4.5.1 | 2019-05-17 | updated docs | diff --git a/README.md b/README.md index ee80dc2..78008f1 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Lightweight collection of 40+ functions to retrieve detailed hardware, system an - simple to use - get detailed information about system, cpu, baseboard, battery, memory, disks/filesystem, network, docker, software, services and processes -- supports Linux, macOS, partial Windows, FreeBSD and SunOS support +- supports Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support - no npm dependencies (for production) ### Installation @@ -82,6 +82,7 @@ si.cpu() (last 7 major and minor version releases) +- Version 4.7.0: partial NetBSD support - Version 4.6.0: added `dockerInfo()` - Version 4.5.0: `fsOpenFiles()` added open file descriptor count - Version 4.4.0: `dockerContainers()` added started, finished time @@ -97,7 +98,7 @@ You can find all changes here: [detailed changelog][changelog-url] [Node.js][nodejs-url] comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still work in progress. It is supposed to be used as a backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above. -I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details. +I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra, Mojave) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details. If you have comments, suggestions & reports, please feel free to contact me! @@ -723,7 +724,8 @@ Windows is a registered trademark of Microsoft Corporation. Node.js is a tradema Intel is a trademark of Intel Corporation, AMD is a trademark of Advanced Micro Devices Inc., Raspberry Pi is a trademark of the Raspberry Pi Foundation, Debian is a trademark of the Debian Project, Ubuntu is a trademark of Canonical Ltd., FreeBSD is a registered trademark of The FreeBSD Foundation, -Docker is a trademark of Docker, Inc., Sun, Solaris, OpenSolaris and registered trademarks of Sun Microsystems. +NetBSD is a registered trademark of The NetBSD Foundation, Docker is a trademark of Docker, Inc., Sun, +Solaris, OpenSolaris and registered trademarks of Sun Microsystems. All other trademarks are the property of their respective owners. diff --git a/docs/gettingstarted.html b/docs/gettingstarted.html index 16e51bc..30a370b 100644 --- a/docs/gettingstarted.html +++ b/docs/gettingstarted.html @@ -50,7 +50,7 @@ @@ -58,7 +58,7 @@

Node.js comes with some basic OS information, but I always wanted a little more. So I came up to write this little library. This library is still work in progress. It is supposed to be used as a backend/server-side library (will definilely not work within a browser). It requires node.js version 4.0 and above.

-

I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows 7, Windows 10, FreeBSD and SunOS machines. +

I was able to test it on several Debian, Raspbian, Ubuntu distributions as well as macOS (Mavericks, Yosemite, El Captain, Sierra, High Sierra) and some Windows 7, Windows 10, FreeBSD, OpenBSD, NetBSD and SunOS machines. Not all functions are supported on all operating systems. Have a look at the function reference in the docs to get further details.

If you have comments, suggestions & reports, please feel free to contact me on github!

I also created a nice little command line tool called mmon (micro-monitor) for Linux and macOS, also available via github and npm

diff --git a/docs/history.html b/docs/history.html index ed60e47..9bea258 100644 --- a/docs/history.html +++ b/docs/history.html @@ -80,6 +80,11 @@ + + 4.7.0 + 2019-05-29 + partial NetBSD support + 4.6.1 2019-05-29 diff --git a/docs/index.html b/docs/index.html index 5a72a68..6777304 100644 --- a/docs/index.html +++ b/docs/index.html @@ -73,7 +73,7 @@ } function typed() { var options = { - strings: ["System and OS information library for node.js", "Get detailed hardware, system & OS information.", "For Linux, macOS, Windows, FreeBSD, SunOS"], + strings: ["System and OS information library for node.js", "Get detailed hardware, system & OS information.", "For Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD, SunOS"], typeSpeed: 60, loop: false, backDelay: 1200, @@ -170,7 +170,7 @@
systeminformation
-
Current Version: 4.6.1
+
Current Version: 4.7.0
@@ -183,7 +183,7 @@
Overview
-
Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information. For Linux, macOS, partial Windows, FreeBSD and SunOS support
+
Lightweight collection of 40+ functions to retrieve detailed hardware, system and OS information. For Linux, macOS, partial Windows, FreeBSD, OpenBSD, NetBSD and SunOS support
diff --git a/docs/trademarks.html b/docs/trademarks.html index d45ba6d..816dadb 100644 --- a/docs/trademarks.html +++ b/docs/trademarks.html @@ -53,6 +53,7 @@
  • Raspberry Pi is a trademark of the Raspberry Pi Foundation
  • Debian is a trademark of the Debian Project
  • FreeBSD is a registered trademark of The FreeBSD Foundation
  • +
  • NetBSD is a registered trademark of The NetBSD Foundation
  • Docker is a trademark of Docker, Inc.
  • Ubuntu is a trademark of Canonical Ltd.
  • CentOS is a trademark of Read Hat Inc.
  • diff --git a/lib/battery.js b/lib/battery.js index 1472779..408c742 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); module.exports = function (callback) { @@ -101,7 +102,7 @@ module.exports = function (callback) { resolve(result); } } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('sysctl hw.acpi.battery hw.acpi.acline', function (error, stdout) { let lines = stdout.toString().split('\n'); const batteries = parseInt('0' + util.getValue(lines, 'hw.acpi.battery.units'), 10); diff --git a/lib/cpu.js b/lib/cpu.js index 4de9725..63934df 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); let _cpu_speed = '0.00'; @@ -355,7 +356,7 @@ function getCpu() { }); }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { let modelline = ''; let lines = []; if (os.cpus()[0] && os.cpus()[0].model) modelline = os.cpus()[0].model; @@ -659,7 +660,7 @@ function cpuTemperature(callback) { } }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('sysctl dev.cpu | grep temp', function (error, stdout) { if (!error) { let lines = stdout.toString().split('\n'); @@ -792,7 +793,7 @@ function cpuFlags(callback) { } }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('export LC_ALL=C; dmidecode -t 4 2>/dev/null; unset LC_ALL', function (error, stdout) { let flags = []; if (!error) { @@ -870,7 +871,7 @@ function cpuCache(callback) { resolve(result); }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('export LC_ALL=C; dmidecode -t 7 2>/dev/null; unset LC_ALL', function (error, stdout) { let cache = []; if (!error) { diff --git a/lib/filesystem.js b/lib/filesystem.js index a6cc8ab..af603a5 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); const NOT_SUPPORTED = 'not supported'; @@ -39,11 +40,11 @@ function fsSize(callback) { return new Promise((resolve) => { process.nextTick(() => { let data = []; - if (_linux || _freebsd || _openbsd || _darwin) { + if (_linux || _freebsd || _openbsd || _netbsd || _darwin) { let cmd = ''; if (_darwin) cmd = 'df -lkP | grep ^/'; if (_linux) cmd = 'df -lkPT | grep ^/'; - if (_freebsd || _openbsd) cmd = 'df -lkPT'; + if (_freebsd || _openbsd || _netbsd) cmd = 'df -lkPT'; exec(cmd, function (error, stdout) { if (!error) { let lines = stdout.toString().split('\n'); @@ -54,10 +55,10 @@ function fsSize(callback) { if (line && (line[0].startsWith('/')) || (line[6] && line[6] === '/')) { data.push({ 'fs': line[0], - 'type': ((_linux || _freebsd || _openbsd) ? line[1] : 'HFS'), - 'size': parseInt(((_linux || _freebsd || _openbsd) ? line[2] : line[1])) * 1024, - 'used': parseInt(((_linux || _freebsd || _openbsd) ? line[3] : line[2])) * 1024, - 'use': parseFloat((100.0 * ((_linux || _freebsd || _openbsd) ? line[3] : line[2]) / ((_linux || _freebsd || _openbsd) ? line[2] : line[1])).toFixed(2)), + 'type': ((_linux || _freebsd || _openbsd || _netbsd) ? line[1] : 'HFS'), + 'size': parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])) * 1024, + 'used': parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024, + 'use': parseFloat((100.0 * ((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2]) / ((_linux || _freebsd || _openbsd || _netbsd) ? line[2] : line[1])).toFixed(2)), 'mount': line[line.length - 1] }); } @@ -119,7 +120,7 @@ function fsOpenFiles(callback) { allocated: -1, available: -1 }; - if (_freebsd || _openbsd || _darwin) { + if (_freebsd || _openbsd || _netbsd || _darwin) { let cmd = 'sysctl -a | grep \'kern.*files\''; exec(cmd, function (error, stdout) { if (!error) { @@ -587,7 +588,7 @@ function disksIO(callback) { let wIO = 0; if ((_disk_io && !_disk_io.ms) || (_disk_io && _disk_io.ms && Date.now() - _disk_io.ms >= 500)) { - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { // prints Block layer statistics for all mounted volumes // var cmd = "for mount in `lsblk | grep / | sed -r 's/│ └─//' | cut -d ' ' -f 1`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done"; // var cmd = "for mount in `lsblk | grep / | sed 's/[│└─├]//g' | awk '{$1=$1};1' | cut -d ' ' -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done"; @@ -802,7 +803,7 @@ function diskLayout(callback) { } }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { if (callback) { callback(result); } resolve(result); } diff --git a/lib/graphics.js b/lib/graphics.js index 3b2457c..7e0332c 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); let _resolutionx = 0; @@ -461,7 +462,7 @@ function graphics(callback) { }); } } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { if (callback) { callback(result); } resolve(result); } diff --git a/lib/index.js b/lib/index.js index 1cdd868..8006546 100644 --- a/lib/index.js +++ b/lib/index.js @@ -40,6 +40,7 @@ let _platform = process.platform; const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); // ---------------------------------------------------------------------------------- @@ -139,7 +140,7 @@ function getDynamicData(srv, iface, callback) { let functionProcessed = (function () { let totalFunctions = 14; if (_windows) totalFunctions = 10; - if (_freebsd || _openbsd) totalFunctions = 11; + if (_freebsd || _openbsd || _netbsd) totalFunctions = 11; if (_sunos) totalFunctions = 6; return function () { @@ -203,7 +204,7 @@ function getDynamicData(srv, iface, callback) { }); } - if (!_openbsd && !_freebsd && !_sunos) { + if (!_openbsd && !_freebsd && !_netbsd && !_sunos) { network.networkStats(iface).then(res => { data.networkStats = res; functionProcessed(); @@ -243,14 +244,14 @@ function getDynamicData(srv, iface, callback) { }); } - if (!_windows && !_openbsd && !_freebsd && !_sunos) { + if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) { filesystem.fsStats().then(res => { data.fsStats = res; functionProcessed(); }); } - if (!_windows && !_openbsd && !_freebsd && !_sunos) { + if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) { filesystem.disksIO().then(res => { data.disksIO = res; functionProcessed(); diff --git a/lib/internet.js b/lib/internet.js index 676e4e2..822c796 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); // -------------------------- @@ -42,7 +43,7 @@ function inetChecksite(url, callback) { if (url) { url = url.toLowerCase(); let t = Date.now(); - if (_linux || _freebsd || _openbsd || _darwin || _sunos) { + if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) { let args = ' -I --connect-timeout 5 -m 5 ' + url + ' 2>/dev/null | head -n 1 | cut -d " " -f2'; let cmd = 'curl'; exec(cmd + args, function (error, stdout) { @@ -111,11 +112,11 @@ function inetLatency(host, callback) { return new Promise((resolve) => { process.nextTick(() => { let cmd; - if (_linux || _freebsd || _openbsd || _darwin) { + if (_linux || _freebsd || _openbsd || _netbsd || _darwin) { if (_linux) { cmd = 'ping -c 2 -w 3 ' + host + ' | grep rtt'; } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { cmd = 'ping -c 2 -t 3 ' + host + ' | grep round-trip'; } if (_darwin) { diff --git a/lib/memory.js b/lib/memory.js index 5df939e..6d9834a 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -24,6 +24,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); const OSX_RAM_manufacturers = { @@ -158,7 +159,7 @@ function mem(callback) { resolve(result); }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('/sbin/sysctl -a | grep -E "hw.realmem|hw.physmem|vm.stats.vm.v_page_count|vm.stats.vm.v_wire_count|vm.stats.vm.v_active_count|vm.stats.vm.v_inactive_count|vm.stats.vm.v_cache_count|vm.stats.vm.v_free_count|vm.stats.vm.v_page_size"', function (error, stdout) { if (!error) { let lines = stdout.toString().split('\n'); @@ -260,7 +261,7 @@ function memLayout(callback) { let result = []; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { exec('export LC_ALL=C; dmidecode -t memory 2>/dev/null | grep -iE "Size:|Type|Speed|Manufacturer|Form Factor|Locator|Memory Device|Serial Number|Voltage|Part Number"; unset LC_ALL', function (error, stdout) { if (!error) { let devices = stdout.toString().split('Memory Device'); diff --git a/lib/network.js b/lib/network.js index 4aac4db..c19bf93 100644 --- a/lib/network.js +++ b/lib/network.js @@ -26,6 +26,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); let _network = {}; @@ -58,11 +59,11 @@ function getDefaultNetworkInterface() { } } ifacename = ifacename || ifacenameFirst || ''; - if (_linux || _darwin || _freebsd || _openbsd || _sunos) { + if (_linux || _darwin || _freebsd || _openbsd || _netbsd || _sunos) { let cmd = ''; if (_linux) cmd = 'ip route 2> /dev/null | grep default | awk \'{print $5}\''; if (_darwin) cmd = 'route get 0.0.0.0 2>/dev/null | grep interface: | awk \'{print $2}\''; - if (_freebsd || _openbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:'; + if (_freebsd || _openbsd || _netbsd || _sunos) cmd = 'route get 0.0.0.0 | grep interface:'; let result = execSync(cmd); ifacename = result.toString().split('\n')[0]; if (ifacename.indexOf(':') > -1) { @@ -80,7 +81,7 @@ function getMacAddresses() { let iface = ''; let mac = ''; let result = {}; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { if (typeof pathToIp === 'undefined') { try { const lines = execSync('which ip').toString().split('\n'); @@ -384,7 +385,7 @@ function networkInterfaces(callback) { type = 'wireless'; } } - if (_darwin || _freebsd || _openbsd) { + if (_darwin || _freebsd || _openbsd || _netbsd) { nics.forEach(nic => { if (nic.iface === dev) { mtu = nic.mtu; @@ -595,7 +596,7 @@ function networkStatsSingle(iface) { resolve(result); } } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { cmd = 'netstat -ibndI ' + iface; exec(cmd, function (error, stdout) { if (!error) { @@ -707,9 +708,9 @@ function networkConnections(callback) { return new Promise((resolve) => { process.nextTick(() => { let result = []; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { let cmd = 'netstat -tuna | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"'; - if (_freebsd || _openbsd) cmd = 'netstat -na | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"'; + if (_freebsd || _openbsd || _netbsd) cmd = 'netstat -na | grep "ESTABLISHED\\|SYN_SENT\\|SYN_RECV\\|FIN_WAIT1\\|FIN_WAIT2\\|TIME_WAIT\\|CLOSE\\|CLOSE_WAIT\\|LAST_ACK\\|LISTEN\\|CLOSING\\|UNKNOWN\\|VERBUNDEN"'; exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) { if (!error) { let lines = stdout.toString().split('\n'); diff --git a/lib/osinfo.js b/lib/osinfo.js index a68b627..f6b3864 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); const NOT_SUPPORTED = 'not supported'; @@ -220,7 +221,7 @@ function osInfo(callback) { //} }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('sysctl kern.ostype kern.osrelease kern.osrevision kern.hostuuid', function (error, stdout) { if (!error) { @@ -680,7 +681,7 @@ function uuid(callback) { resolve(result); }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('kenv -q smbios.system.uuid', function (error, stdout) { if (!error) { result.os = stdout.toString().split('\n')[0].trim().toLowerCase(); diff --git a/lib/processes.js b/lib/processes.js index c64aa4d..fc9038a 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -26,6 +26,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); let _processes_cpu = { @@ -101,8 +102,8 @@ function services(srv, callback) { let dataSrv = []; let allSrv = []; - if (_linux || _freebsd || _openbsd || _darwin) { - if ((_linux || _freebsd || _openbsd) && srv === '*') { + if (_linux || _freebsd || _openbsd || _netbsd || _darwin) { + if ((_linux || _freebsd || _openbsd || _netbsd) && srv === '*') { srv = ''; let tmpsrv = execSync('service --status-all 2> /dev/null').toString().split('\n'); for (const s of tmpsrv) { @@ -560,9 +561,9 @@ function processes(callback) { let cmd = ''; if ((_processes_cpu.ms && Date.now() - _processes_cpu.ms >= 500) || _processes_cpu.ms === 0) { - if (_linux || _freebsd || _openbsd || _darwin || _sunos) { + if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) { if (_linux) cmd = 'export LC_ALL=C; ps -axo pid:11,ppid:11,pcpu:6,pmem:6,pri:5,vsz:11,rss:11,ni:5,lstart:30,state:5,tty:15,user:20,command; unset LC_ALL'; - if (_freebsd || _openbsd) cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,lstart,state,tty,user,command; unset LC_ALL'; + if (_freebsd || _openbsd || _netbsd) cmd = 'export LC_ALL=C; ps -axo pid,ppid,pcpu,pmem,pri,vsz,rss,ni,lstart,state,tty,user,command; unset LC_ALL'; if (_darwin) cmd = 'export LC_ALL=C; ps -acxo pid,ppid,pcpu,pmem,pri,vsz,rss,nice,lstart,state,tty,user,command -r; unset LC_ALL'; if (_sunos) cmd = 'ps -Ao pid,ppid,pcpu,pmem,pri,vsz,rss,nice,stime,s,tty,user,comm'; exec(cmd, { maxBuffer: 1024 * 2000 }, function (error, stdout) { diff --git a/lib/system.js b/lib/system.js index 5ba251f..a625ab1 100644 --- a/lib/system.js +++ b/lib/system.js @@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); function system(callback) { @@ -41,7 +42,7 @@ function system(callback) { sku: '-', }; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { exec('export LC_ALL=C; dmidecode -t system 2>/dev/null; unset LC_ALL', function (error, stdout) { // if (!error) { let lines = stdout.toString().split('\n'); @@ -251,7 +252,7 @@ function bios(callback) { revision: '', }; let cmd = ''; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { if (process.arch === 'arm') { cmd = 'cat /proc/cpuinfo | grep Serial'; @@ -345,7 +346,7 @@ function baseboard(callback) { assetTag: '-', }; let cmd = ''; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { if (process.arch === 'arm') { cmd = 'cat /proc/cpuinfo | grep Serial'; // 'BCM2709', 'BCM2835', 'BCM2708' --> @@ -485,7 +486,7 @@ function chassis(callback) { assetTag: '-', sku: '', }; - if (_linux || _freebsd || _openbsd) { + if (_linux || _freebsd || _openbsd || _netbsd) { const cmd = `echo -n "chassis_asset_tag: "; cat /sys/devices/virtual/dmi/id/chassis_asset_tag 2>/dev/null; echo; echo -n "chassis_serial: "; cat /sys/devices/virtual/dmi/id/chassis_serial 2>/dev/null; echo; echo -n "chassis_type: "; cat /sys/devices/virtual/dmi/id/chassis_type 2>/dev/null; echo; diff --git a/lib/users.js b/lib/users.js index 1f23fae..c48fba1 100644 --- a/lib/users.js +++ b/lib/users.js @@ -23,6 +23,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); const _sunos = (_platform === 'sunos'); // -------------------------- @@ -211,7 +212,7 @@ function users(callback) { } }); } - if (_freebsd || _openbsd) { + if (_freebsd || _openbsd || _netbsd) { exec('who; echo "---"; w -ih', function (error, stdout) { if (!error) { // lines / split diff --git a/lib/util.js b/lib/util.js index c7a117b..f098d87 100644 --- a/lib/util.js +++ b/lib/util.js @@ -25,6 +25,7 @@ const _darwin = (_platform === 'darwin'); const _windows = (_platform === 'win32'); const _freebsd = (_platform === 'freebsd'); const _openbsd = (_platform === 'openbsd'); +const _netbsd = (_platform === 'netbsd'); // const _sunos = (_platform === 'sunos'); let _cores = 0; @@ -320,7 +321,7 @@ function getCodepage() { } return codepage; } - if (_linux || _darwin || _freebsd || _openbsd) { + if (_linux || _darwin || _freebsd || _openbsd || _netbsd) { if (!codepage) { try { const stdout = execSync('echo $LANG'); diff --git a/package.json b/package.json index 16c7ead..9aae51e 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,8 @@ "osx", "windows", "freebsd", + "openbsd", + "netbsd", "cpu", "cpuload", "physical cores", @@ -72,6 +74,7 @@ "win32", "freebsd", "openbsd", + "netbsd", "sunos" ], "engines": {