systeminformation 5.12.8 → 5.12.10

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2021 Sebastian Hildebrandt
3
+ Copyright (c) 2014-2022 Sebastian Hildebrandt
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
package/README.md CHANGED
@@ -1024,7 +1024,7 @@ All other trademarks are the property of their respective owners.
1024
1024
 
1025
1025
  >The [`MIT`][license-url] License (MIT)
1026
1026
  >
1027
- >Copyright © 2014-2021 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com).
1027
+ >Copyright © 2014-2022 Sebastian Hildebrandt, [+innovations](http://www.plus-innovations.com).
1028
1028
  >
1029
1029
  >Permission is hereby granted, free of charge, to any person obtaining a copy
1030
1030
  >of this software and associated documentation files (the "Software"), to deal
package/lib/battery.js CHANGED
@@ -230,7 +230,7 @@ module.exports = function (callback) {
230
230
  workload.push(util.powerShell('(Get-WmiObject -Class BatteryFullChargedCapacity -Namespace ROOT/WMI).FullChargedCapacity'));
231
231
  util.promiseAll(
232
232
  workload
233
- ).then(data => {
233
+ ).then((data) => {
234
234
  if (data) {
235
235
  let parts = data.results[0].split(/\n\s*\n/);
236
236
  let batteries = [];
package/lib/bluetooth.js CHANGED
@@ -37,6 +37,25 @@ function parseBluetoothType(str) {
37
37
  if (str.indexOf('speaker') >= 0) { result = 'Speaker'; }
38
38
  if (str.indexOf('headset') >= 0) { result = 'Headset'; }
39
39
  if (str.indexOf('phone') >= 0) { result = 'Phone'; }
40
+ if (str.indexOf('macbook') >= 0) { result = 'Computer'; }
41
+ if (str.indexOf('imac') >= 0) { result = 'Computer'; }
42
+ if (str.indexOf('ipad') >= 0) { result = 'Tablet'; }
43
+ if (str.indexOf('watch') >= 0) { result = 'Watch'; }
44
+ if (str.indexOf('headphone') >= 0) { result = 'Headset'; }
45
+ // to be continued ...
46
+
47
+ return result;
48
+ }
49
+
50
+ function parseBluetoothManufacturer(str) {
51
+ let result = str.split(' ')[0];
52
+ str = str.toLowerCase();
53
+ if (str.indexOf('apple') >= 0) { result = 'Apple'; }
54
+ if (str.indexOf('ipad') >= 0) { result = 'Apple'; }
55
+ if (str.indexOf('imac') >= 0) { result = 'Apple'; }
56
+ if (str.indexOf('iphone') >= 0) { result = 'Apple'; }
57
+ if (str.indexOf('magic mouse') >= 0) { result = 'Apple'; }
58
+ if (str.indexOf('macbook') >= 0) { result = 'Apple'; }
40
59
  // to be continued ...
41
60
 
42
61
  return result;
@@ -59,12 +78,12 @@ function parseLinuxBluetoothInfo(lines, macAddr1, macAddr2) {
59
78
 
60
79
  function parseDarwinBluetoothDevices(bluetoothObject, macAddr2) {
61
80
  const result = {};
62
- const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || '') + (bluetoothObject.device_name || '')).toLowerCase();
81
+ const typeStr = ((bluetoothObject.device_minorClassOfDevice_string || bluetoothObject.device_majorClassOfDevice_string || bluetoothObject.device_minorType || '') + (bluetoothObject.device_name || '')).toLowerCase();
63
82
 
64
83
  result.device = bluetoothObject.device_services || '';
65
84
  result.name = bluetoothObject.device_name || '';
66
- result.manufacturer = bluetoothObject.device_manufacturer || '';
67
- result.macDevice = (bluetoothObject.device_addr || '').toLowerCase().replace(/-/g, ':');
85
+ result.manufacturer = bluetoothObject.device_manufacturer || parseBluetoothManufacturer(bluetoothObject.device_name || '') || '';
86
+ result.macDevice = (bluetoothObject.device_addr || bluetoothObject.device_address || '').toLowerCase().replace(/-/g, ':');
68
87
  result.macHost = macAddr2;
69
88
  result.batteryPercent = bluetoothObject.device_batteryPercent || null;
70
89
  result.type = parseBluetoothType(typeStr);
@@ -96,16 +115,16 @@ function bluetoothDevices(callback) {
96
115
  if (_linux) {
97
116
  // get files in /var/lib/bluetooth/ recursive
98
117
  const btFiles = util.getFilesInPath('/var/lib/bluetooth/');
99
- for (let i = 0; i < btFiles.length; i++) {
100
- const filename = path.basename(btFiles[i]);
101
- const pathParts = btFiles[i].split('/');
118
+ btFiles.forEach((element) => {
119
+ const filename = path.basename(element);
120
+ const pathParts = element.split('/');
102
121
  const macAddr1 = pathParts.length >= 6 ? pathParts[pathParts.length - 2] : null;
103
122
  const macAddr2 = pathParts.length >= 7 ? pathParts[pathParts.length - 3] : null;
104
123
  if (filename === 'info') {
105
- const infoFile = fs.readFileSync(btFiles[i], { encoding: 'utf8' }).split('\n');
124
+ const infoFile = fs.readFileSync(element, { encoding: 'utf8' }).split('\n');
106
125
  result.push(parseLinuxBluetoothInfo(infoFile, macAddr1, macAddr2));
107
126
  }
108
- }
127
+ });
109
128
  // determine "connected" with hcitool con
110
129
  try {
111
130
  const hdicon = execSync('hcitool con').toString().toLowerCase();
@@ -135,9 +154,8 @@ function bluetoothDevices(callback) {
135
154
  if (outObj.SPBluetoothDataType[0]['local_device_title'] && outObj.SPBluetoothDataType[0].local_device_title.general_address) {
136
155
  macAddr2 = outObj.SPBluetoothDataType[0].local_device_title.general_address.toLowerCase().replace(/-/g, ':');
137
156
  }
138
-
139
- for (let i = 0; i < outObj.SPBluetoothDataType[0]['device_title'].length; i++) {
140
- const obj = outObj.SPBluetoothDataType[0]['device_title'][i];
157
+ outObj.SPBluetoothDataType[0]['device_title'].forEach((element) => {
158
+ const obj = element;
141
159
  const objKey = Object.keys(obj);
142
160
  if (objKey && objKey.length === 1) {
143
161
  const innerObject = obj[objKey[0]];
@@ -145,7 +163,35 @@ function bluetoothDevices(callback) {
145
163
  const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
146
164
  result.push(bluetoothDevice);
147
165
  }
148
- }
166
+ });
167
+ }
168
+ if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_connected'] && outObj.SPBluetoothDataType[0]['device_connected'].length) {
169
+ const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
170
+ outObj.SPBluetoothDataType[0]['device_connected'].forEach((element) => {
171
+ const obj = element;
172
+ const objKey = Object.keys(obj);
173
+ if (objKey && objKey.length === 1) {
174
+ const innerObject = obj[objKey[0]];
175
+ innerObject.device_name = objKey[0];
176
+ innerObject.device_isconnected = 'attrib_Yes';
177
+ const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
178
+ result.push(bluetoothDevice);
179
+ }
180
+ });
181
+ }
182
+ if (outObj.SPBluetoothDataType && outObj.SPBluetoothDataType.length && outObj.SPBluetoothDataType[0] && outObj.SPBluetoothDataType[0]['device_not_connected'] && outObj.SPBluetoothDataType[0]['device_not_connected'].length) {
183
+ const macAddr2 = outObj.SPBluetoothDataType[0].controller_properties && outObj.SPBluetoothDataType[0].controller_properties.controller_address ? outObj.SPBluetoothDataType[0].controller_properties.controller_address.toLowerCase().replace(/-/g, ':') : null;
184
+ outObj.SPBluetoothDataType[0]['device_not_connected'].forEach((element) => {
185
+ const obj = element;
186
+ const objKey = Object.keys(obj);
187
+ if (objKey && objKey.length === 1) {
188
+ const innerObject = obj[objKey[0]];
189
+ innerObject.device_name = objKey[0];
190
+ innerObject.device_isconnected = 'attrib_No';
191
+ const bluetoothDevice = parseDarwinBluetoothDevices(innerObject, macAddr2);
192
+ result.push(bluetoothDevice);
193
+ }
194
+ });
149
195
  }
150
196
  } catch (e) {
151
197
  util.noop();
@@ -161,11 +207,11 @@ function bluetoothDevices(callback) {
161
207
  util.powerShell('Get-WmiObject Win32_PNPEntity | select PNPClass, Name, Manufacturer | fl').then((stdout, error) => {
162
208
  if (!error) {
163
209
  const parts = stdout.toString().split(/\n\s*\n/);
164
- for (let i = 0; i < parts.length; i++) {
165
- if (util.getValue(parts[i].split('\n'), 'PNPClass', ':') === 'Bluetooth') {
166
- result.push(parseWindowsBluetooth(parts[i].split('\n')));
210
+ parts.forEach((part) => {
211
+ if (util.getValue(part.split('\n'), 'PNPClass', ':') === 'Bluetooth') {
212
+ result.push(parseWindowsBluetooth(part.split('\n')));
167
213
  }
168
- }
214
+ });
169
215
  }
170
216
  if (callback) {
171
217
  callback(result);
package/lib/cli.js CHANGED
@@ -23,7 +23,7 @@ const si = require('./index');
23
23
  // ----------------------------------------------------------------------------------
24
24
  (function () {
25
25
  si.getStaticData().then(
26
- (data => {
26
+ ((data) => {
27
27
  data.time = si.time();
28
28
  console.log(JSON.stringify(data, null, 2));
29
29
  }
package/lib/cpu.js CHANGED
@@ -656,7 +656,7 @@ function getCpu() {
656
656
  result.cores = parseInt(countThreads) || util.cores();
657
657
  result.physicalCores = parseInt(countCores) || util.cores();
658
658
  }
659
- cpuCache().then(res => {
659
+ cpuCache().then((res) => {
660
660
  result.cache = res;
661
661
  resolve(result);
662
662
  });
@@ -816,7 +816,7 @@ function getCpu() {
816
816
 
817
817
  Promise.all(
818
818
  workload
819
- ).then(data => {
819
+ ).then((data) => {
820
820
  let lines = data[0].split('\r\n');
821
821
  let name = util.getValue(lines, 'name', ':') || '';
822
822
  if (name.indexOf('@') >= 0) {
package/lib/docker.js CHANGED
@@ -35,7 +35,7 @@ function dockerInfo(callback) {
35
35
  }
36
36
  const result = {};
37
37
 
38
- _docker_socket.getInfo(data => {
38
+ _docker_socket.getInfo((data) => {
39
39
  result.id = data.ID;
40
40
  result.containers = data.Containers;
41
41
  result.containersRunning = data.ContainersRunning;
@@ -130,7 +130,7 @@ function dockerImages(all, callback) {
130
130
  if (workload.length) {
131
131
  Promise.all(
132
132
  workload
133
- ).then(data => {
133
+ ).then((data) => {
134
134
  if (callback) { callback(data); }
135
135
  resolve(data);
136
136
  });
@@ -255,24 +255,11 @@ function dockerContainers(all, callback) {
255
255
  element.Name = element.Names[0].replace(/^\/|\/$/g, '');
256
256
  }
257
257
  workload.push(dockerContainerInspect(element.Id.trim(), element));
258
- // result.push({
259
- // id: element.Id,
260
- // name: element.Name,
261
- // image: element.Image,
262
- // imageID: element.ImageID,
263
- // command: element.Command,
264
- // created: element.Created,
265
- // state: element.State,
266
- // ports: element.Ports,
267
- // mounts: element.Mounts,
268
- // // hostconfig: element.HostConfig,
269
- // // network: element.NetworkSettings
270
- // });
271
258
  });
272
259
  if (workload.length) {
273
260
  Promise.all(
274
261
  workload
275
- ).then(data => {
262
+ ).then((data) => {
276
263
  if (callback) { callback(data); }
277
264
  resolve(data);
278
265
  });
@@ -511,7 +498,7 @@ function dockerContainerStats(containerIDs, callback) {
511
498
  if (workload.length) {
512
499
  Promise.all(
513
500
  workload
514
- ).then(data => {
501
+ ).then((data) => {
515
502
  if (callback) { callback(data); }
516
503
  resolve(data);
517
504
  });
@@ -685,7 +672,7 @@ function dockerVolumes(callback) {
685
672
  if (!_docker_socket) {
686
673
  _docker_socket = new DockerSocket();
687
674
  }
688
- _docker_socket.listVolumes(data => {
675
+ _docker_socket.listVolumes((data) => {
689
676
  let dockerVolumes = {};
690
677
  try {
691
678
  dockerVolumes = data;
@@ -726,7 +713,7 @@ function dockerAll(callback) {
726
713
  if (result && Object.prototype.toString.call(result) === '[object Array]' && result.length > 0) {
727
714
  let l = result.length;
728
715
  result.forEach(function (element) {
729
- dockerContainerStats(element.id).then(res => {
716
+ dockerContainerStats(element.id).then((res) => {
730
717
  // include stats in array
731
718
  element.memUsage = res[0].memUsage;
732
719
  element.memLimit = res[0].memLimit;
package/lib/filesystem.js CHANGED
@@ -53,7 +53,7 @@ function fsSize(callback) {
53
53
  const linuxTmpFileSystems = ['rootfs', 'unionfs', 'squashfs', 'cramfs', 'initrd', 'initramfs', 'devtmpfs', 'tmpfs', 'udev', 'devfs', 'specfs', 'type', 'appimaged'];
54
54
  let result = false;
55
55
  linuxTmpFileSystems.forEach(linuxFs => {
56
- if (fs.toLowerCase().indexOf(linuxFs) >= 0) result = true;
56
+ if (fs.toLowerCase().indexOf(linuxFs) >= 0) { result = true; }
57
57
  });
58
58
  return result;
59
59
  }
@@ -1209,7 +1209,7 @@ function diskLayout(callback) {
1209
1209
  }
1210
1210
  util.promiseAll(
1211
1211
  workload
1212
- ).then(data => {
1212
+ ).then((data) => {
1213
1213
  let devices = data.results[0].toString().split(/\n\s*\n/);
1214
1214
  devices.forEach(function (device) {
1215
1215
  let lines = device.split('\r\n');
package/lib/graphics.js CHANGED
@@ -784,7 +784,7 @@ function graphics(callback) {
784
784
 
785
785
  Promise.all(
786
786
  workload
787
- ).then(data => {
787
+ ).then((data) => {
788
788
  // controller + vram
789
789
  let csections = data[0].replace(/\r/g, '').split(/\n\s*\n/);
790
790
  let vsections = data[1].replace(/\r/g, '').split(/\n\s*\n/);
package/lib/index.d.ts CHANGED
@@ -156,16 +156,16 @@ export namespace Systeminformation {
156
156
  type: string;
157
157
  protocol: string;
158
158
  };
159
- model_family?: string,
160
- model_name?: string,
161
- serial_number?: string,
162
- firmware_version?: string,
159
+ model_family?: string;
160
+ model_name?: string;
161
+ serial_number?: string;
162
+ firmware_version?: string;
163
163
  smart_status: {
164
164
  passed: boolean;
165
165
  };
166
166
  trim?: {
167
167
  supported: boolean;
168
- },
168
+ };
169
169
  ata_smart_attributes?: {
170
170
  revision: number;
171
171
  table: {
@@ -185,7 +185,10 @@ export namespace Systeminformation {
185
185
  event_count: boolean;
186
186
  auto_keep: boolean;
187
187
  };
188
- raw: { value: number; string: string; };
188
+ raw: {
189
+ value: number;
190
+ string: string;
191
+ };
189
192
  }[];
190
193
  };
191
194
  ata_smart_error_log?: {
@@ -201,12 +204,12 @@ export namespace Systeminformation {
201
204
  type: {
202
205
  value: number;
203
206
  string: string;
204
- },
207
+ };
205
208
  status: {
206
209
  value: number;
207
210
  string: string;
208
211
  passed: boolean;
209
- },
212
+ };
210
213
  lifetime_hours: number;
211
214
  }[];
212
215
  count: number;
@@ -215,34 +218,34 @@ export namespace Systeminformation {
215
218
  };
216
219
  };
217
220
  nvme_pci_vendor?: {
218
- id: number,
221
+ id: number;
219
222
  subsystem_id: number;
220
223
  },
221
224
  nvme_smart_health_information_log?: {
222
- critical_warning?: number,
223
- temperature?: number,
224
- available_spare?: number,
225
- available_spare_threshold?: number,
226
- percentage_used?: number,
227
- data_units_read?: number,
228
- data_units_written?: number,
229
- host_reads?: number,
230
- host_writes?: number,
231
- controller_busy_time?: number,
232
- power_cycles?: number,
233
- power_on_hours?: number,
234
- unsafe_shutdowns?: number,
235
- media_errors?: number,
236
- num_err_log_entries?: number,
237
- warning_temp_time?: number,
238
- critical_comp_time?: number,
225
+ critical_warning?: number;
226
+ temperature?: number;
227
+ available_spare?: number;
228
+ available_spare_threshold?: number;
229
+ percentage_used?: number;
230
+ data_units_read?: number;
231
+ data_units_written?: number;
232
+ host_reads?: number;
233
+ host_writes?: number;
234
+ controller_busy_time?: number;
235
+ power_cycles?: number;
236
+ power_on_hours?: number;
237
+ unsafe_shutdowns?: number;
238
+ media_errors?: number;
239
+ num_err_log_entries?: number;
240
+ warning_temp_time?: number;
241
+ critical_comp_time?: number;
239
242
  temperature_sensors?: number[];
240
243
  },
241
244
  user_capacity?: {
242
- blocks: number,
245
+ blocks: number;
243
246
  bytes: number;
244
247
  },
245
- logical_block_size?: number,
248
+ logical_block_size?: number;
246
249
  temperature: {
247
250
  current: number;
248
251
  };
@@ -283,7 +286,7 @@ export namespace Systeminformation {
283
286
  currentCapacity: number;
284
287
  capacityUnit: string;
285
288
  percent: number;
286
- timeRemaining: number,
289
+ timeRemaining: number;
287
290
  acConnected: boolean;
288
291
  type: string;
289
292
  model: string;
@@ -618,7 +621,7 @@ export namespace Systeminformation {
618
621
  interface ProcessesProcessData {
619
622
  pid: number;
620
623
  parentPid: number;
621
- name: string,
624
+ name: string;
622
625
  cpu: number;
623
626
  cpuu: number;
624
627
  cpus: number;
@@ -627,7 +630,7 @@ export namespace Systeminformation {
627
630
  memVsz: number;
628
631
  memRss: number;
629
632
  nice: number;
630
- started: string,
633
+ started: string;
631
634
  state: string;
632
635
  tty: string;
633
636
  user: string;
@@ -772,7 +775,7 @@ export namespace Systeminformation {
772
775
  restartCount: number;
773
776
  cpuStats: any;
774
777
  precpuStats: any;
775
- memoryStats: any,
778
+ memoryStats: any;
776
779
  networks: any;
777
780
  }
778
781
 
package/lib/index.js CHANGED
@@ -95,7 +95,7 @@ function getStaticData(callback) {
95
95
  network.networkInterfaces(),
96
96
  memory.memLayout(),
97
97
  filesystem.diskLayout()
98
- ]).then(res => {
98
+ ]).then((res) => {
99
99
  data.system = res[0];
100
100
  data.bios = res[1];
101
101
  data.baseboard = res[2];
@@ -181,95 +181,95 @@ function getDynamicData(srv, iface, callback) {
181
181
  data.node = process.versions.node;
182
182
  data.v8 = process.versions.v8;
183
183
 
184
- cpu.cpuCurrentSpeed().then(res => {
184
+ cpu.cpuCurrentSpeed().then((res) => {
185
185
  data.cpuCurrentSpeed = res;
186
186
  functionProcessed();
187
187
  });
188
188
 
189
- users.users().then(res => {
189
+ users.users().then((res) => {
190
190
  data.users = res;
191
191
  functionProcessed();
192
192
  });
193
193
 
194
- processes.processes().then(res => {
194
+ processes.processes().then((res) => {
195
195
  data.processes = res;
196
196
  functionProcessed();
197
197
  });
198
198
 
199
- cpu.currentLoad().then(res => {
199
+ cpu.currentLoad().then((res) => {
200
200
  data.currentLoad = res;
201
201
  functionProcessed();
202
202
  });
203
203
 
204
204
  if (!_sunos) {
205
- cpu.cpuTemperature().then(res => {
205
+ cpu.cpuTemperature().then((res) => {
206
206
  data.temp = res;
207
207
  functionProcessed();
208
208
  });
209
209
  }
210
210
 
211
211
  if (!_openbsd && !_freebsd && !_netbsd && !_sunos) {
212
- network.networkStats(iface).then(res => {
212
+ network.networkStats(iface).then((res) => {
213
213
  data.networkStats = res;
214
214
  functionProcessed();
215
215
  });
216
216
  }
217
217
 
218
218
  if (!_sunos) {
219
- network.networkConnections().then(res => {
219
+ network.networkConnections().then((res) => {
220
220
  data.networkConnections = res;
221
221
  functionProcessed();
222
222
  });
223
223
  }
224
224
 
225
- memory.mem().then(res => {
225
+ memory.mem().then((res) => {
226
226
  data.mem = res;
227
227
  functionProcessed();
228
228
  });
229
229
 
230
230
  if (!_sunos) {
231
- battery().then(res => {
231
+ battery().then((res) => {
232
232
  data.battery = res;
233
233
  functionProcessed();
234
234
  });
235
235
  }
236
236
 
237
237
  if (!_sunos) {
238
- processes.services(srv).then(res => {
238
+ processes.services(srv).then((res) => {
239
239
  data.services = res;
240
240
  functionProcessed();
241
241
  });
242
242
  }
243
243
 
244
244
  if (!_sunos) {
245
- filesystem.fsSize().then(res => {
245
+ filesystem.fsSize().then((res) => {
246
246
  data.fsSize = res;
247
247
  functionProcessed();
248
248
  });
249
249
  }
250
250
 
251
251
  if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) {
252
- filesystem.fsStats().then(res => {
252
+ filesystem.fsStats().then((res) => {
253
253
  data.fsStats = res;
254
254
  functionProcessed();
255
255
  });
256
256
  }
257
257
 
258
258
  if (!_windows && !_openbsd && !_freebsd && !_netbsd && !_sunos) {
259
- filesystem.disksIO().then(res => {
259
+ filesystem.disksIO().then((res) => {
260
260
  data.disksIO = res;
261
261
  functionProcessed();
262
262
  });
263
263
  }
264
264
 
265
265
  if (!_openbsd && !_freebsd && !_netbsd && !_sunos) {
266
- wifi.wifiNetworks().then(res => {
266
+ wifi.wifiNetworks().then((res) => {
267
267
  data.wifiNetworks = res;
268
268
  functionProcessed();
269
269
  });
270
270
  }
271
271
 
272
- internet.inetLatency().then(res => {
272
+ internet.inetLatency().then((res) => {
273
273
  data.inetLatency = res;
274
274
  functionProcessed();
275
275
  });
@@ -301,9 +301,9 @@ function getAllData(srv, iface, callback) {
301
301
  iface = '';
302
302
  }
303
303
 
304
- getStaticData().then(res => {
304
+ getStaticData().then((res) => {
305
305
  data = res;
306
- getDynamicData(srv, iface).then(res => {
306
+ getDynamicData(srv, iface).then((res) => {
307
307
  for (let key in res) {
308
308
  if ({}.hasOwnProperty.call(res, key)) {
309
309
  data[key] = res[key];
@@ -333,7 +333,7 @@ function get(valueObject, callback) {
333
333
  }
334
334
  });
335
335
 
336
- Promise.all(allPromises).then(data => {
336
+ Promise.all(allPromises).then((data) => {
337
337
  const result = {};
338
338
  let i = 0;
339
339
  for (let key in valueObject) {
@@ -419,7 +419,7 @@ function observe(valueObject, interval, callback) {
419
419
  let _data = null;
420
420
 
421
421
  const result = setInterval(() => {
422
- get(valueObject).then(data => {
422
+ get(valueObject).then((data) => {
423
423
  if (JSON.stringify(_data) !== JSON.stringify(data)) {
424
424
  _data = Object.assign({}, data);
425
425
  callback(data);
package/lib/network.js CHANGED
@@ -250,7 +250,7 @@ function getWindowsNics() {
250
250
  let cmd = 'Get-WmiObject Win32_NetworkAdapter | fl *' + '; echo \'#-#-#-#\';';
251
251
  cmd += 'Get-WmiObject Win32_NetworkAdapterConfiguration | fl DHCPEnabled' + '';
252
252
  try {
253
- util.powerShell(cmd).then(data => {
253
+ util.powerShell(cmd).then((data) => {
254
254
  data = data.split('#-#-#-#');
255
255
  const nsections = (data[0] || '').split(/\n\s*\n/);
256
256
  const nconfigsections = (data[1] || '').split(/\n\s*\n/);
@@ -1161,7 +1161,7 @@ function networkStats(ifaces, callback) {
1161
1161
  if (workload.length) {
1162
1162
  Promise.all(
1163
1163
  workload
1164
- ).then(data => {
1164
+ ).then((data) => {
1165
1165
  if (callback) { callback(data); }
1166
1166
  resolve(data);
1167
1167
  });
@@ -1183,7 +1183,7 @@ function networkStatsSingle(iface) {
1183
1183
  if (sections[i].trim() !== '') {
1184
1184
  let lines = sections[i].trim().split('\r\n');
1185
1185
  perfData.push({
1186
- name: util.getValue(lines, 'Name', ':').replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase(),
1186
+ name: util.getValue(lines, 'Name', ':').replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase(),
1187
1187
  rx_bytes: parseInt(util.getValue(lines, 'BytesReceivedPersec', ':'), 10),
1188
1188
  rx_errors: parseInt(util.getValue(lines, 'PacketsReceivedErrors', ':'), 10),
1189
1189
  rx_dropped: parseInt(util.getValue(lines, 'PacketsReceivedDiscarded', ':'), 10),
@@ -1202,7 +1202,7 @@ function networkStatsSingle(iface) {
1202
1202
  let ifaceSanitized = '';
1203
1203
  const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
1204
1204
  for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
1205
- if (!(s[i] === undefined)) {
1205
+ if (s[i] !== undefined) {
1206
1206
  ifaceSanitized = ifaceSanitized + s[i];
1207
1207
  }
1208
1208
  }
@@ -1334,8 +1334,8 @@ function networkStatsSingle(iface) {
1334
1334
  det.mac.toLowerCase() === ifaceSanitized.toLowerCase() ||
1335
1335
  det.ip4.toLowerCase() === ifaceSanitized.toLowerCase() ||
1336
1336
  det.ip6.toLowerCase() === ifaceSanitized.toLowerCase() ||
1337
- det.ifaceName.replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase() === ifaceSanitized.replace(/[()[\] ]+/g, '').replace('#', '_').toLowerCase()) &&
1338
- (det.ifaceName.replace(/[()[\] ]+/g, '').replace(/\#|\//g, '_').toLowerCase() === detail.name)) {
1337
+ det.ifaceName.replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase() === ifaceSanitized.replace(/[()[\] ]+/g, '').replace('#', '_').toLowerCase()) &&
1338
+ (det.ifaceName.replace(/[()[\] ]+/g, '').replace(/#|\//g, '_').toLowerCase() === detail.name)) {
1339
1339
  ifaceName = det.iface;
1340
1340
  rx_bytes = detail.rx_bytes;
1341
1341
  rx_dropped = detail.rx_dropped;
@@ -1693,7 +1693,7 @@ function networkGatewayDefault(callback) {
1693
1693
  });
1694
1694
  if (!result) {
1695
1695
  util.powerShell('Get-CimInstance -ClassName Win32_IP4RouteTable | Where-Object { $_.Destination -eq \'0.0.0.0\' -and $_.Mask -eq \'0.0.0.0\' }')
1696
- .then(data => {
1696
+ .then((data) => {
1697
1697
  let lines = data.toString().split('\r\n');
1698
1698
  if (lines.length > 1 && !result) {
1699
1699
  result = util.getValue(lines, 'NextHop');
package/lib/osinfo.js CHANGED
@@ -250,7 +250,7 @@ function osInfo(callback) {
250
250
  result.build = (release.BUILD_ID || '').replace(/"/g, '').trim();
251
251
  isUefiLinux().then(uefi => {
252
252
  result.uefi = uefi;
253
- uuid().then(data => {
253
+ uuid().then((data) => {
254
254
  result.serial = data.os;
255
255
  if (callback) {
256
256
  callback(result);
@@ -333,7 +333,7 @@ function osInfo(callback) {
333
333
  workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
334
334
  util.promiseAll(
335
335
  workload
336
- ).then(data => {
336
+ ).then((data) => {
337
337
  let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
338
338
  result.distro = util.getValue(lines, 'Caption', ':').trim();
339
339
  result.serial = util.getValue(lines, 'SerialNumber', ':').trim();
package/lib/processes.js CHANGED
@@ -253,8 +253,8 @@ function services(srv, callback) {
253
253
  // process
254
254
  let list_new = {};
255
255
  let resultProcess = {};
256
- for (let i = 0; i < curr_processes.length; i++) {
257
- resultProcess = calcProcStatLinux(curr_processes[i], all, _services_cpu);
256
+ curr_processes.forEach((element) => {
257
+ resultProcess = calcProcStatLinux(element, all, _services_cpu);
258
258
 
259
259
  if (resultProcess.pid) {
260
260
  let listPos = -1;
@@ -279,7 +279,7 @@ function services(srv, callback) {
279
279
  cstime: resultProcess.cstime
280
280
  };
281
281
  }
282
- }
282
+ });
283
283
 
284
284
  // store old values
285
285
  _services_cpu.all = all;
@@ -338,18 +338,18 @@ function services(srv, callback) {
338
338
  let wincommand = 'Get-WmiObject Win32_Service';
339
339
  if (srvs[0] !== '*') {
340
340
  wincommand += ' -Filter "';
341
- for (let i = 0; i < srvs.length; i++) {
342
- wincommand += `Name='${srvs[i]}' or `;
343
- }
341
+ srvs.forEach((srv) => {
342
+ wincommand += `Name='${srv}' or `;
343
+ });
344
344
  wincommand = `${wincommand.slice(0, -4)}"`;
345
345
  }
346
346
  wincommand += ' | select Name,Caption,Started,StartMode,ProcessId | fl';
347
347
  util.powerShell(wincommand).then((stdout, error) => {
348
348
  if (!error) {
349
349
  let serviceSections = stdout.split(/\n\s*\n/);
350
- for (let i = 0; i < serviceSections.length; i++) {
351
- if (serviceSections[i].trim() !== '') {
352
- let lines = serviceSections[i].trim().split('\r\n');
350
+ serviceSections.forEach((element) => {
351
+ if (element.trim() !== '') {
352
+ let lines = element.trim().split('\r\n');
353
353
  let srvName = util.getValue(lines, 'Name', ':', true).toLowerCase();
354
354
  let srvCaption = util.getValue(lines, 'Caption', ':', true).toLowerCase();
355
355
  let started = util.getValue(lines, 'Started', ':', true);
@@ -368,7 +368,9 @@ function services(srv, callback) {
368
368
  dataSrv.push(srvCaption);
369
369
  }
370
370
  }
371
- }
371
+
372
+ });
373
+
372
374
  if (srvString !== '*') {
373
375
  let srvsMissing = srvs.filter(function (e) {
374
376
  return dataSrv.indexOf(e) === -1;
@@ -740,9 +742,9 @@ function processes(callback) {
740
742
  if (_linux) {
741
743
  // calc process_cpu - ps is not accurate in linux!
742
744
  cmd = 'cat /proc/stat | grep "cpu "';
743
- for (let i = 0; i < result.list.length; i++) {
744
- cmd += (';cat /proc/' + result.list[i].pid + '/stat');
745
- }
745
+ result.list.forEach((element) => {
746
+ cmd += (';cat /proc/' + element.pid + '/stat');
747
+ });
746
748
  exec(cmd, { maxBuffer: 1024 * 20000 }, function (error, stdout) {
747
749
  let curr_processes = stdout.toString().split('\n');
748
750
 
@@ -752,8 +754,8 @@ function processes(callback) {
752
754
  // process
753
755
  let list_new = {};
754
756
  let resultProcess = {};
755
- for (let i = 0; i < curr_processes.length; i++) {
756
- resultProcess = calcProcStatLinux(curr_processes[i], all, _processes_cpu);
757
+ curr_processes.forEach((element) => {
758
+ resultProcess = calcProcStatLinux(element, all, _processes_cpu);
757
759
 
758
760
  if (resultProcess.pid) {
759
761
 
@@ -775,7 +777,7 @@ function processes(callback) {
775
777
  cstime: resultProcess.cstime
776
778
  };
777
779
  }
778
- }
780
+ });
779
781
 
780
782
  // store old values
781
783
  _processes_cpu.all = all;
@@ -829,9 +831,9 @@ function processes(callback) {
829
831
  let list_new = {};
830
832
  let allcpuu = 0;
831
833
  let allcpus = 0;
832
- for (let i = 0; i < processSections.length; i++) {
833
- if (processSections[i].trim() !== '') {
834
- let lines = processSections[i].trim().split('\r\n');
834
+ processSections.forEach((element) => {
835
+ if (element.trim() !== '') {
836
+ let lines = element.trim().split('\r\n');
835
837
  let pid = parseInt(util.getValue(lines, 'ProcessId', ':', true), 10);
836
838
  let parentPid = parseInt(util.getValue(lines, 'ParentProcessId', ':', true), 10);
837
839
  let statusValue = util.getValue(lines, 'ExecutionState', ':');
@@ -889,11 +891,12 @@ function processes(callback) {
889
891
  params: ''
890
892
  });
891
893
  }
892
- }
894
+ });
895
+
893
896
  result.sleeping = result.all - result.running - result.blocked - result.unknown;
894
897
  result.list = procs;
895
- for (let i = 0; i < procStats.length; i++) {
896
- let resultProcess = calcProcStatWin(procStats[i], allcpuu + allcpus, _processes_cpu);
898
+ procStats.forEach((element) => {
899
+ let resultProcess = calcProcStatWin(element, allcpuu + allcpus, _processes_cpu);
897
900
 
898
901
  // store pcpu in outer array
899
902
  let listPos = result.list.map(function (e) { return e.pid; }).indexOf(resultProcess.pid);
@@ -910,7 +913,8 @@ function processes(callback) {
910
913
  utime: resultProcess.utime,
911
914
  stime: resultProcess.stime
912
915
  };
913
- }
916
+ });
917
+
914
918
  // store old values
915
919
  _processes_cpu.all = allcpuu + allcpus;
916
920
  _processes_cpu.all_utime = allcpuu;
@@ -972,7 +976,7 @@ function processLoad(proc, callback) {
972
976
 
973
977
  const s = util.sanitizeShellString(proc);
974
978
  for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
975
- if (!(s[i] === undefined)) {
979
+ if (s[i] !== undefined) {
976
980
  processesString = processesString + s[i];
977
981
  }
978
982
  }
@@ -1008,9 +1012,9 @@ function processLoad(proc, callback) {
1008
1012
  let allcpus = 0;
1009
1013
 
1010
1014
  // go through all processes
1011
- for (let i = 0; i < processSections.length; i++) {
1012
- if (processSections[i].trim() !== '') {
1013
- let lines = processSections[i].trim().split('\r\n');
1015
+ processSections.forEach((element) => {
1016
+ if (element.trim() !== '') {
1017
+ let lines = element.trim().split('\r\n');
1014
1018
  let pid = parseInt(util.getValue(lines, 'ProcessId', ':', true), 10);
1015
1019
  let name = util.getValue(lines, 'Caption', ':', true);
1016
1020
  let utime = parseInt(util.getValue(lines, 'UserModeTime', ':', true), 10);
@@ -1058,7 +1062,8 @@ function processLoad(proc, callback) {
1058
1062
  }
1059
1063
  }
1060
1064
  }
1061
- }
1065
+ });
1066
+
1062
1067
  // add missing processes
1063
1068
  if (processesString !== '*') {
1064
1069
  let processesMissing = processes.filter(function (name) {
@@ -1077,8 +1082,8 @@ function processLoad(proc, callback) {
1077
1082
  }
1078
1083
 
1079
1084
  // calculate proc stats for each proc
1080
- for (let i = 0; i < procStats.length; i++) {
1081
- let resultProcess = calcProcStatWin(procStats[i], allcpuu + allcpus, _process_cpu);
1085
+ procStats.forEach((element) => {
1086
+ let resultProcess = calcProcStatWin(element, allcpuu + allcpus, _process_cpu);
1082
1087
 
1083
1088
  let listPos = -1;
1084
1089
  for (let j = 0; j < result.length; j++) {
@@ -1095,7 +1100,8 @@ function processLoad(proc, callback) {
1095
1100
  utime: resultProcess.utime,
1096
1101
  stime: resultProcess.stime
1097
1102
  };
1098
- }
1103
+ });
1104
+
1099
1105
  // store old values
1100
1106
  _process_cpu.all = allcpuu + allcpus;
1101
1107
  _process_cpu.all_utime = allcpuu;
@@ -1210,9 +1216,8 @@ function processLoad(proc, callback) {
1210
1216
  // process
1211
1217
  let list_new = {};
1212
1218
  let resultProcess = {};
1213
-
1214
- for (let i = 0; i < curr_processes.length; i++) {
1215
- resultProcess = calcProcStatLinux(curr_processes[i], all, _process_cpu);
1219
+ curr_processes.forEach((element) => {
1220
+ resultProcess = calcProcStatLinux(element, all, _process_cpu);
1216
1221
 
1217
1222
  if (resultProcess.pid) {
1218
1223
 
@@ -1238,7 +1243,7 @@ function processLoad(proc, callback) {
1238
1243
  cstime: resultProcess.cstime
1239
1244
  };
1240
1245
  }
1241
- }
1246
+ });
1242
1247
 
1243
1248
  result.forEach(function (item) {
1244
1249
  item.cpu = Math.round(item.cpu * 100) / 100;
package/lib/system.js CHANGED
@@ -571,7 +571,7 @@ function baseboard(callback) {
571
571
  workload.push(execPromise('export LC_ALL=C; dmidecode -t memory 2>/dev/null'));
572
572
  util.promiseAll(
573
573
  workload
574
- ).then(data => {
574
+ ).then((data) => {
575
575
  let lines = data.results[0] ? data.results[0].toString().split('\n') : [''];
576
576
  result.manufacturer = util.getValue(lines, 'Manufacturer');
577
577
  result.model = util.getValue(lines, 'Product Name');
@@ -630,7 +630,7 @@ function baseboard(callback) {
630
630
  workload.push(execPromise('system_profiler SPMemoryDataType'));
631
631
  util.promiseAll(
632
632
  workload
633
- ).then(data => {
633
+ ).then((data) => {
634
634
  let lines = data.results[0] ? data.results[0].toString().replace(/[<>"]/g, '').split('\n') : [''];
635
635
  result.manufacturer = util.getValue(lines, 'manufacturer', '=', true);
636
636
  result.model = util.getValue(lines, 'model', '=', true);
@@ -668,7 +668,7 @@ function baseboard(callback) {
668
668
  workload.push(util.powerShell(`Get-WmiObject Win32_physicalmemoryarray | select ${maxCapacityAttribute}, MemoryDevices | fl`));
669
669
  util.promiseAll(
670
670
  workload
671
- ).then(data => {
671
+ ).then((data) => {
672
672
  let lines = data.results[0] ? data.results[0].toString().split('\r\n') : [''];
673
673
 
674
674
  result.manufacturer = util.getValue(lines, 'manufacturer', ':');
package/lib/usb.js CHANGED
@@ -14,9 +14,7 @@
14
14
  // ----------------------------------------------------------------------------------
15
15
 
16
16
  const exec = require('child_process').exec;
17
- // const execSync = require('child_process').execSync;
18
17
  const util = require('./util');
19
- // const fs = require('fs');
20
18
 
21
19
  let _platform = process.platform;
22
20
 
@@ -91,16 +89,6 @@ function parseLinuxUsb(usb) {
91
89
  return result;
92
90
  }
93
91
 
94
- // bus
95
- // deviceId
96
- // id
97
- // name(product)
98
- // type(bInterfaceClass)
99
- // removable / hotplug
100
- // vendor
101
- // manufacturer
102
- // maxpower(linux)
103
-
104
92
  function getDarwinUsbType(name) {
105
93
  let result = '';
106
94
  if (name.indexOf('camera') >= 0) { result = 'Camera'; }
@@ -164,25 +152,6 @@ function parseDarwinUsb(usb, id) {
164
152
  }
165
153
  }
166
154
 
167
- // function getWindowsUsbType(service) {
168
- // let result = ''
169
- // if (service.indexOf('usbhub3') >= 0) { result = 'Hub'; }
170
- // else if (service.indexOf('usbstor') >= 0) { result = 'Storage'; }
171
- // else if (service.indexOf('hidusb') >= 0) { result = 'Input'; }
172
- // else if (service.indexOf('usbccgp') >= 0) { result = 'Controller'; }
173
- // else if (service.indexOf('usbxhci') >= 0) { result = 'Controller'; }
174
- // else if (service.indexOf('usbehci') >= 0) { result = 'Controller'; }
175
- // else if (service.indexOf('kbdhid') >= 0) { result = 'Keyboard'; }
176
- // else if (service.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
177
- // else if (service.indexOf('pointing') >= 0) { result = 'Mouse'; }
178
- // else if (service.indexOf('disk') >= 0) { result = 'Storage'; }
179
- // else if (service.indexOf('usbhub') >= 0) { result = 'Hub'; }
180
- // else if (service.indexOf('bthusb') >= 0) { result = ''; }
181
- // else if (service.indexOf('bth') >= 0) { result = ''; }
182
- // else if (service.indexOf('rfcomm') >= 0) { result = ''; }
183
- // return result;
184
- // }
185
-
186
155
  function getWindowsUsbTypeCreation(creationclass, name) {
187
156
  let result = '';
188
157
  if (name.indexOf('storage') >= 0) { result = 'Storage'; }
@@ -216,7 +185,6 @@ function parseWindowsUsb(lines, id) {
216
185
  } else {
217
186
  return null;
218
187
  }
219
-
220
188
  }
221
189
 
222
190
  function usb(callback) {
@@ -278,21 +246,6 @@ function usb(callback) {
278
246
  }
279
247
  resolve(result);
280
248
  });
281
-
282
- // util.powerShell("gwmi Win32_USBControllerDevice |\%{[wmi]($_.Dependent)}").then(data => {
283
-
284
- // const parts = data.toString().split(/\n\s*\n/);
285
- // for (let i = 0; i < parts.length; i++) {
286
- // const usb = parseWindowsUsb(parts[i].split('\n'), i)
287
- // if (usb) {
288
- // result.push(usb)
289
- // }
290
- // }
291
- // if (callback) {
292
- // callback(result);
293
- // }
294
- // resolve(result);
295
- // });
296
249
  }
297
250
  if (_sunos || _freebsd || _openbsd || _netbsd) {
298
251
  resolve(null);
package/lib/users.js CHANGED
@@ -26,44 +26,6 @@ const _openbsd = (_platform === 'openbsd');
26
26
  const _netbsd = (_platform === 'netbsd');
27
27
  const _sunos = (_platform === 'sunos');
28
28
 
29
- // let _winDateFormat = {
30
- // dateFormat: '',
31
- // dateSeperator: '',
32
- // timeFormat: '',
33
- // timeSeperator: '',
34
- // amDesignator: '',
35
- // pmDesignator: ''
36
- // };
37
-
38
- // --------------------------
39
- // array of users online = sessions
40
-
41
- // function getWinCulture() {
42
- // return new Promise((resolve) => {
43
- // process.nextTick(() => {
44
- // if (!_winDateFormat.dateFormat) {
45
- // util.powerShell('(get-culture).DateTimeFormat')
46
- // .then(data => {
47
- // let lines = data.toString().split('\r\n');
48
- // _winDateFormat.dateFormat = util.getValue(lines, 'ShortDatePattern', ':');
49
- // _winDateFormat.dateSeperator = util.getValue(lines, 'DateSeparator', ':');
50
- // _winDateFormat.timeFormat = util.getValue(lines, 'ShortTimePattern', ':');
51
- // _winDateFormat.timeSeperator = util.getValue(lines, 'TimeSeparator', ':');
52
- // _winDateFormat.amDesignator = util.getValue(lines, 'AMDesignator', ':');
53
- // _winDateFormat.pmDesignator = util.getValue(lines, 'PMDesignator', ':');
54
-
55
- // resolve(_winDateFormat);
56
- // })
57
- // .catch(() => {
58
- // resolve(_winDateFormat);
59
- // });
60
- // } else {
61
- // resolve(_winDateFormat);
62
- // }
63
- // });
64
- // });
65
- // }
66
-
67
29
  function parseUsersLinux(lines, phase) {
68
30
  let result = [];
69
31
  let result_who = [];
@@ -245,21 +207,11 @@ function users(callback) {
245
207
  }
246
208
  if (_windows) {
247
209
  try {
248
- // const workload = [];
249
- // // workload.push(util.powerShell('Get-CimInstance -ClassName Win32_Account | fl *'));
250
- // workload.push(util.powerShell('Get-WmiObject Win32_LogonSession | fl *'));
251
- // workload.push(util.powerShell('Get-WmiObject Win32_LoggedOnUser | fl *'));
252
- // workload.push(util.powerShell('Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl'));
253
- // Promise.all(
254
- // workload
255
- // ).then(data => {
256
210
  let cmd = 'Get-WmiObject Win32_LogonSession | select LogonId,StartTime | fl' + '; echo \'#-#-#-#\';';
257
211
  cmd += 'Get-WmiObject Win32_LoggedOnUser | select antecedent,dependent | fl ' + '; echo \'#-#-#-#\';';
258
212
  cmd += 'Get-WmiObject Win32_Process -Filter "name=\'explorer.exe\'" | Select @{Name="sessionid";Expression={$_.SessionId}}, @{Name="domain";Expression={$_.GetOwner().Domain}}, @{Name="username";Expression={$_.GetOwner().User}} | fl' + '; echo \'#-#-#-#\';';
259
213
  cmd += 'query user';
260
- util.powerShell(cmd).then(data => {
261
- // controller + vram
262
- // let accounts = parseWinAccounts(data[0].split(/\n\s*\n/));
214
+ util.powerShell(cmd).then((data) => {
263
215
  if (data) {
264
216
  data = data.split('#-#-#-#');
265
217
  let sessions = parseWinSessions((data[0] || '').split(/\n\s*\n/));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "systeminformation",
3
- "version": "5.12.8",
3
+ "version": "5.12.10",
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)",