systeminformation 6.0.0-beta.2 → 6.0.0-beta.21

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 (139) hide show
  1. package/README.md +67 -18
  2. package/dist/bsd/mem.js +8 -3
  3. package/dist/bsd/network-stats.d.ts +1 -1
  4. package/dist/bsd/network-stats.js +14 -7
  5. package/dist/bsd/os-info.d.ts +1 -0
  6. package/dist/common/darwin.d.ts +2 -0
  7. package/dist/common/darwin.js +17 -1
  8. package/dist/common/defaults.d.ts +2 -1
  9. package/dist/common/defaults.js +36 -6
  10. package/dist/common/exec.js +29 -13
  11. package/dist/common/files.d.ts +9 -0
  12. package/dist/common/files.js +67 -3
  13. package/dist/common/filesys.d.ts +30 -0
  14. package/dist/common/filesys.js +228 -11
  15. package/dist/common/host.js +55 -3
  16. package/dist/common/internet.js +31 -20
  17. package/dist/common/mappings.d.ts +0 -3
  18. package/dist/common/mappings.js +35 -14
  19. package/dist/common/network.d.ts +15 -2
  20. package/dist/common/network.js +18 -22
  21. package/dist/common/nvidia.d.ts +1 -1
  22. package/dist/common/nvidia.js +4 -5
  23. package/dist/common/parse.d.ts +4 -6
  24. package/dist/common/parse.js +24 -69
  25. package/dist/common/security.d.ts +2 -0
  26. package/dist/common/security.js +18 -3
  27. package/dist/common/types.d.ts +53 -5
  28. package/dist/common/windows.d.ts +4 -0
  29. package/dist/common/windows.js +57 -1
  30. package/dist/cpu-current-load.d.ts +1 -0
  31. package/dist/cpu-current-load.js +54 -8
  32. package/dist/cpu-current-speed.js +5 -3
  33. package/dist/darwin/battery.d.ts +1 -1
  34. package/dist/darwin/battery.js +15 -5
  35. package/dist/darwin/camera.js +3 -3
  36. package/dist/darwin/disk-layout.js +16 -12
  37. package/dist/darwin/disks-io.js +3 -3
  38. package/dist/darwin/displays.d.ts +1 -0
  39. package/dist/darwin/displays.js +64 -2
  40. package/dist/darwin/fans.d.ts +2 -0
  41. package/dist/darwin/fans.js +28 -0
  42. package/dist/darwin/gpu.js +1 -1
  43. package/dist/darwin/index.d.ts +3 -0
  44. package/dist/darwin/index.js +8 -2
  45. package/dist/darwin/keyboard.js +4 -4
  46. package/dist/darwin/mouse.js +4 -4
  47. package/dist/darwin/network-interfaces.d.ts +3 -0
  48. package/dist/darwin/network-interfaces.js +81 -14
  49. package/dist/darwin/network-stats.d.ts +1 -1
  50. package/dist/darwin/network-stats.js +14 -7
  51. package/dist/darwin/os-info.d.ts +2 -0
  52. package/dist/darwin/os-info.js +24 -2
  53. package/dist/darwin/process-focused.d.ts +3 -0
  54. package/dist/darwin/process-focused.js +26 -0
  55. package/dist/darwin/serial-ports.d.ts +2 -0
  56. package/dist/darwin/serial-ports.js +94 -0
  57. package/dist/darwin/users.js +1 -1
  58. package/dist/docker.js +4 -5
  59. package/dist/fans.d.ts +1 -0
  60. package/dist/fans.js +17 -0
  61. package/dist/get-data.d.ts +4 -0
  62. package/dist/get-data.js +6 -2
  63. package/dist/get.js +6 -1
  64. package/dist/index.d.ts +3 -0
  65. package/dist/index.js +8 -2
  66. package/dist/inet-public-ip.js +2 -1
  67. package/dist/linux/audio.js +59 -0
  68. package/dist/linux/baseboard.js +9 -20
  69. package/dist/linux/bios.js +6 -15
  70. package/dist/linux/block-devices.js +3 -1
  71. package/dist/linux/camera.js +2 -1
  72. package/dist/linux/chassis.js +4 -10
  73. package/dist/linux/cpu-temperature.js +34 -19
  74. package/dist/linux/cpu.js +3 -1
  75. package/dist/linux/disk-layout.js +9 -12
  76. package/dist/linux/disks-io.js +9 -9
  77. package/dist/linux/displays.d.ts +8 -0
  78. package/dist/linux/displays.js +151 -4
  79. package/dist/linux/fans.d.ts +2 -0
  80. package/dist/linux/fans.js +92 -0
  81. package/dist/linux/fs-size.d.ts +1 -1
  82. package/dist/linux/fs-size.js +164 -37
  83. package/dist/linux/fs-stats.js +6 -9
  84. package/dist/linux/gpu.d.ts +2 -0
  85. package/dist/linux/gpu.js +97 -22
  86. package/dist/linux/index.d.ts +3 -0
  87. package/dist/linux/index.js +8 -2
  88. package/dist/linux/mem-layout.js +3 -7
  89. package/dist/linux/mem.d.ts +1 -0
  90. package/dist/linux/mem.js +21 -1
  91. package/dist/linux/network-interfaces.d.ts +1 -0
  92. package/dist/linux/network-interfaces.js +154 -113
  93. package/dist/linux/network-stats.d.ts +1 -1
  94. package/dist/linux/network-stats.js +14 -40
  95. package/dist/linux/npu.js +2 -1
  96. package/dist/linux/os-info.js +56 -5
  97. package/dist/linux/printer.js +4 -4
  98. package/dist/linux/process-focused.d.ts +4 -0
  99. package/dist/linux/process-focused.js +32 -0
  100. package/dist/linux/process-load.js +11 -13
  101. package/dist/linux/processes.js +89 -80
  102. package/dist/linux/serial-ports.d.ts +2 -0
  103. package/dist/linux/serial-ports.js +102 -0
  104. package/dist/linux/services.js +182 -49
  105. package/dist/linux/system.js +1 -7
  106. package/dist/linux/users.js +1 -1
  107. package/dist/linux/uuid.js +4 -10
  108. package/dist/linux/wifi-networks.js +2 -2
  109. package/dist/network-interfaces.js +1 -1
  110. package/dist/observe.d.ts +1 -1
  111. package/dist/observe.js +5 -1
  112. package/dist/process-focused.d.ts +1 -0
  113. package/dist/process-focused.js +17 -0
  114. package/dist/serial-ports.d.ts +1 -0
  115. package/dist/serial-ports.js +17 -0
  116. package/dist/versions.js +34 -80
  117. package/dist/windows/audio.d.ts +29 -0
  118. package/dist/windows/audio.js +151 -11
  119. package/dist/windows/disk-layout.js +3 -0
  120. package/dist/windows/disks-io.js +3 -3
  121. package/dist/windows/displays.d.ts +5 -0
  122. package/dist/windows/displays.js +101 -16
  123. package/dist/windows/fans.d.ts +2 -0
  124. package/dist/windows/fans.js +71 -0
  125. package/dist/windows/fs-size.js +1 -4
  126. package/dist/windows/gpu.js +3 -2
  127. package/dist/windows/index.d.ts +3 -0
  128. package/dist/windows/index.js +8 -2
  129. package/dist/windows/network-interfaces.js +36 -41
  130. package/dist/windows/network-stats.js +20 -6
  131. package/dist/windows/process-focused.d.ts +3 -0
  132. package/dist/windows/process-focused.js +36 -0
  133. package/dist/windows/process-load.js +7 -5
  134. package/dist/windows/processes.d.ts +1 -0
  135. package/dist/windows/processes.js +54 -26
  136. package/dist/windows/serial-ports.d.ts +3 -0
  137. package/dist/windows/serial-ports.js +73 -0
  138. package/dist/windows/services.js +4 -1
  139. package/package.json +1 -1
package/dist/linux/gpu.js CHANGED
@@ -1,34 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gpu = exports.mergeControllerDrm = exports.drmDevices = void 0;
3
+ exports.gpu = exports.mergeControllerDrm = exports.tegraDevice = exports.drmDevices = void 0;
4
4
  const promises_1 = require("fs/promises");
5
5
  const common_1 = require("../common");
6
6
  const const_1 = require("../common/const");
7
7
  const exec_1 = require("../common/exec");
8
+ const files_1 = require("../common/files");
8
9
  const nvidia_1 = require("../common/nvidia");
9
10
  const raspberry_1 = require("../common/raspberry");
10
- const readSysfs = async (file) => {
11
- try {
12
- return (await (0, promises_1.readFile)(file, 'utf8')).trim();
13
- }
14
- catch {
15
- return '';
16
- }
17
- };
18
- const readSysfsNumber = async (files, divisor = 1) => {
11
+ const security_1 = require("../common/security");
12
+ const readSysfsNumber = async (files, divisor = 1, preferNonZero = false) => {
13
+ let fallback = null;
19
14
  for (const file of files) {
20
- const value = Number.parseFloat(await readSysfs(file));
21
- if (!Number.isNaN(value)) {
15
+ const value = Number.parseFloat(await (0, files_1.readSysfs)(file));
16
+ if (Number.isNaN(value)) {
17
+ continue;
18
+ }
19
+ if (!preferNonZero || value !== 0) {
22
20
  return value / divisor;
23
21
  }
22
+ fallback = 0;
24
23
  }
25
- return null;
24
+ return fallback;
26
25
  };
27
26
  const parseAmdClock = (stdout) => {
28
27
  const line = stdout.split('\n').find((l) => l.includes('*'));
29
28
  const value = line ? Number.parseFloat(line.replace(/^\d+:\s*/, '')) : Number.NaN;
30
29
  return Number.isNaN(value) ? null : value;
31
30
  };
31
+ const INTEGRATED_DRM_DRIVERS = ['i915', 'xe'];
32
32
  const drmDevices = async (drmPath = '/sys/class/drm') => {
33
33
  const devices = [];
34
34
  let cards = [];
@@ -51,32 +51,99 @@ const drmDevices = async (drmPath = '/sys/class/drm') => {
51
51
  if (!/^[\da-f]{2}:[\da-f]{2}\.[\da-f]$/i.test(busAddress)) {
52
52
  continue;
53
53
  }
54
+ let driver = '';
55
+ try {
56
+ driver = (await (0, promises_1.readlink)(`${devicePath}/driver`)).split('/').pop() || '';
57
+ }
58
+ catch { }
54
59
  let hwmon = [];
55
60
  try {
56
- hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).map((node) => `${devicePath}/hwmon/${node}`);
61
+ hwmon = (await (0, promises_1.readdir)(`${devicePath}/hwmon`)).filter(security_1.isSafePathSegment).map((node) => `${devicePath}/hwmon/${node}`);
57
62
  }
58
63
  catch { }
59
64
  const clockCore = await readSysfsNumber([
60
65
  `${cardPath}/gt_act_freq_mhz`,
61
66
  `${cardPath}/gt_cur_freq_mhz`,
62
67
  `${cardPath}/gt/gt0/rps_act_freq_mhz`,
68
+ `${cardPath}/gt/gt0/rps_cur_freq_mhz`,
63
69
  `${devicePath}/tile0/gt0/freq0/act_freq`,
64
70
  `${devicePath}/tile0/gt0/freq0/cur_freq`
65
- ]);
71
+ ], 1, true);
72
+ const memoryTotal = await readSysfsNumber([`${devicePath}/mem_info_vram_total`, `${cardPath}/lmem_total_bytes`, `${devicePath}/tile0/physical_vram_size_bytes`], 1024 * 1024, true);
66
73
  devices.push({
67
74
  busAddress,
75
+ sharedMemory: INTEGRATED_DRM_DRIVERS.includes(driver) && !memoryTotal,
68
76
  utilizationGpu: await readSysfsNumber([`${devicePath}/gpu_busy_percent`]),
69
- memoryTotal: await readSysfsNumber([`${devicePath}/mem_info_vram_total`], 1024 * 1024),
77
+ memoryTotal,
70
78
  memoryUsed: await readSysfsNumber([`${devicePath}/mem_info_vram_used`], 1024 * 1024),
71
79
  temperatureGpu: await readSysfsNumber(hwmon.map((node) => `${node}/temp1_input`), 1000),
72
80
  powerDraw: await readSysfsNumber(hwmon.map((node) => `${node}/power1_input`), 1000000),
73
81
  powerLimit: await readSysfsNumber(hwmon.map((node) => `${node}/power1_max`), 1000000),
74
- clockCore: clockCore !== null ? clockCore : parseAmdClock(await readSysfs(`${devicePath}/pp_dpm_sclk`))
82
+ clockCore: clockCore !== null ? clockCore : parseAmdClock(await (0, files_1.readSysfs)(`${devicePath}/pp_dpm_sclk`))
75
83
  });
76
84
  }
77
85
  return devices;
78
86
  };
79
87
  exports.drmDevices = drmDevices;
88
+ const readDeviceTree = async (file) => (await (0, files_1.readSysfs)(file)).replace(/\0/g, '\n').trim();
89
+ const tegraClock = async (root) => {
90
+ let nodes = [];
91
+ try {
92
+ nodes = (await (0, promises_1.readdir)(`${root}/sys/class/devfreq`)).filter(security_1.isSafePathSegment);
93
+ }
94
+ catch {
95
+ return null;
96
+ }
97
+ const gpuNodes = nodes.filter((node) => /\.(gpu|gm20b|gp10b|gv11b|ga10b)$/.test(node)).sort();
98
+ return await readSysfsNumber(gpuNodes.map((node) => `${root}/sys/class/devfreq/${node}/cur_freq`), 1000000, true);
99
+ };
100
+ const tegraTemperature = async (root) => {
101
+ let zones = [];
102
+ try {
103
+ zones = (await (0, promises_1.readdir)(`${root}/sys/class/thermal`)).filter((zone) => zone.startsWith('thermal_zone') && (0, security_1.isSafePathSegment)(zone)).sort();
104
+ }
105
+ catch {
106
+ return null;
107
+ }
108
+ for (const zone of zones) {
109
+ if ((await (0, files_1.readSysfs)(`${root}/sys/class/thermal/${zone}/type`)).toLowerCase().startsWith('gpu')) {
110
+ return await readSysfsNumber([`${root}/sys/class/thermal/${zone}/temp`], 1000);
111
+ }
112
+ }
113
+ return null;
114
+ };
115
+ const tegraSoc = (compatible) => {
116
+ const match = /nvidia,(tegra\d+)/.exec(compatible);
117
+ return match ? match[1].charAt(0).toUpperCase() + match[1].slice(1) : '';
118
+ };
119
+ const tegraDevice = async (root = '') => {
120
+ const compatible = (await readDeviceTree(`${root}/proc/device-tree/compatible`)).toLowerCase();
121
+ if (!compatible.includes('nvidia,tegra')) {
122
+ return null;
123
+ }
124
+ const model = (await readDeviceTree(`${root}/proc/device-tree/model`)) || tegraSoc(compatible);
125
+ const load = await readSysfsNumber([`${root}/sys/devices/platform/gpu.0/load`, `${root}/sys/devices/gpu.0/load`]);
126
+ const temperatureGpu = await tegraTemperature(root);
127
+ const clockCore = await tegraClock(root);
128
+ const result = {
129
+ vendor: 'NVIDIA',
130
+ model: model || 'Tegra',
131
+ bus: '',
132
+ vram: null,
133
+ vramDynamic: true
134
+ };
135
+ if (load !== null) {
136
+ result.utilizationGpu = Math.min(100, Math.round(load) / 10);
137
+ }
138
+ if (temperatureGpu !== null) {
139
+ result.temperatureGpu = temperatureGpu;
140
+ }
141
+ if (clockCore !== null) {
142
+ result.clockCore = clockCore;
143
+ }
144
+ return result;
145
+ };
146
+ exports.tegraDevice = tegraDevice;
80
147
  const mergeControllerDrm = (controller, drm) => {
81
148
  if (!drm) {
82
149
  return controller;
@@ -86,10 +153,8 @@ const mergeControllerDrm = (controller, drm) => {
86
153
  }
87
154
  if (controller.memoryTotal === undefined && drm.memoryTotal) {
88
155
  controller.memoryTotal = drm.memoryTotal;
89
- if (controller.vram === null) {
90
- controller.vram = drm.memoryTotal;
91
- controller.vramDynamic = false;
92
- }
156
+ controller.vram = Math.round(drm.memoryTotal);
157
+ controller.vramDynamic = false;
93
158
  }
94
159
  if (controller.memoryUsed === undefined && drm.memoryUsed !== null) {
95
160
  controller.memoryUsed = drm.memoryUsed;
@@ -109,6 +174,10 @@ const mergeControllerDrm = (controller, drm) => {
109
174
  if (controller.clockCore === undefined && drm.clockCore !== null) {
110
175
  controller.clockCore = drm.clockCore;
111
176
  }
177
+ if (drm.sharedMemory) {
178
+ controller.vram = null;
179
+ controller.vramDynamic = true;
180
+ }
112
181
  return controller;
113
182
  };
114
183
  exports.mergeControllerDrm = mergeControllerDrm;
@@ -127,7 +196,7 @@ const parseLinesLinuxControllers = async (lines) => {
127
196
  let isGraphicsController = false;
128
197
  let pciIDs = [];
129
198
  try {
130
- const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null; unset LC_ALL | grep "Bus Address: "', const_1.execOptsLinux);
199
+ const { stdout } = await (0, exec_1.exec)('export LC_ALL=C; dmidecode -t 9 2>/dev/null | grep "Bus Address: "', const_1.execOptsLinux);
131
200
  pciIDs = stdout.split('\n');
132
201
  for (let i = 0; i < pciIDs.length; i++) {
133
202
  pciIDs[i] = pciIDs[i].replace('Bus Address:', '').replace('0000:', '').trim();
@@ -376,6 +445,12 @@ const gpu = async () => {
376
445
  catch { }
377
446
  }
378
447
  catch { }
448
+ if (!result.length) {
449
+ const tegra = await (0, exports.tegraDevice)();
450
+ if (tegra) {
451
+ result.push(tegra);
452
+ }
453
+ }
379
454
  }
380
455
  catch { }
381
456
  return result;
@@ -11,6 +11,7 @@ export { cpuCache } from './cpu-cache';
11
11
  export { cpuCurrentSpeed } from '../cpu-current-speed';
12
12
  export { cpuFlags } from './cpu-flags';
13
13
  export { cpuTemperature } from './cpu-temperature';
14
+ export { fans } from './fans';
14
15
  export { currentLoad } from '../cpu-current-load';
15
16
  export { diskLayout } from './disk-layout';
16
17
  export { disksIO } from './disks-io';
@@ -39,12 +40,14 @@ export { pci } from './pci';
39
40
  export { printer } from './printer';
40
41
  export { processes } from './processes';
41
42
  export { processLoad } from './process-load';
43
+ export { processFocused } from './process-focused';
42
44
  export { services } from './services';
43
45
  export { shell } from '../shell';
44
46
  export { software } from './software';
45
47
  export { system } from './system';
46
48
  export { thunderbolt } from './thunderbolt';
47
49
  export { time } from '../time';
50
+ export { serialPorts } from './serial-ports';
48
51
  export { usb } from './usb';
49
52
  export { users } from './users';
50
53
  export { uuid } from './uuid';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.software = exports.shell = exports.services = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
- exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.time = exports.thunderbolt = exports.system = void 0;
3
+ exports.services = exports.processFocused = exports.processLoad = exports.processes = exports.printer = exports.pci = exports.osInfo = exports.npu = exports.npm = exports.networkStats = exports.networkInterfaces = exports.networkInterfaceDefault = exports.networkGatewayDefault = exports.networkConnections = exports.mouse = exports.memLayout = exports.mem = exports.keyboard = exports.inetLatency = exports.inetChecksite = exports.gpu = exports.fullLoad = exports.fsStats = exports.fsSize = exports.fsOpenFiles = exports.dockerAll = exports.dockerVolumes = exports.dockerContainerProcesses = exports.dockerContainerStats = exports.dockerContainers = exports.dockerImages = exports.dockerInfo = exports.displays = exports.disksIO = exports.diskLayout = exports.currentLoad = exports.fans = exports.cpuTemperature = exports.cpuFlags = exports.cpuCurrentSpeed = exports.cpuCache = exports.cpu = exports.chassis = exports.camera = exports.bluetoothDevices = exports.blockDevices = exports.bios = exports.battery = exports.baseboard = exports.audio = void 0;
4
+ exports.wifiNetworks = exports.wifiInterfaces = exports.wifiConnections = exports.versions = exports.version = exports.vboxInfo = exports.uuid = exports.users = exports.usb = exports.serialPorts = exports.time = exports.thunderbolt = exports.system = exports.software = exports.shell = void 0;
5
5
  var audio_1 = require("./audio");
6
6
  Object.defineProperty(exports, "audio", { enumerable: true, get: function () { return audio_1.audio; } });
7
7
  var baseboard_1 = require("./baseboard");
@@ -28,6 +28,8 @@ var cpu_flags_1 = require("./cpu-flags");
28
28
  Object.defineProperty(exports, "cpuFlags", { enumerable: true, get: function () { return cpu_flags_1.cpuFlags; } });
29
29
  var cpu_temperature_1 = require("./cpu-temperature");
30
30
  Object.defineProperty(exports, "cpuTemperature", { enumerable: true, get: function () { return cpu_temperature_1.cpuTemperature; } });
31
+ var fans_1 = require("./fans");
32
+ Object.defineProperty(exports, "fans", { enumerable: true, get: function () { return fans_1.fans; } });
31
33
  var cpu_current_load_1 = require("../cpu-current-load");
32
34
  Object.defineProperty(exports, "currentLoad", { enumerable: true, get: function () { return cpu_current_load_1.currentLoad; } });
33
35
  var disk_layout_1 = require("./disk-layout");
@@ -90,6 +92,8 @@ var processes_1 = require("./processes");
90
92
  Object.defineProperty(exports, "processes", { enumerable: true, get: function () { return processes_1.processes; } });
91
93
  var process_load_1 = require("./process-load");
92
94
  Object.defineProperty(exports, "processLoad", { enumerable: true, get: function () { return process_load_1.processLoad; } });
95
+ var process_focused_1 = require("./process-focused");
96
+ Object.defineProperty(exports, "processFocused", { enumerable: true, get: function () { return process_focused_1.processFocused; } });
93
97
  var services_1 = require("./services");
94
98
  Object.defineProperty(exports, "services", { enumerable: true, get: function () { return services_1.services; } });
95
99
  var shell_1 = require("../shell");
@@ -102,6 +106,8 @@ var thunderbolt_1 = require("./thunderbolt");
102
106
  Object.defineProperty(exports, "thunderbolt", { enumerable: true, get: function () { return thunderbolt_1.thunderbolt; } });
103
107
  var time_1 = require("../time");
104
108
  Object.defineProperty(exports, "time", { enumerable: true, get: function () { return time_1.time; } });
109
+ var serial_ports_1 = require("./serial-ports");
110
+ Object.defineProperty(exports, "serialPorts", { enumerable: true, get: function () { return serial_ports_1.serialPorts; } });
105
111
  var usb_1 = require("./usb");
106
112
  Object.defineProperty(exports, "usb", { enumerable: true, get: function () { return usb_1.usb; } });
107
113
  var users_1 = require("./users");
@@ -5,6 +5,7 @@ const node_os_1 = require("node:os");
5
5
  const common_1 = require("../common");
6
6
  const const_1 = require("../common/const");
7
7
  const exec_1 = require("../common/exec");
8
+ const files_1 = require("../common/files");
8
9
  const mappings_1 = require("../common/mappings");
9
10
  const raspberry_1 = require("../common/raspberry");
10
11
  const memLayout = async () => {
@@ -30,11 +31,7 @@ const memLayout = async () => {
30
31
  channel: null,
31
32
  type: (0, common_1.getValue)(lines, 'Type:'),
32
33
  ecc: dataWidth && totalWidth ? totalWidth > dataWidth : false,
33
- clockSpeed: (0, common_1.getValue)(lines, 'Configured Clock Speed:')
34
- ? parseInt((0, common_1.getValue)(lines, 'Configured Clock Speed:'), 10)
35
- : (0, common_1.getValue)(lines, 'Speed:')
36
- ? parseInt((0, common_1.getValue)(lines, 'Speed:'), 10)
37
- : null,
34
+ clockSpeed: (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Memory Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Configured Clock Speed:')) || (0, common_1.toInt)((0, common_1.getValue)(lines, 'Speed:')) || null,
38
35
  formFactor: (0, common_1.getValue)(lines, 'Form Factor:'),
39
36
  manufacturer: (0, mappings_1.getMemManufacturer)((0, common_1.getValue)(lines, 'Manufacturer:')),
40
37
  partNum: (0, common_1.getValue)(lines, 'Part Number:'),
@@ -78,8 +75,7 @@ const memLayout = async () => {
78
75
  voltageMin: null,
79
76
  voltageMax: null
80
77
  });
81
- ({ stdout } = await (0, exec_1.exec)('cat /proc/cpuinfo 2>/dev/null', const_1.execOptsLinux));
82
- let lines = stdout.split('\n');
78
+ let lines = await (0, files_1.readFileLines)('/proc/cpuinfo');
83
79
  const version = (0, common_1.getValue)(lines, 'revision', ':', true).toLowerCase();
84
80
  if (await (0, raspberry_1.isRaspberry)(lines)) {
85
81
  result[0].type = 'LPDDR2';
@@ -1,2 +1,3 @@
1
1
  import type { MemData } from '../common/types';
2
+ export declare const parseArcstats: (lines: string[]) => number;
2
3
  export declare const mem: () => Promise<MemData>;
package/dist/linux/mem.js CHANGED
@@ -1,10 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mem = void 0;
3
+ exports.mem = exports.parseArcstats = void 0;
4
4
  const promises_1 = require("node:fs/promises");
5
5
  const node_os_1 = require("node:os");
6
6
  const common_1 = require("../common");
7
7
  const defaults_1 = require("../common/defaults");
8
+ const files_1 = require("../common/files");
9
+ const parseArcstats = (lines) => {
10
+ let size = 0;
11
+ let cMin = 0;
12
+ for (const line of lines) {
13
+ const parts = line.trim().split(/\s+/);
14
+ if (parts.length < 3) {
15
+ continue;
16
+ }
17
+ if (parts[0] === 'size') {
18
+ size = (0, common_1.toInt)(parts[2]);
19
+ }
20
+ else if (parts[0] === 'c_min') {
21
+ cMin = (0, common_1.toInt)(parts[2]);
22
+ }
23
+ }
24
+ return Math.max(size - cMin, 0);
25
+ };
26
+ exports.parseArcstats = parseArcstats;
8
27
  const mem = async () => {
9
28
  await (0, common_1.nextTick)();
10
29
  const defaults = (0, common_1.cloneObj)(defaults_1.initMemData);
@@ -25,6 +44,7 @@ const mem = async () => {
25
44
  const buffcache = buffers + cached + slab;
26
45
  let available = (0, common_1.toInt)((0, common_1.getValue)(lines, 'memavailable'));
27
46
  available = available ? available * 1024 : free + buffcache;
47
+ available = Math.min(total, available + (0, exports.parseArcstats)(await (0, files_1.readFileLines)('/proc/spl/kstat/zfs/arcstats')));
28
48
  const active = total - available;
29
49
  let swaptotal = (0, common_1.toInt)((0, common_1.getValue)(lines, 'swaptotal'));
30
50
  swaptotal = swaptotal ? swaptotal * 1024 : 0;
@@ -1,3 +1,4 @@
1
1
  import type { NetworkInterfacesData } from '../common/types';
2
2
  export declare const checkLinuxDCHPInterfaces: (file: string, depth?: number) => Promise<any[]>;
3
+ export declare const pciSlotFromPath: (path: string) => string | null;
3
4
  export declare const networkInterfaces: (defaultString?: string, rescan?: boolean) => Promise<NetworkInterfacesData[]>;