| 4.4.1 |
2019-05-11 |
diff --git a/docs/index.html b/docs/index.html
index eb2f835..f4f0d75 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -170,7 +170,7 @@
systeminformation
- Current Version: 4.4.1
+ Current Version: 4.5.0
diff --git a/lib/filesystem.js b/lib/filesystem.js
index 9044833..a6cc8ab 100644
--- a/lib/filesystem.js
+++ b/lib/filesystem.js
@@ -76,7 +76,7 @@ function fsSize(callback) {
}
if (_windows) {
try {
- util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout, error) => {
+ util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
let lines = stdout.split('\r\n').filter(line => line.trim() !== '').filter((line, idx) => idx > 0);
lines.forEach(function (line) {
if (line !== '') {
@@ -107,6 +107,66 @@ function fsSize(callback) {
exports.fsSize = fsSize;
+// --------------------------
+// FS - open files count
+
+function fsOpenFiles(callback) {
+
+ return new Promise((resolve) => {
+ process.nextTick(() => {
+ const result = {
+ max: -1,
+ allocated: -1,
+ available: -1
+ };
+ if (_freebsd || _openbsd || _darwin) {
+ let cmd = 'sysctl -a | grep \'kern.*files\'';
+ exec(cmd, function (error, stdout) {
+ if (!error) {
+ let lines = stdout.toString().split('\n');
+ result.max = parseInt(util.getValue(lines, 'kern.maxfiles', ':'), 10);
+ result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10);
+ }
+ if (callback) {
+ callback(result);
+ }
+ resolve(result);
+ });
+ }
+ if (_linux) {
+ let cmd = 'cat /proc/sys/fs/file-nr';
+ exec(cmd, function (error, stdout) {
+ if (!error) {
+ let lines = stdout.toString().split('\n');
+ if (lines[0]) {
+ const parts = lines[0].replace(/\s+/g, ' ').split(' ');
+ if (parts.length === 3) {
+ result.allocated = parseInt(parts[0], 10);
+ result.available = parseInt(parts[1], 10);
+ result.max = parseInt(parts[2], 10);
+ }
+ }
+ }
+ if (callback) {
+ callback(result);
+ }
+ resolve(result);
+ });
+ }
+ if (_sunos) {
+ if (callback) { callback(result); }
+ resolve(result);
+ }
+ if (_windows) {
+ if (callback) { callback(result); }
+ resolve(result);
+ }
+ });
+ });
+}
+
+exports.fsOpenFiles = fsOpenFiles;
+
// --------------------------
// disks
@@ -638,9 +698,9 @@ function diskLayout(callback) {
model = model.toUpperCase();
diskManufacturers.forEach((manufacturer) => {
const re = RegExp(manufacturer.pattern);
- if (re.test(model)) { result = manufacturer.manufacturer }
- })
- return result
+ if (re.test(model)) { result = manufacturer.manufacturer; }
+ });
+ return result;
}
return new Promise((resolve) => {
@@ -656,7 +716,7 @@ function diskLayout(callback) {
const out = stdout.toString().trim();
const outJSON = JSON.parse(out);
if (outJSON && outJSON.hasOwnProperty('blockdevices')) {
- let devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null });
+ let devices = outJSON.blockdevices.filter(item => { return item.group === 'disk' && item.size > 0 && item.model !== null; });
devices.forEach((device) => {
let mediumType = '';
const BSDName = '/dev/' + device.name;
diff --git a/lib/index.d.ts b/lib/index.d.ts
index f8c0442..379e499 100644
--- a/lib/index.d.ts
+++ b/lib/index.d.ts
@@ -250,6 +250,12 @@ export namespace Systeminformation {
mount: string;
}
+ interface FsOpenFilesData {
+ max: number;
+ allocated: number;
+ available: number;
+ }
+
interface BlockDevicesData {
name: string;
identifier: string;
@@ -511,6 +517,7 @@ export function battery(cb?: (data: Systeminformation.BatteryData) => any): Prom
export function graphics(cb?: (data: Systeminformation.GraphicsData) => any): Promise;
export function fsSize(cb?: (data: Systeminformation.FsSizeData[]) => any): Promise;
+export function fsOpenFiles(cb?: (data: Systeminformation.FsOpenFilesData[]) => any): Promise;
export function blockDevices(cb?: (data: Systeminformation.BlockDevicesData[]) => any): Promise;
export function fsStats(cb?: (data: Systeminformation.FsStatsData) => any): Promise;
export function disksIO(cb?: (data: Systeminformation.DisksIoData) => any): Promise;
diff --git a/lib/index.js b/lib/index.js
index fc75554..5fffd4b 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -337,6 +337,7 @@ exports.battery = battery;
exports.graphics = graphics.graphics;
exports.fsSize = filesystem.fsSize;
+exports.fsOpenFiles = filesystem.fsOpenFiles;
exports.blockDevices = filesystem.blockDevices;
exports.fsStats = filesystem.fsStats;
exports.disksIO = filesystem.disksIO;