systeminformation 5.15.0 → 5.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,6 +112,8 @@ si.cpu()
112
112
 
113
113
  (last 7 major and minor version releases)
114
114
 
115
+ - Version 5.16.0: `fsSize()` added rw property
116
+ - Version 5.15.0: `blockDevices()` added device
115
117
  - Version 5.14.0: `blockDevices()` added raid group member (linux)
116
118
  - Version 5.13.0: `networkConnections()` added process name (mac OS)
117
119
  - Version 5.12.0: `cpu()` added performance and efficiency cores
@@ -489,6 +491,7 @@ Full function reference with examples can be found at [https://systeminformation
489
491
  | | [0].available | X | X | X | X | | used in bytes |
490
492
  | | [0].use | X | X | X | X | | used in % |
491
493
  | | [0].mount | X | X | X | X | | mount point |
494
+ | | [0].rw | X | X | X | X | | read and write (false if read only) |
492
495
  | si.fsOpenFiles(cb) | {...} | X | X | X | | | count max/allocated file descriptors |
493
496
  | | max | X | X | X | | | max file descriptors |
494
497
  | | allocated | X | X | X | | | current open files count |
package/lib/filesystem.js CHANGED
@@ -39,6 +39,7 @@ let _disk_io = {};
39
39
  function fsSize(callback) {
40
40
 
41
41
  let macOsDisks = [];
42
+ let osMounts = [];
42
43
 
43
44
  function getmacOsFsType(fs) {
44
45
  if (!fs.startsWith('/')) { return 'NFS'; }
@@ -86,6 +87,7 @@ function fsSize(callback) {
86
87
  const used = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[3] : line[2])) * 1024;
87
88
  const available = parseInt(((_linux || _freebsd || _openbsd || _netbsd) ? line[4] : line[3])) * 1024;
88
89
  const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
90
+ let rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
89
91
  line.splice(0, (_linux || _freebsd || _openbsd || _netbsd) ? 6 : 5);
90
92
  const mount = line.join(' ');
91
93
  if (!data.find(el => (el.fs === fs && el.type === fsType))) {
@@ -96,7 +98,8 @@ function fsSize(callback) {
96
98
  used,
97
99
  available,
98
100
  use,
99
- mount
101
+ mount,
102
+ rw
100
103
  });
101
104
  }
102
105
  }
@@ -110,18 +113,37 @@ function fsSize(callback) {
110
113
  let data = [];
111
114
  if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
112
115
  let cmd = '';
116
+ macOsDisks = [];
117
+ osMounts = {};
113
118
  if (_darwin) {
114
119
  cmd = 'df -kP';
115
120
  try {
116
121
  macOsDisks = execSync('diskutil list').toString().split('\n').filter(line => {
117
122
  return !line.startsWith('/') && line.indexOf(':') > 0;
118
123
  });
124
+ execSync('mount').toString().split('\n').filter(line => {
125
+ return line.startsWith('/');
126
+ }).forEach((line) => {
127
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
128
+ });
119
129
  } catch (e) {
120
- macOsDisks = [];
130
+ util.noop();
121
131
  }
122
132
  }
123
- if (_linux) { cmd = 'df -lkPTx squashfs'; }
124
- if (_freebsd || _openbsd || _netbsd) { cmd = 'df -lkPT'; }
133
+ if (_linux) {
134
+ cmd = 'df -lkPTx squashfs';
135
+ execSync('cat /proc/mounts').toString().split('\n').filter(line => {
136
+ return line.startsWith('/');
137
+ }).forEach((line) => {
138
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('rw') >= 0;
139
+ });
140
+ }
141
+ if (_freebsd || _openbsd || _netbsd) {
142
+ cmd = 'df -lkPT';
143
+ execSync('mount').toString().split('\n').forEach((line) => {
144
+ osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
145
+ });
146
+ }
125
147
  exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
126
148
  let lines = filterLines(stdout);
127
149
  data = parseDf(lines);
@@ -151,7 +173,7 @@ function fsSize(callback) {
151
173
  if (_windows) {
152
174
  try {
153
175
  // util.wmic('logicaldisk get Caption,FileSystem,FreeSpace,Size').then((stdout) => {
154
- util.powerShell('Get-CimInstance Win32_logicaldisk | select Caption,FileSystem,FreeSpace,Size | fl').then((stdout, error) => {
176
+ util.powerShell('Get-CimInstance Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size | fl').then((stdout, error) => {
155
177
  if (!error) {
156
178
  let devices = stdout.toString().split(/\n\s*\n/);
157
179
  devices.forEach(function (device) {
@@ -159,6 +181,8 @@ function fsSize(callback) {
159
181
  const size = util.toInt(util.getValue(lines, 'size', ':'));
160
182
  const free = util.toInt(util.getValue(lines, 'freespace', ':'));
161
183
  const caption = util.getValue(lines, 'caption', ':');
184
+ const rwValue = util.getValue(lines, 'access', ':');
185
+ const rw = rwValue ? (util.toInt(rwValue) !== 1) : null;
162
186
  if (size) {
163
187
  data.push({
164
188
  fs: caption,
@@ -167,7 +191,8 @@ function fsSize(callback) {
167
191
  used: size - free,
168
192
  available: free,
169
193
  use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
170
- mount: caption
194
+ mount: caption,
195
+ rw
171
196
  });
172
197
  }
173
198
  });
package/lib/index.d.ts CHANGED
@@ -434,6 +434,7 @@ export namespace Systeminformation {
434
434
  available: number;
435
435
  use: number;
436
436
  mount: string;
437
+ rw: boolean | null;
437
438
  }
438
439
 
439
440
  interface FsOpenFilesData {
@@ -1010,7 +1011,7 @@ export function audio(cb?: (data: Systeminformation.AudioData[]) => any): Promis
1010
1011
  export function bluetoothDevices(cb?: (data: Systeminformation.BluetoothDeviceData[]) => any): Promise<Systeminformation.BluetoothDeviceData[]>;
1011
1012
 
1012
1013
  export function getStaticData(cb?: (data: Systeminformation.StaticData) => any): Promise<Systeminformation.StaticData>;
1013
- export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<ysteminformation.DynamicData>;
1014
+ export function getDynamicData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<Systeminformation.DynamicData>;
1014
1015
  export function getAllData(srv?: string, iface?: string, cb?: (data: any) => any): Promise<Systeminformation.StaticData & Systeminformation.DynamicData>;
1015
1016
  export function get(valuesObject: any, cb?: (data: any) => any): Promise<any>;
1016
1017
  export function observe(valuesObject: any, interval: number, cb?: (data: any) => any): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.15.0",
3
+ "version": "5.16.0",
4
4
  "description": "Advanced, lightweight system and OS information library",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Hildebrandt <hildebrandt@plus-innovations.com> (https://plus-innovations.com)",