systeminformation 6.0.0-beta.1 → 6.0.0-beta.11

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.
Files changed (94) hide show
  1. package/README.md +41 -7
  2. package/dist/bsd/network-stats.js +2 -2
  3. package/dist/common/darwin.d.ts +2 -0
  4. package/dist/common/darwin.js +17 -1
  5. package/dist/common/defaults.d.ts +2 -1
  6. package/dist/common/defaults.js +21 -5
  7. package/dist/common/exec.js +1 -1
  8. package/dist/common/files.d.ts +9 -0
  9. package/dist/common/files.js +67 -3
  10. package/dist/common/filesys.d.ts +10 -0
  11. package/dist/common/filesys.js +41 -10
  12. package/dist/common/host.js +55 -3
  13. package/dist/common/mappings.js +2 -1
  14. package/dist/common/network.js +4 -4
  15. package/dist/common/nvidia.d.ts +1 -1
  16. package/dist/common/nvidia.js +4 -5
  17. package/dist/common/parse.d.ts +4 -6
  18. package/dist/common/parse.js +24 -69
  19. package/dist/common/security.d.ts +1 -0
  20. package/dist/common/security.js +3 -1
  21. package/dist/common/types.d.ts +33 -5
  22. package/dist/cpu-current-load.js +28 -6
  23. package/dist/cpu-current-speed.js +5 -3
  24. package/dist/darwin/battery.d.ts +1 -1
  25. package/dist/darwin/battery.js +15 -5
  26. package/dist/darwin/camera.js +3 -3
  27. package/dist/darwin/disk-layout.js +16 -12
  28. package/dist/darwin/disks-io.js +3 -3
  29. package/dist/darwin/displays.js +34 -1
  30. package/dist/darwin/fans.d.ts +2 -0
  31. package/dist/darwin/fans.js +28 -0
  32. package/dist/darwin/gpu.js +1 -1
  33. package/dist/darwin/index.d.ts +2 -0
  34. package/dist/darwin/index.js +6 -2
  35. package/dist/darwin/keyboard.js +4 -4
  36. package/dist/darwin/mouse.js +4 -4
  37. package/dist/darwin/network-interfaces.js +5 -10
  38. package/dist/darwin/network-stats.js +5 -5
  39. package/dist/darwin/serial-ports.d.ts +2 -0
  40. package/dist/darwin/serial-ports.js +94 -0
  41. package/dist/fans.d.ts +1 -0
  42. package/dist/fans.js +17 -0
  43. package/dist/get-data.d.ts +4 -0
  44. package/dist/get-data.js +6 -2
  45. package/dist/index.d.ts +2 -0
  46. package/dist/index.js +6 -2
  47. package/dist/linux/audio.js +59 -0
  48. package/dist/linux/baseboard.js +9 -20
  49. package/dist/linux/bios.js +6 -15
  50. package/dist/linux/camera.js +2 -1
  51. package/dist/linux/chassis.js +4 -10
  52. package/dist/linux/cpu-temperature.js +34 -19
  53. package/dist/linux/cpu.js +3 -1
  54. package/dist/linux/disk-layout.js +7 -10
  55. package/dist/linux/disks-io.js +9 -9
  56. package/dist/linux/displays.js +40 -2
  57. package/dist/linux/fans.d.ts +2 -0
  58. package/dist/linux/fans.js +92 -0
  59. package/dist/linux/fs-size.js +160 -34
  60. package/dist/linux/fs-stats.js +6 -9
  61. package/dist/linux/gpu.js +15 -15
  62. package/dist/linux/index.d.ts +2 -0
  63. package/dist/linux/index.js +6 -2
  64. package/dist/linux/mem-layout.js +2 -2
  65. package/dist/linux/network-interfaces.js +36 -39
  66. package/dist/linux/network-stats.js +8 -36
  67. package/dist/linux/npu.js +2 -1
  68. package/dist/linux/os-info.js +19 -4
  69. package/dist/linux/printer.js +4 -4
  70. package/dist/linux/process-load.js +9 -12
  71. package/dist/linux/processes.js +89 -80
  72. package/dist/linux/serial-ports.d.ts +2 -0
  73. package/dist/linux/serial-ports.js +102 -0
  74. package/dist/linux/services.js +179 -47
  75. package/dist/linux/system.js +1 -7
  76. package/dist/linux/uuid.js +4 -10
  77. package/dist/serial-ports.d.ts +1 -0
  78. package/dist/serial-ports.js +17 -0
  79. package/dist/versions.js +32 -77
  80. package/dist/windows/disk-layout.js +3 -0
  81. package/dist/windows/disks-io.js +3 -3
  82. package/dist/windows/displays.js +43 -12
  83. package/dist/windows/fans.d.ts +2 -0
  84. package/dist/windows/fans.js +71 -0
  85. package/dist/windows/index.d.ts +2 -0
  86. package/dist/windows/index.js +6 -2
  87. package/dist/windows/network-interfaces.js +20 -29
  88. package/dist/windows/network-stats.js +4 -2
  89. package/dist/windows/process-load.js +7 -5
  90. package/dist/windows/processes.js +17 -11
  91. package/dist/windows/serial-ports.d.ts +3 -0
  92. package/dist/windows/serial-ports.js +73 -0
  93. package/dist/windows/services.js +3 -0
  94. package/package.json +1 -1
@@ -4,6 +4,7 @@ exports.services = void 0;
4
4
  const common_1 = require("../common");
5
5
  const const_1 = require("../common/const");
6
6
  const exec_1 = require("../common/exec");
7
+ const files_1 = require("../common/files");
7
8
  const parse_1 = require("../common/parse");
8
9
  const security_1 = require("../common/security");
9
10
  const _services_cpu = {
@@ -82,15 +83,179 @@ const darwinGetServices = async () => {
82
83
  catch { }
83
84
  return srvs;
84
85
  };
86
+ const calcServicesCpuLinux = async (result) => {
87
+ result.forEach((item) => {
88
+ item.cpu = 0;
89
+ });
90
+ const pids = [];
91
+ for (const i in result) {
92
+ pids.push(...result[i].pids);
93
+ }
94
+ const cpuBaseline = { ..._services_cpu };
95
+ const stats = await (0, files_1.readProcStats)(pids);
96
+ const all = (0, parse_1.parseProcStat)(stats.all);
97
+ const curr_processes = stats.procs;
98
+ const list_new = {};
99
+ curr_processes.forEach((element) => {
100
+ const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, cpuBaseline);
101
+ if (resultProcess.pid) {
102
+ let listPos = -1;
103
+ for (let i = 0; i < result.length; i++) {
104
+ for (let j = 0; j < result[i].pids.length; j++) {
105
+ if (result[i].pids[j] === resultProcess.pid) {
106
+ listPos = i;
107
+ }
108
+ }
109
+ }
110
+ if (listPos >= 0) {
111
+ result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
112
+ }
113
+ list_new[resultProcess.pid] = {
114
+ cpuu: resultProcess.cpuu,
115
+ cpus: resultProcess.cpus,
116
+ utime: resultProcess.utime,
117
+ stime: resultProcess.stime
118
+ };
119
+ }
120
+ });
121
+ _services_cpu.all = all;
122
+ _services_cpu.list = Object.assign({}, list_new);
123
+ _services_cpu.ms = Date.now();
124
+ _services_cpu.result = Object.assign({}, result);
125
+ };
126
+ const systemdTimestamp = (value) => {
127
+ const parts = value.match(/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2})(?: (\S+))?/);
128
+ if (!parts) {
129
+ return null;
130
+ }
131
+ const utc = parts[3] === 'UTC' || parts[3] === 'GMT';
132
+ const date = new Date(`${parts[1]}T${parts[2]}${utc ? 'Z' : ''}`);
133
+ return Number.isNaN(date.getTime()) ? null : date;
134
+ };
135
+ const systemdUnits = async () => {
136
+ const units = [];
137
+ const stdout = await (0, exec_1.execSecure)('systemctl', [
138
+ 'show',
139
+ '--no-pager',
140
+ '--property=Id',
141
+ '--property=LoadState',
142
+ '--property=ActiveState',
143
+ '--property=UnitFileState',
144
+ '--property=ActiveEnterTimestamp',
145
+ '--property=ActiveExitTimestamp',
146
+ '--property=MainPID',
147
+ '*.service'
148
+ ]);
149
+ stdout.split(/\n\s*\n/).forEach((block) => {
150
+ const lines = block.split('\n');
151
+ const id = (0, common_1.getValue)(lines, 'Id', '=', false, true);
152
+ if (id && (0, common_1.getValue)(lines, 'LoadState', '=', false, true) !== 'not-found') {
153
+ const mainPid = (0, common_1.toInt)((0, common_1.getValue)(lines, 'MainPID', '=', false, true));
154
+ const activeState = (0, common_1.getValue)(lines, 'ActiveState', '=', false, true);
155
+ const running = activeState === 'active' || activeState === 'reloading';
156
+ const enter = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveEnterTimestamp', '=', false, true));
157
+ const exit = systemdTimestamp((0, common_1.getValue)(lines, 'ActiveExitTimestamp', '=', false, true));
158
+ units.push({
159
+ name: id.replace(/\.service$/, ''),
160
+ running,
161
+ startmode: (0, common_1.getValue)(lines, 'UnitFileState', '=', false, true),
162
+ lastChanged: (running ? enter || exit : exit || enter) || null,
163
+ mainPid
164
+ });
165
+ }
166
+ });
167
+ return units;
168
+ };
169
+ const elapsedToDate = (elapsed) => {
170
+ const parts = elapsed.split('-');
171
+ const days = parts.length > 1 ? (0, common_1.toInt)(parts[0]) : 0;
172
+ const time = (parts.length > 1 ? parts[1] : parts[0]).split(':');
173
+ if (time.length < 2 || time.length > 3) {
174
+ return null;
175
+ }
176
+ const seconds = time.reduce((total, part) => total * 60 + (0, common_1.toInt)(part), 0) + days * 86400;
177
+ return seconds > 0 ? new Date(Date.now() - seconds * 1000) : null;
178
+ };
179
+ const psProcessesLinux = async () => {
180
+ const procs = [];
181
+ const stdout = await (0, exec_1.execSecure)('ps', ['-axo', 'pcpu,pmem,pid,ppid']);
182
+ stdout
183
+ .replace(/ +/g, ' ')
184
+ .replace(/,+/g, '.')
185
+ .split('\n')
186
+ .forEach((line) => {
187
+ const parts = line.trim().split(' ');
188
+ if (parts.length >= 4) {
189
+ const pid = (0, common_1.toInt)(parts[2]);
190
+ if (pid) {
191
+ procs.push({ pid, ppid: (0, common_1.toInt)(parts[3]), cpu: parseFloat(parts[0]) || 0, mem: parseFloat(parts[1]) || 0 });
192
+ }
193
+ }
194
+ });
195
+ return procs;
196
+ };
197
+ const servicesFromSystemd = async (srvs, units) => {
198
+ const all = srvs.length === 1 && srvs[0] === '*';
199
+ const matches = (unit) => {
200
+ const name = unit.name.toLowerCase();
201
+ return srvs.indexOf(name) >= 0 || srvs.indexOf(`${name}.service`) >= 0;
202
+ };
203
+ const selected = all ? units : units.filter(matches);
204
+ const procs = await psProcessesLinux();
205
+ const byPid = {};
206
+ const children = {};
207
+ procs.forEach((proc) => {
208
+ byPid[proc.pid] = { cpu: proc.cpu, mem: proc.mem };
209
+ children[proc.ppid] = (children[proc.ppid] || []).concat(proc.pid);
210
+ });
211
+ const result = [];
212
+ selected.forEach((unit) => {
213
+ const pids = [];
214
+ const collect = (pid) => {
215
+ pids.push(pid);
216
+ (children[pid] || []).forEach(collect);
217
+ };
218
+ if (unit.mainPid && byPid[unit.mainPid]) {
219
+ collect(unit.mainPid);
220
+ }
221
+ result.push({
222
+ name: unit.name,
223
+ running: unit.running,
224
+ startmode: unit.startmode,
225
+ lastChanged: unit.lastChanged,
226
+ pids,
227
+ cpu: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].cpu : 0), 0).toFixed(2)),
228
+ mem: parseFloat(pids.reduce((sum, pid) => sum + (byPid[pid] ? byPid[pid].mem : 0), 0).toFixed(2))
229
+ });
230
+ });
231
+ if (!all) {
232
+ srvs
233
+ .filter((srv) => !selected.some((unit) => unit.name.toLowerCase() === srv || `${unit.name.toLowerCase()}.service` === srv))
234
+ .forEach((srv) => {
235
+ result.push({ name: srv, running: false, startmode: '', lastChanged: null, pids: [], cpu: 0, mem: 0 });
236
+ });
237
+ }
238
+ await calcServicesCpuLinux(result);
239
+ return result;
240
+ };
85
241
  const services = async (srv) => {
86
242
  await (0, common_1.nextTick)();
87
243
  const result = [];
88
244
  if (!(0, security_1.isPrototypePolluted)()) {
89
245
  let srvs = (0, security_1.sanitizeServiceString)(srv);
246
+ if (const_1.LINUX) {
247
+ try {
248
+ const units = await systemdUnits();
249
+ if (units.length) {
250
+ return await servicesFromSystemd(srvs, units);
251
+ }
252
+ }
253
+ catch { }
254
+ }
90
255
  if (srvs.length === 1 && srvs[0] === '*') {
91
256
  srvs = const_1.DARWIN ? await darwinGetServices() : await nixGetServices();
92
257
  }
93
- let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,command'] : ['-axo', 'pcpu,pmem,pid,command'];
258
+ let args = const_1.DARWIN ? ['-caxo', 'pcpu,pmem,pid,etime,command'] : ['-axo', 'pcpu,pmem,pid,etime,command'];
94
259
  if (srvs.length > 0) {
95
260
  let stdout = await (0, exec_1.execSecure)('ps', args);
96
261
  if (stdout) {
@@ -112,16 +277,22 @@ const services = async (srv) => {
112
277
  });
113
278
  }
114
279
  const pids = [];
280
+ let lastChanged = null;
115
281
  for (const p of ps) {
116
- const pid = p.trim().split(' ')[2];
117
- if (pid) {
118
- pids.push((0, common_1.toInt)(pid));
282
+ const parts = p.trim().split(' ');
283
+ if (parts[2]) {
284
+ pids.push((0, common_1.toInt)(parts[2]));
285
+ const started = elapsedToDate(parts[3] || '');
286
+ if (started && (!lastChanged || started < lastChanged)) {
287
+ lastChanged = started;
288
+ }
119
289
  }
120
290
  }
121
291
  result.push({
122
292
  name: srv,
123
293
  running: ps.length > 0,
124
294
  startmode: '',
295
+ lastChanged,
125
296
  pids: pids,
126
297
  cpu: parseFloat(ps
127
298
  .reduce(function (pv, cv) {
@@ -136,50 +307,9 @@ const services = async (srv) => {
136
307
  });
137
308
  });
138
309
  if (const_1.LINUX) {
139
- let cmd = 'cat /proc/stat | grep "cpu "';
140
- for (const i in result) {
141
- for (const j in result[i].pids) {
142
- cmd += ';cat /proc/' + result[i].pids[j] + '/stat';
143
- }
144
- }
145
- const { stdout } = await (0, exec_1.exec)(cmd, const_1.execOptsLinux);
146
- let curr_processes = stdout.toString().split('\n');
147
- const all = (0, parse_1.parseProcStat)(curr_processes[0]);
148
- curr_processes = curr_processes.slice(1);
149
- const list_new = {};
150
- curr_processes.forEach((element) => {
151
- const resultProcess = (0, parse_1.calcProcStatLinux)(element, all, _services_cpu);
152
- if (resultProcess.pid) {
153
- let listPos = -1;
154
- for (let i = 0; i < result.length; i++) {
155
- for (let j = 0; j < result[i].pids.length; j++) {
156
- if (result[i].pids[j] === resultProcess.pid) {
157
- listPos = i;
158
- }
159
- }
160
- }
161
- if (listPos >= 0) {
162
- result[listPos].cpu += resultProcess.cpuu + resultProcess.cpus;
163
- }
164
- list_new[resultProcess.pid] = {
165
- cpuu: resultProcess.cpuu,
166
- cpus: resultProcess.cpus,
167
- utime: resultProcess.utime,
168
- stime: resultProcess.stime,
169
- cutime: resultProcess.cutime,
170
- cstime: resultProcess.cstime
171
- };
172
- }
173
- });
174
- _services_cpu.all = all;
175
- _services_cpu.list = Object.assign({}, list_new);
176
- _services_cpu.ms = Date.now();
177
- _services_cpu.result = Object.assign({}, result);
178
- return result;
179
- }
180
- else {
181
- return result;
310
+ await calcServicesCpuLinux(result);
182
311
  }
312
+ return result;
183
313
  }
184
314
  else {
185
315
  args = ['-o', 'comm'];
@@ -194,6 +324,7 @@ const services = async (srv) => {
194
324
  name: srv,
195
325
  running: ps.length > 0,
196
326
  startmode: '',
327
+ lastChanged: null,
197
328
  pids: [],
198
329
  cpu: 0,
199
330
  mem: 0
@@ -207,6 +338,7 @@ const services = async (srv) => {
207
338
  name: srv,
208
339
  running: false,
209
340
  startmode: '',
341
+ lastChanged: null,
210
342
  pids: [],
211
343
  cpu: 0,
212
344
  mem: 0
@@ -21,14 +21,8 @@ const system = async () => {
21
21
  result.serial = (0, common_1.getValue)(lines, 'serial number');
22
22
  result.uuid = (0, common_1.getValue)(lines, 'uuid').toLowerCase();
23
23
  result.sku = (0, common_1.getValue)(lines, 'sku number');
24
- const cmd = `echo -n "product_name: "; cat /sys/devices/virtual/dmi/id/product_name 2>/dev/null; echo;
25
- echo -n "product_serial: "; cat /sys/devices/virtual/dmi/id/product_serial 2>/dev/null; echo;
26
- echo -n "product_uuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;
27
- echo -n "product_version: "; cat /sys/devices/virtual/dmi/id/product_version 2>/dev/null; echo;
28
- echo -n "sys_vendor: "; cat /sys/devices/virtual/dmi/id/sys_vendor 2>/dev/null; echo;`;
29
24
  try {
30
- ({ stdout } = await (0, exec_1.execSave)(cmd));
31
- lines = stdout.split('\n');
25
+ lines = await (0, files_1.readSysfsMany)(files_1.DMI_PATH, ['product_name', 'product_serial', 'product_uuid', 'product_version', 'sys_vendor']);
32
26
  result.manufacturer = result.manufacturer === '' ? (0, common_1.getValue)(lines, 'sys_vendor') : result.manufacturer;
33
27
  result.model = result.model === '' ? (0, common_1.getValue)(lines, 'product_name') : result.model;
34
28
  result.version = result.version === '' ? (0, common_1.getValue)(lines, 'product_version') : result.version;
@@ -4,21 +4,15 @@ exports.uuid = void 0;
4
4
  const promises_1 = require("fs/promises");
5
5
  const common_1 = require("../common");
6
6
  const defaults_1 = require("../common/defaults");
7
- const exec_1 = require("../common/exec");
7
+ const files_1 = require("../common/files");
8
8
  const disk_layout_1 = require("./disk-layout");
9
9
  const uuid = async () => {
10
10
  await (0, common_1.nextTick)();
11
11
  const defaults = defaults_1.initUUID;
12
12
  try {
13
- const cmd = `echo -n "os: "; cat /var/lib/dbus/machine-id 2> /dev/null ||
14
- cat /etc/machine-id 2> /dev/null; echo;
15
- echo -n "hardware: "; cat /sys/class/dmi/id/product_uuid 2> /dev/null; echo;
16
- echo -n "systemuuid: "; cat /sys/devices/virtual/dmi/id/product_uuid 2>/dev/null; echo;`;
17
- const { stdout } = await (0, exec_1.execSave)(cmd);
18
- const lines = stdout.toString().split('\n');
19
- const os = (0, common_1.getValue)(lines, 'os').toLowerCase();
20
- let hardware = (0, common_1.getValue)(lines, 'hardware').toLowerCase();
21
- const systemuuid = (0, common_1.getValue)(lines, 'systemuuid').toLowerCase();
13
+ const os = ((await (0, files_1.readSysfs)('/var/lib/dbus/machine-id')) || (await (0, files_1.readSysfs)('/etc/machine-id'))).toLowerCase();
14
+ let hardware = (await (0, files_1.readSysfs)('/sys/class/dmi/id/product_uuid')).toLowerCase();
15
+ const systemuuid = (await (0, files_1.readSysfs)(`${files_1.DMI_PATH}/product_uuid`)).toLowerCase();
22
16
  if (!hardware) {
23
17
  const lines = (await (0, promises_1.readFile)('/proc/cpuinfo')).toString().split('\n');
24
18
  const serial = (0, common_1.getValue)(lines, 'serial');
@@ -0,0 +1 @@
1
+ export declare const serialPorts: () => Promise<import("./common/types").SerialPortData[] | null>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serialPorts = void 0;
4
+ const const_1 = require("./common/const");
5
+ const serialPorts = async () => {
6
+ switch (true) {
7
+ case const_1.LINUX || const_1.ANDROID:
8
+ return (await import('./linux/serial-ports.js')).serialPorts();
9
+ case const_1.DARWIN:
10
+ return (await import('./darwin/serial-ports.js')).serialPorts();
11
+ case const_1.WINDOWS:
12
+ return (await import('./windows/serial-ports.js')).serialPorts();
13
+ default:
14
+ return null;
15
+ }
16
+ };
17
+ exports.serialPorts = serialPorts;
package/dist/versions.js CHANGED
@@ -414,90 +414,45 @@ const versions = async (apps) => {
414
414
  });
415
415
  }
416
416
  if (Object.keys(appsObj.versions).includes('postgresql')) {
417
- if (const_1.LINUX) {
418
- (0, exec_1.exec)('locate bin/postgres')
419
- .then((res) => {
420
- const postgresqlBin = res.stdout.split('\n').sort();
421
- if (postgresqlBin.length) {
422
- (0, exec_1.exec)(postgresqlBin[postgresqlBin.length - 1] + ' -V')
423
- .then((res) => {
424
- if (res.stdout) {
425
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
426
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
417
+ if (const_1.WINDOWS) {
418
+ windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
419
+ .then((stdout) => {
420
+ const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
421
+ serviceSections.forEach((item) => {
422
+ const lines = item.trim().split('\r\n');
423
+ const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
424
+ if (srvCaption.indexOf('postgresql') > -1) {
425
+ const parts = srvCaption.split(' server ');
426
+ if (parts.length > 1) {
427
+ appsObj.versions.postgresql = parts[1];
427
428
  }
428
- functionProcessed();
429
- })
430
- .catch(() => {
431
- functionProcessed();
432
- });
433
- }
434
- else {
435
- functionProcessed();
436
- }
429
+ }
430
+ });
431
+ functionProcessed();
437
432
  })
438
433
  .catch(() => {
439
- (0, exec_1.exec)('psql -V')
440
- .then((res) => {
441
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
442
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
443
- appsObj.versions.postgresql = appsObj.versions.postgresql.split('-')[0];
444
- functionProcessed();
445
- })
446
- .catch(() => {
447
- functionProcessed();
448
- });
434
+ functionProcessed();
449
435
  });
450
436
  }
451
437
  else {
452
- if (const_1.WINDOWS) {
453
- windows_1.ps.exec('Get-CimInstance Win32_Service | select caption | fl')
454
- .then((stdout) => {
455
- const serviceSections = (stdout ? stdout.toString() : '').split(/\n\s*\n/);
456
- serviceSections.forEach((item) => {
457
- const lines = item.trim().split('\r\n');
458
- const srvCaption = (0, common_1.getValue)(lines, 'caption', ':', true).toLowerCase();
459
- if (srvCaption.indexOf('postgresql') > -1) {
460
- const parts = srvCaption.split(' server ');
461
- if (parts.length > 1) {
462
- appsObj.versions.postgresql = parts[1];
463
- }
464
- }
465
- });
466
- functionProcessed();
467
- })
468
- .catch(() => {
469
- functionProcessed();
470
- });
471
- }
472
- else {
473
- (0, exec_1.exec)('postgres -V')
474
- .then((res) => {
475
- if (res.stdout) {
476
- const postgresql = res.stdout.split('\n')[0].split(' ') || [];
477
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
478
- if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
479
- appsObj.versions.postgresql = postgresql[postgresql.length - 2];
480
- }
438
+ const parsePostgres = (stdout) => {
439
+ const postgresql = stdout.split('\n')[0].split(' ') || [];
440
+ let version = postgresql.length ? postgresql[postgresql.length - 1] : '';
441
+ if (version.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
442
+ version = postgresql[postgresql.length - 2];
443
+ }
444
+ return version.split('-')[0];
445
+ };
446
+ (async () => {
447
+ for (const cmd of ['postgres -V', 'pg_config --version', 'psql -V']) {
448
+ const { stdout } = await (0, exec_1.execSave)(cmd);
449
+ if (stdout) {
450
+ appsObj.versions.postgresql = parsePostgres(stdout);
451
+ break;
481
452
  }
482
- functionProcessed();
483
- })
484
- .catch(() => {
485
- (0, exec_1.exec)('pg_config --version 2> /dev/null')
486
- .then((res) => {
487
- if (res.stdout) {
488
- const postgresql = res.stdout.toString().split('\n')[0].split(' ') || [];
489
- appsObj.versions.postgresql = postgresql.length ? postgresql[postgresql.length - 1] : '';
490
- if (appsObj.versions.postgresql.includes('(') && postgresql.length >= 2 && !postgresql[postgresql.length - 2].includes('(')) {
491
- appsObj.versions.postgresql = postgresql[postgresql.length - 2];
492
- }
493
- }
494
- })
495
- .catch(() => { })
496
- .finally(() => {
497
- functionProcessed();
498
- });
499
- });
500
- }
453
+ }
454
+ functionProcessed();
455
+ })();
501
456
  }
502
457
  }
503
458
  if (Object.keys(appsObj.versions).includes('perl')) {
@@ -99,6 +99,9 @@ const diskLayout = async () => {
99
99
  const smartDev = JSON.parse(stdout.trim());
100
100
  if (smartDev?.devices && smartDev.devices.length > 0) {
101
101
  for (const dev of smartDev.devices) {
102
+ if (!/^[\w/.,:\\-]+$/.test(String(dev.name || ''))) {
103
+ continue;
104
+ }
102
105
  try {
103
106
  const { stdout: smartOut } = await (0, exec_1.execSave)(`smartctl -j -a ${dev.name}`, const_1.execOptsWin);
104
107
  const smartData = JSON.parse(smartOut);
@@ -34,9 +34,9 @@ const disksIO = async () => {
34
34
  rIO_sec: filesys_1._disk_io.rIO_sec,
35
35
  wIO_sec: filesys_1._disk_io.wIO_sec,
36
36
  tIO_sec: filesys_1._disk_io.tIO_sec,
37
- rWaitTime: filesys_1._disk_io.rWaitTime,
38
- wWaitTime: filesys_1._disk_io.wWaitTime,
39
- tWaitTime: filesys_1._disk_io.tWaitTime,
37
+ rWaitTime: filesys_1._disk_io.rWaitTimeDelta,
38
+ wWaitTime: filesys_1._disk_io.wWaitTimeDelta,
39
+ tWaitTime: filesys_1._disk_io.tWaitTimeDelta,
40
40
  rWaitPercent: filesys_1._disk_io.rWaitPercent,
41
41
  wWaitPercent: filesys_1._disk_io.wWaitPercent,
42
42
  tWaitPercent: filesys_1._disk_io.tWaitPercent
@@ -5,7 +5,7 @@ const common_1 = require("../common");
5
5
  const mappings_1 = require("../common/mappings");
6
6
  const exec_1 = require("../common/exec");
7
7
  const windows_1 = require("../common/windows");
8
- const psCurrentModes = "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight } }";
8
+ const psCurrentModes = "Add-Type -AssemblyName System.Windows.Forms; if (-not ('SiDevMode' -as [Type])) { Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential,CharSet=CharSet.Ansi)]public struct SIDEVMODE{[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public int dmPositionX;public int dmPositionY;public int dmDisplayOrientation;public int dmDisplayFixedOutput;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr,SizeConst=32)]public string dmFormName;public short dmLogPixels;public int dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;public int dmICMMethod;public int dmICMIntent;public int dmMediaType;public int dmDitherType;public int dmReserved1;public int dmReserved2;public int dmPanningWidth;public int dmPanningHeight;}public class SiDevMode{[DllImport(\"user32.dll\",CharSet=CharSet.Ansi)]public static extern bool EnumDisplaySettings(string lpszDeviceName,int iModeNum,ref SIDEVMODE lpDevMode);}' }; [System.Windows.Forms.Screen]::AllScreens | ForEach-Object { $dm = New-Object SIDEVMODE; $dm.dmSize = [System.Runtime.InteropServices.Marshal]::SizeOf($dm); if ([SiDevMode]::EnumDisplaySettings($_.DeviceName, -1, [ref]$dm)) { $_.DeviceName + '|' + $dm.dmDisplayFrequency + '|' + $dm.dmBitsPerPel + '|' + $dm.dmPelsWidth + '|' + $dm.dmPelsHeight + '|' + $dm.dmPositionX + '|' + $dm.dmPositionY } }";
9
9
  const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, connections, isections, currentModes) => {
10
10
  const displays = [];
11
11
  const desktopMonitors = (dsections || []).map((section) => {
@@ -28,11 +28,24 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
28
28
  const instanceName = monitor ? monitor.instanceName : '';
29
29
  const bitsPerPixel = (0, common_1.toInt)((0, common_1.getValue)(linesScreen, 'BitsPerPixel'));
30
30
  const bounds = (0, common_1.getValue)(linesScreen, 'Bounds').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
31
+ const workArea = (0, common_1.getValue)(linesScreen, 'WorkingArea').replace('{', '').replace('}', '').replace(/=/g, ':').split(',');
31
32
  const primary = (0, common_1.getValue)(linesScreen, 'Primary');
32
33
  const sizeX = monitor ? monitor.sizeX : '';
33
34
  const sizeY = monitor ? monitor.sizeY : '';
34
35
  const videoOutputTechnology = instanceName && connections[instanceName] !== undefined ? connections[instanceName] : '';
35
36
  const deviceName = (0, common_1.getValue)(linesScreen, 'DeviceName');
37
+ const mode = currentModes[deviceName.toLowerCase()];
38
+ const boundsWidth = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':'));
39
+ const boundsHeight = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':'));
40
+ const boundsX = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'X', ':'));
41
+ const boundsY = (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Y', ':'));
42
+ const resX = mode ? mode.width : boundsWidth;
43
+ const resY = mode ? mode.height : boundsHeight;
44
+ const posX = mode ? mode.positionX : boundsX;
45
+ const posY = mode ? mode.positionY : boundsY;
46
+ const dpiScale = mode && boundsWidth ? mode.width / boundsWidth : 1;
47
+ const workAreaWidth = (0, common_1.getValue)(workArea, 'Width', ':');
48
+ const workAreaHeight = (0, common_1.getValue)(workArea, 'Height', ':');
36
49
  const isection = instanceName ? isections.find((element) => element.instanceId.toLowerCase().startsWith(instanceName)) : undefined;
37
50
  const dsection = instanceName ? desktopMonitors.find((element) => element.deviceId && instanceName.startsWith(element.deviceId)) : undefined;
38
51
  displays.push({
@@ -44,18 +57,24 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
44
57
  deviceName,
45
58
  displayId: instanceName || null,
46
59
  main: hasOwnScreen ? primary.toLowerCase() === 'true' : false,
60
+ mirror: !hasOwnScreen || (monitors.length > ssections.length && i === 0),
47
61
  builtin: videoOutputTechnology === '2147483648',
48
62
  connection: videoOutputTechnology && mappings_1.graphicsVideoTypes[videoOutputTechnology] ? mappings_1.graphicsVideoTypes[videoOutputTechnology] : '',
49
- resolutionX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':')),
50
- resolutionY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':')),
63
+ resolutionX: resX,
64
+ resolutionY: resY,
51
65
  sizeX: sizeX ? parseInt(sizeX, 10) : null,
52
66
  sizeY: sizeY ? parseInt(sizeY, 10) : null,
53
67
  pixelDepth: bitsPerPixel,
54
- currentResX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Width', ':')),
55
- currentResY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Height', ':')),
56
- positionX: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'X', ':')),
57
- positionY: (0, common_1.toInt)((0, common_1.getValue)(bounds, 'Y', ':')),
58
- currentRefreshRate: currentModes[deviceName.toLowerCase()] || null
68
+ currentResX: resX,
69
+ currentResY: resY,
70
+ positionX: posX,
71
+ positionY: posY,
72
+ workAreaResolutionX: workAreaWidth ? Math.round((0, common_1.toInt)(workAreaWidth) * dpiScale) : null,
73
+ workAreaResolutionY: workAreaHeight ? Math.round((0, common_1.toInt)(workAreaHeight) * dpiScale) : null,
74
+ workAreaPositionX: workAreaWidth ? Math.round(posX + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'X', ':')) - boundsX) * dpiScale) : null,
75
+ workAreaPositionY: workAreaHeight ? Math.round(posY + ((0, common_1.toInt)((0, common_1.getValue)(workArea, 'Y', ':')) - boundsY) * dpiScale) : null,
76
+ currentRefreshRate: (mode && mode.refreshRate) || null,
77
+ scale: mode && boundsWidth ? Math.round((mode.width / boundsWidth) * 100) / 100 : null
59
78
  });
60
79
  }
61
80
  }
@@ -70,6 +89,7 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
70
89
  deviceName: '',
71
90
  displayId: null,
72
91
  main: true,
92
+ mirror: false,
73
93
  builtin: true,
74
94
  sizeX: null,
75
95
  sizeY: null,
@@ -81,7 +101,12 @@ const parseLinesWindowsDisplaysPowershell = (ssections, monitors, dsections, con
81
101
  currentResY: first ? first.resolutionY : 0,
82
102
  positionX: 0,
83
103
  positionY: 0,
84
- currentRefreshRate: null
104
+ workAreaResolutionX: null,
105
+ workAreaResolutionY: null,
106
+ workAreaPositionX: null,
107
+ workAreaPositionY: null,
108
+ currentRefreshRate: null,
109
+ scale: null
85
110
  });
86
111
  }
87
112
  return displays;
@@ -177,9 +202,15 @@ const displays = async () => {
177
202
  .split(/\n/)
178
203
  .forEach((element) => {
179
204
  const parts = element.split('|');
180
- const frequency = parts.length === 5 ? (0, common_1.toInt)(parts[1]) : 0;
181
- if (frequency > 1 && parts[0]) {
182
- currentModes[parts[0].trim().toLowerCase()] = frequency;
205
+ if (parts.length === 7 && parts[0].trim() && (0, common_1.toInt)(parts[3])) {
206
+ const frequency = (0, common_1.toInt)(parts[1]);
207
+ currentModes[parts[0].trim().toLowerCase()] = {
208
+ refreshRate: frequency > 1 ? frequency : 0,
209
+ width: (0, common_1.toInt)(parts[3]),
210
+ height: (0, common_1.toInt)(parts[4]),
211
+ positionX: (0, common_1.toInt)(parts[5]),
212
+ positionY: (0, common_1.toInt)(parts[6])
213
+ };
183
214
  }
184
215
  });
185
216
  result = parseLinesWindowsDisplaysPowershell(ssections, monitors, dsections, connections, isections, currentModes);
@@ -0,0 +1,2 @@
1
+ import type { FanData } from '../common/types';
2
+ export declare const fans: () => Promise<FanData[]>;