systeminformation 5.33.5 → 6.0.0-beta.1

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 (498) hide show
  1. package/README.md +873 -958
  2. package/dist/audio.d.ts +1 -0
  3. package/dist/audio.js +18 -0
  4. package/dist/baseboard.d.ts +1 -0
  5. package/dist/baseboard.js +17 -0
  6. package/dist/battery.d.ts +1 -0
  7. package/dist/battery.js +19 -0
  8. package/dist/bios.d.ts +1 -0
  9. package/dist/bios.js +17 -0
  10. package/dist/block-devices.d.ts +1 -0
  11. package/dist/block-devices.js +17 -0
  12. package/dist/bluetooth.d.ts +1 -0
  13. package/dist/bluetooth.js +17 -0
  14. package/dist/bsd/battery.d.ts +2 -0
  15. package/dist/bsd/battery.js +27 -0
  16. package/dist/bsd/cpu-cache.d.ts +1 -0
  17. package/dist/bsd/cpu-cache.js +37 -0
  18. package/dist/bsd/cpu-flags.d.ts +1 -0
  19. package/dist/bsd/cpu-flags.js +28 -0
  20. package/dist/bsd/cpu-temperature.d.ts +1 -0
  21. package/dist/bsd/cpu-temperature.js +29 -0
  22. package/dist/bsd/cpu.d.ts +1 -0
  23. package/dist/bsd/cpu.js +98 -0
  24. package/dist/bsd/index.d.ts +38 -0
  25. package/dist/bsd/index.js +85 -0
  26. package/dist/bsd/mem.d.ts +1 -0
  27. package/dist/bsd/mem.js +37 -0
  28. package/dist/bsd/network-stats.d.ts +2 -0
  29. package/dist/bsd/network-stats.js +92 -0
  30. package/dist/bsd/os-info.d.ts +24 -0
  31. package/dist/bsd/os-info.js +47 -0
  32. package/dist/bsd/uuid.d.ts +2 -0
  33. package/dist/bsd/uuid.js +30 -0
  34. package/dist/camera.d.ts +1 -0
  35. package/dist/camera.js +17 -0
  36. package/dist/chassis.d.ts +1 -0
  37. package/dist/chassis.js +17 -0
  38. package/dist/cli.d.ts +2 -0
  39. package/dist/cli.js +107 -0
  40. package/dist/common/acceleration.d.ts +8 -0
  41. package/dist/common/acceleration.js +86 -0
  42. package/dist/common/codepage.d.ts +1 -0
  43. package/dist/common/codepage.js +43 -0
  44. package/dist/common/const.d.ts +25 -0
  45. package/dist/common/const.js +26 -0
  46. package/dist/common/cpu.d.ts +2 -0
  47. package/dist/common/cpu.js +12 -0
  48. package/dist/common/darwin.d.ts +6 -0
  49. package/dist/common/darwin.js +266 -0
  50. package/dist/common/datetime.d.ts +9 -0
  51. package/dist/common/datetime.js +161 -0
  52. package/dist/common/defaults.d.ts +25 -0
  53. package/dist/common/defaults.js +304 -0
  54. package/dist/common/exec.d.ts +10 -0
  55. package/dist/common/exec.js +69 -0
  56. package/dist/common/files.d.ts +2 -0
  57. package/dist/common/files.js +39 -0
  58. package/dist/common/filesys.d.ts +11 -0
  59. package/dist/common/filesys.js +282 -0
  60. package/dist/common/host.d.ts +2 -0
  61. package/dist/common/host.js +67 -0
  62. package/dist/common/index.d.ts +12 -0
  63. package/dist/common/index.js +146 -0
  64. package/dist/common/internet.d.ts +6 -0
  65. package/dist/common/internet.js +92 -0
  66. package/dist/common/mappings.d.ts +55 -0
  67. package/dist/common/mappings.js +4133 -0
  68. package/dist/common/network.d.ts +8 -0
  69. package/dist/common/network.js +162 -0
  70. package/dist/common/nvidia.d.ts +22 -0
  71. package/dist/common/nvidia.js +159 -0
  72. package/dist/common/parse.d.ts +13 -0
  73. package/dist/common/parse.js +157 -0
  74. package/dist/common/raspberry.d.ts +5 -0
  75. package/dist/common/raspberry.js +277 -0
  76. package/dist/common/security.d.ts +31 -0
  77. package/dist/common/security.js +241 -0
  78. package/dist/common/types.d.ts +1024 -0
  79. package/dist/common/types.js +2 -0
  80. package/dist/common/windows.d.ts +58 -0
  81. package/dist/common/windows.js +292 -0
  82. package/dist/cpu-cache.d.ts +1 -0
  83. package/dist/cpu-cache.js +19 -0
  84. package/dist/cpu-current-load.d.ts +2 -0
  85. package/dist/cpu-current-load.js +249 -0
  86. package/dist/cpu-current-speed.d.ts +3 -0
  87. package/dist/cpu-current-speed.js +84 -0
  88. package/dist/cpu-flags.d.ts +1 -0
  89. package/dist/cpu-flags.js +19 -0
  90. package/dist/cpu-full-load.d.ts +1 -0
  91. package/dist/cpu-full-load.js +30 -0
  92. package/dist/cpu-temperature.d.ts +1 -0
  93. package/dist/cpu-temperature.js +19 -0
  94. package/dist/cpu.d.ts +1 -0
  95. package/dist/cpu.js +19 -0
  96. package/dist/darwin/audio.d.ts +2 -0
  97. package/dist/darwin/audio.js +46 -0
  98. package/dist/darwin/baseboard.d.ts +1 -0
  99. package/dist/darwin/baseboard.js +48 -0
  100. package/dist/darwin/battery.d.ts +2 -0
  101. package/dist/darwin/battery.js +65 -0
  102. package/dist/darwin/bios.d.ts +1 -0
  103. package/dist/darwin/bios.js +45 -0
  104. package/dist/darwin/block-devices.d.ts +2 -0
  105. package/dist/darwin/block-devices.js +101 -0
  106. package/dist/darwin/bluetooth.d.ts +3 -0
  107. package/dist/darwin/bluetooth.js +84 -0
  108. package/dist/darwin/camera.d.ts +2 -0
  109. package/dist/darwin/camera.js +55 -0
  110. package/dist/darwin/chassis.d.ts +2 -0
  111. package/dist/darwin/chassis.js +32 -0
  112. package/dist/darwin/cpu-cache.d.ts +2 -0
  113. package/dist/darwin/cpu-cache.js +29 -0
  114. package/dist/darwin/cpu-flags.d.ts +1 -0
  115. package/dist/darwin/cpu-flags.js +16 -0
  116. package/dist/darwin/cpu-temperature.d.ts +1 -0
  117. package/dist/darwin/cpu-temperature.js +44 -0
  118. package/dist/darwin/cpu.d.ts +1 -0
  119. package/dist/darwin/cpu.js +69 -0
  120. package/dist/darwin/disk-layout.d.ts +2 -0
  121. package/dist/darwin/disk-layout.js +231 -0
  122. package/dist/darwin/disks-io.d.ts +2 -0
  123. package/dist/darwin/disks-io.js +56 -0
  124. package/dist/darwin/displays.d.ts +2 -0
  125. package/dist/darwin/displays.js +98 -0
  126. package/dist/darwin/fs-open-files.d.ts +2 -0
  127. package/dist/darwin/fs-open-files.js +27 -0
  128. package/dist/darwin/fs-stats.d.ts +2 -0
  129. package/dist/darwin/fs-stats.js +47 -0
  130. package/dist/darwin/gpu.d.ts +2 -0
  131. package/dist/darwin/gpu.js +55 -0
  132. package/dist/darwin/index.d.ts +56 -0
  133. package/dist/darwin/index.js +122 -0
  134. package/dist/darwin/keyboard.d.ts +2 -0
  135. package/dist/darwin/keyboard.js +73 -0
  136. package/dist/darwin/mem-layout.d.ts +2 -0
  137. package/dist/darwin/mem-layout.js +60 -0
  138. package/dist/darwin/mem.d.ts +2 -0
  139. package/dist/darwin/mem.js +50 -0
  140. package/dist/darwin/mouse.d.ts +2 -0
  141. package/dist/darwin/mouse.js +78 -0
  142. package/dist/darwin/network-connections.d.ts +2 -0
  143. package/dist/darwin/network-connections.js +98 -0
  144. package/dist/darwin/network-gateway-default.d.ts +1 -0
  145. package/dist/darwin/network-gateway-default.js +26 -0
  146. package/dist/darwin/network-interface-default.d.ts +2 -0
  147. package/dist/darwin/network-interface-default.js +41 -0
  148. package/dist/darwin/network-interfaces.d.ts +2 -0
  149. package/dist/darwin/network-interfaces.js +205 -0
  150. package/dist/darwin/network-stats.d.ts +2 -0
  151. package/dist/darwin/network-stats.js +86 -0
  152. package/dist/darwin/npm.d.ts +1 -0
  153. package/dist/darwin/npm.js +5 -0
  154. package/dist/darwin/npu.d.ts +2 -0
  155. package/dist/darwin/npu.js +41 -0
  156. package/dist/darwin/os-info.d.ts +2 -0
  157. package/dist/darwin/os-info.js +140 -0
  158. package/dist/darwin/pci.d.ts +2 -0
  159. package/dist/darwin/pci.js +37 -0
  160. package/dist/darwin/printer.d.ts +2 -0
  161. package/dist/darwin/printer.js +45 -0
  162. package/dist/darwin/software.d.ts +2 -0
  163. package/dist/darwin/software.js +39 -0
  164. package/dist/darwin/system.d.ts +1 -0
  165. package/dist/darwin/system.js +29 -0
  166. package/dist/darwin/thunderbolt.d.ts +1 -0
  167. package/dist/darwin/thunderbolt.js +53 -0
  168. package/dist/darwin/usb.d.ts +3 -0
  169. package/dist/darwin/usb.js +69 -0
  170. package/dist/darwin/users.d.ts +2 -0
  171. package/dist/darwin/users.js +13 -0
  172. package/dist/darwin/uuid.d.ts +2 -0
  173. package/dist/darwin/uuid.js +39 -0
  174. package/dist/darwin/wifi-connections.d.ts +2 -0
  175. package/dist/darwin/wifi-connections.js +60 -0
  176. package/dist/darwin/wifi-interfaces.d.ts +2 -0
  177. package/dist/darwin/wifi-interfaces.js +27 -0
  178. package/dist/darwin/wifi-networks.d.ts +2 -0
  179. package/dist/darwin/wifi-networks.js +61 -0
  180. package/dist/disk-layout.d.ts +1 -0
  181. package/dist/disk-layout.js +17 -0
  182. package/dist/disks-io.d.ts +1 -0
  183. package/dist/disks-io.js +17 -0
  184. package/dist/displays.d.ts +1 -0
  185. package/dist/displays.js +17 -0
  186. package/dist/docker-socket.d.ts +11 -0
  187. package/dist/docker-socket.js +113 -0
  188. package/dist/docker.d.ts +102 -0
  189. package/dist/docker.js +532 -0
  190. package/dist/fs-open-files.d.ts +1 -0
  191. package/dist/fs-open-files.js +17 -0
  192. package/dist/fs-size.d.ts +1 -0
  193. package/dist/fs-size.js +23 -0
  194. package/dist/fs-stats.d.ts +1 -0
  195. package/dist/fs-stats.js +17 -0
  196. package/dist/get-data.d.ts +110 -0
  197. package/dist/get-data.js +151 -0
  198. package/dist/get.d.ts +5 -0
  199. package/dist/get.js +117 -0
  200. package/dist/gpu.d.ts +1 -0
  201. package/dist/gpu.js +17 -0
  202. package/dist/index.d.ts +60 -0
  203. package/dist/index.js +132 -0
  204. package/dist/inet-checksite.d.ts +1 -0
  205. package/dist/inet-checksite.js +11 -0
  206. package/dist/inet-latency.d.ts +1 -0
  207. package/dist/inet-latency.js +17 -0
  208. package/dist/inet-public-ip.d.ts +2 -0
  209. package/dist/inet-public-ip.js +10 -0
  210. package/dist/keyboard.d.ts +1 -0
  211. package/dist/keyboard.js +17 -0
  212. package/dist/linux/audio.d.ts +2 -0
  213. package/dist/linux/audio.js +67 -0
  214. package/dist/linux/baseboard.d.ts +1 -0
  215. package/dist/linux/baseboard.js +81 -0
  216. package/dist/linux/battery.d.ts +2 -0
  217. package/dist/linux/battery.js +88 -0
  218. package/dist/linux/bios.d.ts +2 -0
  219. package/dist/linux/bios.js +55 -0
  220. package/dist/linux/block-devices.d.ts +2 -0
  221. package/dist/linux/block-devices.js +30 -0
  222. package/dist/linux/bluetooth.d.ts +2 -0
  223. package/dist/linux/bluetooth.js +86 -0
  224. package/dist/linux/camera.d.ts +2 -0
  225. package/dist/linux/camera.js +63 -0
  226. package/dist/linux/chassis.d.ts +1 -0
  227. package/dist/linux/chassis.js +41 -0
  228. package/dist/linux/cpu-cache.d.ts +1 -0
  229. package/dist/linux/cpu-cache.js +35 -0
  230. package/dist/linux/cpu-flags.d.ts +1 -0
  231. package/dist/linux/cpu-flags.js +33 -0
  232. package/dist/linux/cpu-temperature.d.ts +1 -0
  233. package/dist/linux/cpu-temperature.js +179 -0
  234. package/dist/linux/cpu.d.ts +1 -0
  235. package/dist/linux/cpu.js +135 -0
  236. package/dist/linux/disk-layout.d.ts +2 -0
  237. package/dist/linux/disk-layout.js +151 -0
  238. package/dist/linux/disks-io.d.ts +2 -0
  239. package/dist/linux/disks-io.js +58 -0
  240. package/dist/linux/displays.d.ts +2 -0
  241. package/dist/linux/displays.js +193 -0
  242. package/dist/linux/fs-open-files.d.ts +2 -0
  243. package/dist/linux/fs-open-files.js +44 -0
  244. package/dist/linux/fs-size.d.ts +2 -0
  245. package/dist/linux/fs-size.js +157 -0
  246. package/dist/linux/fs-stats.d.ts +2 -0
  247. package/dist/linux/fs-stats.js +65 -0
  248. package/dist/linux/gpu.d.ts +15 -0
  249. package/dist/linux/gpu.js +383 -0
  250. package/dist/linux/index.d.ts +56 -0
  251. package/dist/linux/index.js +122 -0
  252. package/dist/linux/inet-latency.d.ts +1 -0
  253. package/dist/linux/inet-latency.js +39 -0
  254. package/dist/linux/keyboard.d.ts +2 -0
  255. package/dist/linux/keyboard.js +61 -0
  256. package/dist/linux/mem-layout.d.ts +2 -0
  257. package/dist/linux/mem-layout.js +112 -0
  258. package/dist/linux/mem.d.ts +2 -0
  259. package/dist/linux/mem.js +61 -0
  260. package/dist/linux/mouse.d.ts +2 -0
  261. package/dist/linux/mouse.js +73 -0
  262. package/dist/linux/network-connections.d.ts +2 -0
  263. package/dist/linux/network-connections.js +114 -0
  264. package/dist/linux/network-gateway-default.d.ts +1 -0
  265. package/dist/linux/network-gateway-default.js +22 -0
  266. package/dist/linux/network-interface-default.d.ts +2 -0
  267. package/dist/linux/network-interface-default.js +46 -0
  268. package/dist/linux/network-interfaces.d.ts +3 -0
  269. package/dist/linux/network-interfaces.js +353 -0
  270. package/dist/linux/network-stats.d.ts +2 -0
  271. package/dist/linux/network-stats.js +99 -0
  272. package/dist/linux/npm.d.ts +1 -0
  273. package/dist/linux/npm.js +5 -0
  274. package/dist/linux/npu.d.ts +2 -0
  275. package/dist/linux/npu.js +77 -0
  276. package/dist/linux/os-info.d.ts +1 -0
  277. package/dist/linux/os-info.js +114 -0
  278. package/dist/linux/pci.d.ts +2 -0
  279. package/dist/linux/pci.js +56 -0
  280. package/dist/linux/printer.d.ts +2 -0
  281. package/dist/linux/printer.js +80 -0
  282. package/dist/linux/process-load.d.ts +2 -0
  283. package/dist/linux/process-load.js +164 -0
  284. package/dist/linux/processes.d.ts +2 -0
  285. package/dist/linux/processes.js +358 -0
  286. package/dist/linux/services.d.ts +2 -0
  287. package/dist/linux/services.js +222 -0
  288. package/dist/linux/software.d.ts +2 -0
  289. package/dist/linux/software.js +110 -0
  290. package/dist/linux/system.d.ts +1 -0
  291. package/dist/linux/system.js +186 -0
  292. package/dist/linux/thunderbolt.d.ts +2 -0
  293. package/dist/linux/thunderbolt.js +51 -0
  294. package/dist/linux/time.d.ts +6 -0
  295. package/dist/linux/time.js +28 -0
  296. package/dist/linux/usb.d.ts +2 -0
  297. package/dist/linux/usb.js +62 -0
  298. package/dist/linux/users.d.ts +2 -0
  299. package/dist/linux/users.js +102 -0
  300. package/dist/linux/uuid.d.ts +2 -0
  301. package/dist/linux/uuid.js +44 -0
  302. package/dist/linux/wifi-connections.d.ts +2 -0
  303. package/dist/linux/wifi-connections.js +196 -0
  304. package/dist/linux/wifi-interfaces.d.ts +2 -0
  305. package/dist/linux/wifi-interfaces.js +96 -0
  306. package/dist/linux/wifi-networks.d.ts +2 -0
  307. package/dist/linux/wifi-networks.js +176 -0
  308. package/dist/mem-layout.d.ts +1 -0
  309. package/dist/mem-layout.js +17 -0
  310. package/dist/mem.d.ts +1 -0
  311. package/dist/mem.js +19 -0
  312. package/dist/mouse.d.ts +1 -0
  313. package/dist/mouse.js +17 -0
  314. package/dist/network-connections.d.ts +1 -0
  315. package/dist/network-connections.js +17 -0
  316. package/dist/network-gateway-default.d.ts +1 -0
  317. package/dist/network-gateway-default.js +17 -0
  318. package/dist/network-interface-default.d.ts +1 -0
  319. package/dist/network-interface-default.js +17 -0
  320. package/dist/network-interfaces.d.ts +1 -0
  321. package/dist/network-interfaces.js +18 -0
  322. package/dist/network-stats.d.ts +1 -0
  323. package/dist/network-stats.js +19 -0
  324. package/dist/npm.d.ts +2 -0
  325. package/dist/npm.js +22 -0
  326. package/dist/npu.d.ts +1 -0
  327. package/dist/npu.js +17 -0
  328. package/dist/observe.d.ts +5 -0
  329. package/dist/observe.js +16 -0
  330. package/dist/os-info.d.ts +1 -0
  331. package/dist/os-info.js +21 -0
  332. package/dist/pci.d.ts +1 -0
  333. package/dist/pci.js +17 -0
  334. package/dist/printer.d.ts +1 -0
  335. package/dist/printer.js +17 -0
  336. package/dist/process-load.d.ts +1 -0
  337. package/dist/process-load.js +15 -0
  338. package/dist/processes.d.ts +1 -0
  339. package/dist/processes.js +15 -0
  340. package/dist/services.d.ts +1 -0
  341. package/dist/services.js +15 -0
  342. package/dist/shell.d.ts +1 -0
  343. package/dist/shell.js +16 -0
  344. package/dist/software.d.ts +1 -0
  345. package/dist/software.js +17 -0
  346. package/dist/sun/index.d.ts +17 -0
  347. package/dist/sun/index.js +43 -0
  348. package/dist/sun/inet-latency.d.ts +1 -0
  349. package/dist/sun/inet-latency.js +30 -0
  350. package/dist/sun/os-info.d.ts +1 -0
  351. package/dist/sun/os-info.js +26 -0
  352. package/dist/sun/users.d.ts +2 -0
  353. package/dist/sun/users.js +13 -0
  354. package/dist/system.d.ts +1 -0
  355. package/dist/system.js +17 -0
  356. package/dist/thunderbolt.d.ts +1 -0
  357. package/dist/thunderbolt.js +17 -0
  358. package/dist/time.d.ts +6 -0
  359. package/dist/time.js +28 -0
  360. package/dist/usb.d.ts +1 -0
  361. package/dist/usb.js +17 -0
  362. package/dist/users.d.ts +1 -0
  363. package/dist/users.js +21 -0
  364. package/dist/uuid.d.ts +1 -0
  365. package/dist/uuid.js +19 -0
  366. package/dist/version.d.ts +1 -0
  367. package/dist/version.js +16 -0
  368. package/dist/versions.d.ts +2 -0
  369. package/dist/versions.js +1150 -0
  370. package/dist/virtualbox.d.ts +2 -0
  371. package/dist/virtualbox.js +89 -0
  372. package/dist/wifi-connections.d.ts +1 -0
  373. package/dist/wifi-connections.js +17 -0
  374. package/dist/wifi-interfaces.d.ts +1 -0
  375. package/dist/wifi-interfaces.js +17 -0
  376. package/dist/wifi-networks.d.ts +1 -0
  377. package/dist/wifi-networks.js +17 -0
  378. package/dist/windows/audio.d.ts +2 -0
  379. package/dist/windows/audio.js +23 -0
  380. package/dist/windows/baseboard.d.ts +1 -0
  381. package/dist/windows/baseboard.js +35 -0
  382. package/dist/windows/battery.d.ts +1 -0
  383. package/dist/windows/battery.js +81 -0
  384. package/dist/windows/bios.d.ts +1 -0
  385. package/dist/windows/bios.js +37 -0
  386. package/dist/windows/block-devices.d.ts +3 -0
  387. package/dist/windows/block-devices.js +58 -0
  388. package/dist/windows/bluetooth.d.ts +2 -0
  389. package/dist/windows/bluetooth.js +31 -0
  390. package/dist/windows/camera.d.ts +2 -0
  391. package/dist/windows/camera.js +47 -0
  392. package/dist/windows/chassis.d.ts +1 -0
  393. package/dist/windows/chassis.js +29 -0
  394. package/dist/windows/cpu-cache.d.ts +2 -0
  395. package/dist/windows/cpu-cache.js +59 -0
  396. package/dist/windows/cpu-flags.d.ts +1 -0
  397. package/dist/windows/cpu-flags.js +61 -0
  398. package/dist/windows/cpu-temperature.d.ts +1 -0
  399. package/dist/windows/cpu-temperature.js +32 -0
  400. package/dist/windows/cpu.d.ts +1 -0
  401. package/dist/windows/cpu.js +96 -0
  402. package/dist/windows/disk-layout.d.ts +2 -0
  403. package/dist/windows/disk-layout.js +129 -0
  404. package/dist/windows/disks-io.d.ts +2 -0
  405. package/dist/windows/disks-io.js +46 -0
  406. package/dist/windows/displays.d.ts +2 -0
  407. package/dist/windows/displays.js +213 -0
  408. package/dist/windows/fs-open-files.d.ts +2 -0
  409. package/dist/windows/fs-open-files.js +22 -0
  410. package/dist/windows/fs-size.d.ts +2 -0
  411. package/dist/windows/fs-size.js +47 -0
  412. package/dist/windows/fs-stats.d.ts +2 -0
  413. package/dist/windows/fs-stats.js +37 -0
  414. package/dist/windows/gpu.d.ts +2 -0
  415. package/dist/windows/gpu.js +128 -0
  416. package/dist/windows/index.d.ts +56 -0
  417. package/dist/windows/index.js +122 -0
  418. package/dist/windows/inet-latency.d.ts +1 -0
  419. package/dist/windows/inet-latency.js +34 -0
  420. package/dist/windows/keyboard.d.ts +2 -0
  421. package/dist/windows/keyboard.js +47 -0
  422. package/dist/windows/mem-layout.d.ts +2 -0
  423. package/dist/windows/mem-layout.js +39 -0
  424. package/dist/windows/mem.d.ts +2 -0
  425. package/dist/windows/mem.js +33 -0
  426. package/dist/windows/mouse.d.ts +2 -0
  427. package/dist/windows/mouse.js +64 -0
  428. package/dist/windows/network-connections.d.ts +2 -0
  429. package/dist/windows/network-connections.js +93 -0
  430. package/dist/windows/network-gateway-default.d.ts +1 -0
  431. package/dist/windows/network-gateway-default.js +36 -0
  432. package/dist/windows/network-interface-default.d.ts +2 -0
  433. package/dist/windows/network-interface-default.js +56 -0
  434. package/dist/windows/network-interfaces.d.ts +2 -0
  435. package/dist/windows/network-interfaces.js +346 -0
  436. package/dist/windows/network-stats.d.ts +2 -0
  437. package/dist/windows/network-stats.js +135 -0
  438. package/dist/windows/npm.d.ts +1 -0
  439. package/dist/windows/npm.js +5 -0
  440. package/dist/windows/npu.d.ts +2 -0
  441. package/dist/windows/npu.js +29 -0
  442. package/dist/windows/os-info.d.ts +1 -0
  443. package/dist/windows/os-info.js +70 -0
  444. package/dist/windows/pci.d.ts +2 -0
  445. package/dist/windows/pci.js +33 -0
  446. package/dist/windows/printer.d.ts +2 -0
  447. package/dist/windows/printer.js +36 -0
  448. package/dist/windows/process-load.d.ts +2 -0
  449. package/dist/windows/process-load.js +121 -0
  450. package/dist/windows/processes.d.ts +9 -0
  451. package/dist/windows/processes.js +139 -0
  452. package/dist/windows/services.d.ts +2 -0
  453. package/dist/windows/services.js +83 -0
  454. package/dist/windows/shell.d.ts +1 -0
  455. package/dist/windows/shell.js +19 -0
  456. package/dist/windows/software.d.ts +2 -0
  457. package/dist/windows/software.js +53 -0
  458. package/dist/windows/system.d.ts +1 -0
  459. package/dist/windows/system.js +98 -0
  460. package/dist/windows/thunderbolt.d.ts +2 -0
  461. package/dist/windows/thunderbolt.js +34 -0
  462. package/dist/windows/usb.d.ts +2 -0
  463. package/dist/windows/usb.js +37 -0
  464. package/dist/windows/users.d.ts +2 -0
  465. package/dist/windows/users.js +151 -0
  466. package/dist/windows/uuid.d.ts +2 -0
  467. package/dist/windows/uuid.js +28 -0
  468. package/dist/windows/wifi-connections.d.ts +2 -0
  469. package/dist/windows/wifi-connections.js +56 -0
  470. package/dist/windows/wifi-interfaces.d.ts +2 -0
  471. package/dist/windows/wifi-interfaces.js +45 -0
  472. package/dist/windows/wifi-networks.d.ts +2 -0
  473. package/dist/windows/wifi-networks.js +50 -0
  474. package/package.json +78 -12
  475. package/lib/audio.js +0 -277
  476. package/lib/battery.js +0 -334
  477. package/lib/bluetooth.js +0 -315
  478. package/lib/bluetoothVendors.js +0 -1138
  479. package/lib/cli.js +0 -100
  480. package/lib/cpu.js +0 -2285
  481. package/lib/docker.js +0 -791
  482. package/lib/dockerSocket.js +0 -117
  483. package/lib/filesystem.js +0 -1849
  484. package/lib/graphics.js +0 -1321
  485. package/lib/index.d.ts +0 -1051
  486. package/lib/index.js +0 -520
  487. package/lib/internet.js +0 -259
  488. package/lib/memory.js +0 -622
  489. package/lib/network.js +0 -2008
  490. package/lib/osinfo.js +0 -1322
  491. package/lib/printer.js +0 -209
  492. package/lib/processes.js +0 -1459
  493. package/lib/system.js +0 -855
  494. package/lib/usb.js +0 -309
  495. package/lib/users.js +0 -412
  496. package/lib/util.js +0 -2833
  497. package/lib/virtualbox.js +0 -116
  498. package/lib/wifi.js +0 -839
package/lib/filesystem.js DELETED
@@ -1,1849 +0,0 @@
1
- 'use strict';
2
- // @ts-check
3
- // ==================================================================================
4
- // filesystem.js
5
- // ----------------------------------------------------------------------------------
6
- // Description: System Information - library
7
- // for Node.js
8
- // Copyright: (c) 2014 - 2026
9
- // Author: Sebastian Hildebrandt
10
- // ----------------------------------------------------------------------------------
11
- // License: MIT
12
- // ==================================================================================
13
- // 8. File System
14
- // ----------------------------------------------------------------------------------
15
-
16
- const util = require('./util');
17
- const fs = require('fs');
18
-
19
- const exec = require('child_process').exec;
20
- const execSync = require('child_process').execSync;
21
- const execPromiseSave = util.promisifySave(require('child_process').exec);
22
-
23
- const _platform = process.platform;
24
-
25
- const _linux = _platform === 'linux' || _platform === 'android';
26
- const _darwin = _platform === 'darwin';
27
- const _windows = _platform === 'win32';
28
- const _freebsd = _platform === 'freebsd';
29
- const _openbsd = _platform === 'openbsd';
30
- const _netbsd = _platform === 'netbsd';
31
- const _sunos = _platform === 'sunos';
32
-
33
- const _fs_speed = {};
34
- const _disk_io = {};
35
-
36
- // --------------------------
37
- // FS - mounted file systems
38
-
39
- function fsSize(drive, callback) {
40
- if (util.isFunction(drive)) {
41
- callback = drive;
42
- drive = '';
43
- }
44
-
45
- let macOsDisks = [];
46
- let osMounts = [];
47
-
48
- function getmacOsFsType(fs) {
49
- if (!fs.startsWith('/')) {
50
- return 'NFS';
51
- }
52
- const parts = fs.split('/');
53
- const fsShort = parts[parts.length - 1];
54
- const macOsDisksSingle = macOsDisks.filter((item) => item.indexOf(fsShort) >= 0);
55
- if (macOsDisksSingle.length === 1 && macOsDisksSingle[0].indexOf('APFS') >= 0) {
56
- return 'APFS';
57
- }
58
- return 'HFS';
59
- }
60
-
61
- function isLinuxTmpFs(fs) {
62
- const linuxTmpFileSystems = ['rootfs', 'unionfs', 'squashfs', 'cramfs', 'initrd', 'initramfs', 'devtmpfs', 'tmpfs', 'udev', 'devfs', 'specfs', 'type', 'appimaged'];
63
- let result = false;
64
- linuxTmpFileSystems.forEach((linuxFs) => {
65
- if (fs.toLowerCase().indexOf(linuxFs) >= 0) {
66
- result = true;
67
- }
68
- });
69
- return result;
70
- }
71
-
72
- function filterLines(stdout) {
73
- const lines = stdout.toString().split('\n');
74
- lines.shift();
75
- if (stdout.toString().toLowerCase().indexOf('filesystem') >= 0) {
76
- let removeLines = 0;
77
- for (let i = 0; i < lines.length; i++) {
78
- if (lines[i] && lines[i].toLowerCase().startsWith('filesystem')) {
79
- removeLines = i;
80
- }
81
- }
82
- for (let i = 0; i < removeLines; i++) {
83
- lines.shift();
84
- }
85
- }
86
- return lines;
87
- }
88
-
89
- function parseDf(lines) {
90
- const data = [];
91
- // filesystem (first column) and mount point (last column) may contain spaces:
92
- // anchor parsing on the numeric columns in between (blocks, used, available, capacity)
93
- const dfWithType = /^(.+?)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(?:\d+%|-)\s+(.+)$/;
94
- const dfNoType = /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(?:\d+%|-)\s+(.+)$/;
95
- const hasType = _linux || _freebsd || _openbsd || _netbsd;
96
- lines.forEach((line) => {
97
- if (line !== '') {
98
- const parts = line.trim().match(hasType ? dfWithType : dfNoType);
99
- if (parts && (parts[1].startsWith('/') || parts[hasType ? 6 : 5] === '/' || parts[1].indexOf('/') > 0 || parts[1].indexOf(':') === 1 || (!_darwin && !isLinuxTmpFs(parts[2])))) {
100
- const fs = parts[1];
101
- const fsType = hasType ? parts[2] : getmacOsFsType(parts[1]);
102
- const size = parseInt(parts[hasType ? 3 : 2], 10) * 1024;
103
- const used = parseInt(parts[hasType ? 4 : 3], 10) * 1024;
104
- const available = parseInt(parts[hasType ? 5 : 4], 10) * 1024;
105
- const use = parseFloat((100.0 * (used / (used + available))).toFixed(2));
106
- const rw = osMounts && Object.keys(osMounts).length > 0 ? osMounts[fs] || false : null;
107
- const mount = parts[hasType ? 6 : 5];
108
- if (!data.find((el) => el.fs === fs && el.type === fsType && el.mount === mount)) {
109
- data.push({
110
- fs,
111
- type: fsType,
112
- size,
113
- used,
114
- available,
115
- use,
116
- mount,
117
- rw
118
- });
119
- }
120
- }
121
- }
122
- });
123
- return data;
124
- }
125
-
126
- return new Promise((resolve) => {
127
- process.nextTick(() => {
128
- let data = [];
129
- if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
130
- let cmd = '';
131
- macOsDisks = [];
132
- osMounts = {};
133
- if (_darwin) {
134
- cmd = 'df -kP';
135
- try {
136
- macOsDisks = execSync('diskutil list')
137
- .toString()
138
- .split('\n')
139
- .filter((line) => {
140
- return !line.startsWith('/') && line.indexOf(':') > 0;
141
- });
142
- execSync('mount')
143
- .toString()
144
- .split('\n')
145
- .filter((line) => {
146
- return line.startsWith('/');
147
- })
148
- .forEach((line) => {
149
- osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
150
- });
151
- } catch {
152
- util.noop();
153
- }
154
- }
155
- if (_linux) {
156
- try {
157
- cmd = 'export LC_ALL=C; df -kPTx squashfs; unset LC_ALL';
158
- execSync('cat /proc/mounts 2>/dev/null', util.execOptsLinux)
159
- .toString()
160
- .split('\n')
161
- .filter((line) => {
162
- return line.startsWith('/');
163
- })
164
- .forEach((line) => {
165
- // /proc/mounts escapes spaces as \040
166
- const fs = line.split(' ')[0].replace(/\\040/g, ' ');
167
- osMounts[fs] = osMounts[fs] || false;
168
- if (line.toLowerCase().indexOf('/snap/') === -1) {
169
- osMounts[fs] = line.toLowerCase().indexOf('rw,') >= 0 || line.toLowerCase().indexOf(' rw ') >= 0;
170
- }
171
- });
172
- } catch {
173
- util.noop();
174
- }
175
- }
176
- if (_freebsd || _openbsd || _netbsd) {
177
- try {
178
- cmd = 'df -kPT';
179
- execSync('mount')
180
- .toString()
181
- .split('\n')
182
- .forEach((line) => {
183
- osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
184
- });
185
- } catch {
186
- util.noop();
187
- }
188
- }
189
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
190
- const lines = filterLines(stdout);
191
- data = parseDf(lines);
192
- if (drive) {
193
- data = data.filter((item) => {
194
- return item.fs.toLowerCase().indexOf(drive.toLowerCase()) >= 0 || item.mount.toLowerCase().indexOf(drive.toLowerCase()) >= 0;
195
- });
196
- }
197
- if ((!error || data.length) && stdout.toString().trim() !== '') {
198
- if (callback) {
199
- callback(data);
200
- }
201
- resolve(data);
202
- } else {
203
- exec('df -kPT 2>/dev/null', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
204
- // fixed issue alpine fallback
205
- const lines = filterLines(stdout);
206
- data = parseDf(lines);
207
- if (callback) {
208
- callback(data);
209
- }
210
- resolve(data);
211
- });
212
- }
213
- });
214
- }
215
- if (_sunos) {
216
- if (callback) {
217
- callback(data);
218
- }
219
- resolve(data);
220
- }
221
- if (_windows) {
222
- try {
223
- const driveSanitized = drive ? util.sanitizeString(drive, true) : '';
224
- const cmd = `Get-WmiObject Win32_logicaldisk | select Access,Caption,FileSystem,FreeSpace,Size ${driveSanitized ? '| where -property Caption -eq ' + driveSanitized : ''} | fl`;
225
- util.powerShell(cmd).then((stdout, error) => {
226
- if (!error) {
227
- const devices = stdout.toString().split(/\n\s*\n/);
228
- devices.forEach((device) => {
229
- const lines = device.split('\r\n');
230
- const size = util.toInt(util.getValue(lines, 'size', ':'));
231
- const free = util.toInt(util.getValue(lines, 'freespace', ':'));
232
- const caption = util.getValue(lines, 'caption', ':');
233
- const rwValue = util.getValue(lines, 'access', ':');
234
- const rw = rwValue ? util.toInt(rwValue) !== 1 : null;
235
- if (size) {
236
- data.push({
237
- fs: caption,
238
- type: util.getValue(lines, 'filesystem', ':'),
239
- size,
240
- used: size - free,
241
- available: free,
242
- use: parseFloat(((100.0 * (size - free)) / size).toFixed(2)),
243
- mount: caption,
244
- rw
245
- });
246
- }
247
- });
248
- }
249
- if (callback) {
250
- callback(data);
251
- }
252
- resolve(data);
253
- });
254
- } catch {
255
- if (callback) {
256
- callback(data);
257
- }
258
- resolve(data);
259
- }
260
- }
261
- });
262
- });
263
- }
264
-
265
- exports.fsSize = fsSize;
266
-
267
- // --------------------------
268
- // FS - open files count
269
-
270
- function fsOpenFiles(callback) {
271
- return new Promise((resolve) => {
272
- process.nextTick(() => {
273
- const result = {
274
- max: null,
275
- allocated: null,
276
- available: null
277
- };
278
- if (_freebsd || _openbsd || _netbsd || _darwin) {
279
- const cmd = 'sysctl -i kern.maxfiles kern.num_files kern.open_files';
280
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
281
- if (!error) {
282
- const lines = stdout.toString().split('\n');
283
- result.max = parseInt(util.getValue(lines, 'kern.maxfiles', ':'), 10);
284
- result.allocated = parseInt(util.getValue(lines, 'kern.num_files', ':'), 10) || parseInt(util.getValue(lines, 'kern.open_files', ':'), 10);
285
- result.available = result.max - result.allocated;
286
- }
287
- if (callback) {
288
- callback(result);
289
- }
290
- resolve(result);
291
- });
292
- }
293
- if (_linux) {
294
- fs.readFile('/proc/sys/fs/file-nr', (error, stdout) => {
295
- if (!error) {
296
- const lines = stdout.toString().split('\n');
297
- if (lines[0]) {
298
- const parts = lines[0].replace(/\s+/g, ' ').split(' ');
299
- if (parts.length === 3) {
300
- result.allocated = parseInt(parts[0], 10);
301
- result.available = parseInt(parts[1], 10);
302
- result.max = parseInt(parts[2], 10);
303
- if (!result.available) {
304
- result.available = result.max - result.allocated;
305
- }
306
- }
307
- }
308
- if (callback) {
309
- callback(result);
310
- }
311
- resolve(result);
312
- } else {
313
- fs.readFile('/proc/sys/fs/file-max', (error, stdout) => {
314
- if (!error) {
315
- const lines = stdout.toString().split('\n');
316
- if (lines[0]) {
317
- result.max = parseInt(lines[0], 10);
318
- }
319
- }
320
- if (callback) {
321
- callback(result);
322
- }
323
- resolve(result);
324
- });
325
- }
326
- });
327
- }
328
- if (_sunos) {
329
- if (callback) {
330
- callback(null);
331
- }
332
- resolve(null);
333
- }
334
- if (_windows) {
335
- if (callback) {
336
- callback(null);
337
- }
338
- resolve(null);
339
- }
340
- });
341
- });
342
- }
343
-
344
- exports.fsOpenFiles = fsOpenFiles;
345
-
346
- // --------------------------
347
- // disks
348
-
349
- function parseBytes(s) {
350
- const start = s.indexOf(' (') + 2;
351
- const end = s.indexOf(' Bytes)');
352
- return parseInt(s.substr(start, end - start), 10);
353
- }
354
-
355
- function parseDevices(lines) {
356
- const devices = [];
357
- let i = 0;
358
- lines.forEach((line) => {
359
- if (line.length > 0) {
360
- if (line[0] === '*') {
361
- i++;
362
- } else {
363
- const parts = line.split(':');
364
- if (parts.length > 1) {
365
- if (!devices[i]) {
366
- devices[i] = {
367
- name: '',
368
- identifier: '',
369
- type: 'disk',
370
- fsType: '',
371
- mount: '',
372
- size: 0,
373
- physical: 'HDD',
374
- uuid: '',
375
- label: '',
376
- model: '',
377
- serial: '',
378
- removable: false,
379
- protocol: '',
380
- group: '',
381
- device: ''
382
- };
383
- }
384
- parts[0] = parts[0].trim().toUpperCase().replace(/ +/g, '');
385
- parts[1] = parts[1].trim();
386
- if ('DEVICEIDENTIFIER' === parts[0]) {
387
- devices[i].identifier = parts[1];
388
- }
389
- if ('DEVICENODE' === parts[0]) {
390
- devices[i].name = parts[1];
391
- }
392
- if ('VOLUMENAME' === parts[0]) {
393
- if (parts[1].indexOf('Not applicable') === -1) {
394
- devices[i].label = parts[1];
395
- }
396
- }
397
- if ('PROTOCOL' === parts[0]) {
398
- devices[i].protocol = parts[1];
399
- }
400
- if ('DISKSIZE' === parts[0]) {
401
- devices[i].size = parseBytes(parts[1]);
402
- }
403
- if ('FILESYSTEMPERSONALITY' === parts[0]) {
404
- devices[i].fsType = parts[1];
405
- }
406
- if ('MOUNTPOINT' === parts[0]) {
407
- devices[i].mount = parts[1];
408
- }
409
- if ('VOLUMEUUID' === parts[0]) {
410
- devices[i].uuid = parts[1];
411
- }
412
- if ('READ-ONLYMEDIA' === parts[0] && parts[1] === 'Yes') {
413
- devices[i].physical = 'CD/DVD';
414
- }
415
- if ('SOLIDSTATE' === parts[0] && parts[1] === 'Yes') {
416
- devices[i].physical = 'SSD';
417
- }
418
- if ('VIRTUAL' === parts[0]) {
419
- devices[i].type = 'virtual';
420
- }
421
- if ('REMOVABLEMEDIA' === parts[0]) {
422
- devices[i].removable = parts[1] === 'Removable';
423
- }
424
- if ('PARTITIONTYPE' === parts[0]) {
425
- devices[i].type = 'part';
426
- }
427
- if ('DEVICE/MEDIANAME' === parts[0]) {
428
- devices[i].model = parts[1];
429
- }
430
- }
431
- }
432
- }
433
- });
434
- return devices;
435
- }
436
-
437
- function parseBlk(lines) {
438
- let data = [];
439
-
440
- lines
441
- .filter((line) => line !== '')
442
- .forEach((line) => {
443
- try {
444
- line = decodeURIComponent(line.replace(/\\x/g, '%'));
445
- line = line.replace(/\\/g, '\\\\');
446
- const disk = JSON.parse(line);
447
- data.push({
448
- name: util.sanitizeShellString(disk.name),
449
- type: disk.type,
450
- fsType: disk.fsType,
451
- mount: disk.mountpoint,
452
- size: parseInt(disk.size, 10),
453
- physical: disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : disk.type === 'rom' ? 'CD/DVD' : '',
454
- uuid: disk.uuid,
455
- label: disk.label,
456
- model: (disk.model || '').trim(),
457
- serial: disk.serial,
458
- removable: disk.rm === '1',
459
- protocol: disk.tran,
460
- group: disk.group || ''
461
- });
462
- } catch {
463
- util.noop();
464
- }
465
- });
466
- data = util.unique(data);
467
- data = util.sortByKey(data, ['type', 'name']);
468
- return data;
469
- }
470
-
471
- function decodeMdabmData(lines) {
472
- const raid = util.getValue(lines, 'md_level', '=');
473
- const label = util.getValue(lines, 'md_name', '='); // <- get label info
474
- const uuid = util.getValue(lines, 'md_uuid', '='); // <- get uuid info
475
- const members = [];
476
- lines.forEach((line) => {
477
- if (line.toLowerCase().startsWith('md_device_dev') && line.toLowerCase().indexOf('/dev/') > 0) {
478
- members.push(line.split('/dev/')[1]);
479
- }
480
- });
481
- return {
482
- raid,
483
- label,
484
- uuid,
485
- members
486
- };
487
- }
488
-
489
- function raidMatchLinux(data) {
490
- // for all block devices of type "raid%"
491
- let result = data;
492
- try {
493
- data.forEach((element) => {
494
- if (element.type.startsWith('raid')) {
495
- const lines = execSync(`mdadm --export --detail /dev/${util.sanitizeString(element.name, true)}`, util.execOptsLinux).toString().split('\n');
496
- const mdData = decodeMdabmData(lines);
497
-
498
- element.label = mdData.label; // <- assign label info
499
- element.uuid = mdData.uuid; // <- assign uuid info
500
-
501
- if (mdData && mdData.members && mdData.members.length && mdData.raid === element.type) {
502
- result = result.map((blockdevice) => {
503
- if (blockdevice.fsType === 'linux_raid_member' && mdData.members.indexOf(blockdevice.name) >= 0) {
504
- blockdevice.group = element.name;
505
- }
506
- return blockdevice;
507
- });
508
- }
509
- }
510
- });
511
- } catch {
512
- util.noop();
513
- }
514
- return result;
515
- }
516
-
517
- function getDevicesLinux(data) {
518
- const result = [];
519
- data.forEach((element) => {
520
- if (element.type.startsWith('disk')) {
521
- result.push(element.name);
522
- }
523
- });
524
- return result;
525
- }
526
-
527
- function matchDevicesLinux(data) {
528
- let result = data;
529
- try {
530
- const devices = getDevicesLinux(data);
531
- result = result.map((blockdevice) => {
532
- if (blockdevice.type.startsWith('part') || blockdevice.type.startsWith('disk')) {
533
- devices.forEach((element) => {
534
- if (blockdevice.name.startsWith(element)) {
535
- blockdevice.device = '/dev/' + element;
536
- }
537
- });
538
- }
539
- return blockdevice;
540
- });
541
- } catch {
542
- util.noop();
543
- }
544
- return result;
545
- }
546
-
547
- function getDevicesMac(data) {
548
- const result = [];
549
- data.forEach((element) => {
550
- if (element.type.startsWith('disk')) {
551
- result.push({ name: element.name, model: element.model, device: element.name });
552
- }
553
- if (element.type.startsWith('virtual')) {
554
- let device = '';
555
- result.forEach((e) => {
556
- if (e.model === element.model) {
557
- device = e.device;
558
- }
559
- });
560
- if (device) {
561
- result.push({ name: element.name, model: element.model, device });
562
- }
563
- }
564
- });
565
- return result;
566
- }
567
-
568
- function matchDevicesMac(data) {
569
- let result = data;
570
- try {
571
- const devices = getDevicesMac(data);
572
- result = result.map((blockdevice) => {
573
- if (blockdevice.type.startsWith('part') || blockdevice.type.startsWith('disk') || blockdevice.type.startsWith('virtual')) {
574
- devices.forEach((element) => {
575
- if (blockdevice.name.startsWith(element.name)) {
576
- blockdevice.device = element.device;
577
- }
578
- });
579
- }
580
- return blockdevice;
581
- });
582
- } catch {
583
- util.noop();
584
- }
585
- return result;
586
- }
587
-
588
- function getDevicesWin(diskDrives) {
589
- const result = [];
590
- diskDrives.forEach((element) => {
591
- const lines = element.split('\r\n');
592
- const device = util.getValue(lines, 'DeviceID', ':');
593
- let partitions = element.split('@{DeviceID=');
594
- if (partitions.length > 1) {
595
- partitions = partitions.slice(1);
596
- partitions.forEach((partition) => {
597
- result.push({ name: partition.split(';')[0].toUpperCase(), device });
598
- });
599
- }
600
- });
601
- return result;
602
- }
603
-
604
- function matchDevicesWin(data, diskDrives) {
605
- const devices = getDevicesWin(diskDrives);
606
- data.map((element) => {
607
- const filteresDevices = devices.filter((e) => {
608
- return e.name === element.name.toUpperCase();
609
- });
610
- if (filteresDevices.length > 0) {
611
- element.device = filteresDevices[0].device;
612
- }
613
- return element;
614
- });
615
- return data;
616
- }
617
-
618
- function blkStdoutToObject(stdout) {
619
- return stdout
620
- .toString()
621
- .replace(/NAME=/g, '{"name":')
622
- .replace(/FSTYPE=/g, ',"fsType":')
623
- .replace(/TYPE=/g, ',"type":')
624
- .replace(/SIZE=/g, ',"size":')
625
- .replace(/MOUNTPOINT=/g, ',"mountpoint":')
626
- .replace(/UUID=/g, ',"uuid":')
627
- .replace(/ROTA=/g, ',"rota":')
628
- .replace(/RO=/g, ',"ro":')
629
- .replace(/RM=/g, ',"rm":')
630
- .replace(/TRAN=/g, ',"tran":')
631
- .replace(/SERIAL=/g, ',"serial":')
632
- .replace(/LABEL=/g, ',"label":')
633
- .replace(/MODEL=/g, ',"model":')
634
- .replace(/OWNER=/g, ',"owner":')
635
- .replace(/GROUP=/g, ',"group":')
636
- .replace(/\n/g, '}\n');
637
- }
638
-
639
- function blockDevices(callback) {
640
- return new Promise((resolve) => {
641
- process.nextTick(() => {
642
- let data = [];
643
- if (_linux) {
644
- // see https://wiki.ubuntuusers.de/lsblk/
645
- // exec("lsblk -bo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,TRAN,SERIAL,LABEL,MODEL,OWNER,GROUP,MODE,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,SCHED,RQ-SIZE,RA,WSAME", function (error, stdout) {
646
- const procLsblk1 = exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,TRAN,SERIAL,LABEL,MODEL,OWNER 2>/dev/null', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
647
- if (!error) {
648
- const lines = blkStdoutToObject(stdout).split('\n');
649
- data = parseBlk(lines);
650
- data = raidMatchLinux(data);
651
- data = matchDevicesLinux(data);
652
- if (callback) {
653
- callback(data);
654
- }
655
- resolve(data);
656
- } else {
657
- const procLsblk2 = exec('lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER 2>/dev/null', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
658
- if (!error) {
659
- const lines = blkStdoutToObject(stdout).split('\n');
660
- data = parseBlk(lines);
661
- data = raidMatchLinux(data);
662
- }
663
- if (callback) {
664
- callback(data);
665
- }
666
- resolve(data);
667
- });
668
- procLsblk2.on('error', () => {
669
- if (callback) {
670
- callback(data);
671
- }
672
- resolve(data);
673
- });
674
- }
675
- });
676
- procLsblk1.on('error', () => {
677
- if (callback) {
678
- callback(data);
679
- }
680
- resolve(data);
681
- });
682
- }
683
- if (_darwin) {
684
- const procDskutil = exec('diskutil info -all', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
685
- if (!error) {
686
- const lines = stdout.toString().split('\n');
687
- // parse lines into temp array of devices
688
- data = parseDevices(lines);
689
- data = matchDevicesMac(data);
690
- }
691
- if (callback) {
692
- callback(data);
693
- }
694
- resolve(data);
695
- });
696
- procDskutil.on('error', () => {
697
- if (callback) {
698
- callback(data);
699
- }
700
- resolve(data);
701
- });
702
- }
703
- if (_sunos) {
704
- if (callback) {
705
- callback(data);
706
- }
707
- resolve(data);
708
- }
709
- if (_windows) {
710
- const drivetypes = ['Unknown', 'NoRoot', 'Removable', 'Local', 'Network', 'CD/DVD', 'RAM'];
711
- try {
712
- const workload = [];
713
- workload.push(util.powerShell('Get-CimInstance -ClassName Win32_LogicalDisk | select Caption,DriveType,Name,FileSystem,Size,VolumeSerialNumber,VolumeName | fl'));
714
- workload.push(
715
- util.powerShell(
716
- "Get-WmiObject -Class Win32_diskdrive | Select-Object -Property PNPDeviceId,DeviceID, Model, Size, @{L='Partitions'; E={$_.GetRelated('Win32_DiskPartition').GetRelated('Win32_LogicalDisk') | Select-Object -Property DeviceID, VolumeName, Size, FreeSpace}} | fl"
717
- )
718
- );
719
- util.promiseAll(workload).then((res) => {
720
- const logicalDisks = res.results[0].toString().split(/\n\s*\n/);
721
- const diskDrives = res.results[1].toString().split(/\n\s*\n/);
722
- logicalDisks.forEach((device) => {
723
- const lines = device.split('\r\n');
724
- const drivetype = util.getValue(lines, 'drivetype', ':');
725
- if (drivetype) {
726
- data.push({
727
- name: util.getValue(lines, 'name', ':'),
728
- identifier: util.getValue(lines, 'caption', ':'),
729
- type: 'disk',
730
- fsType: util.getValue(lines, 'filesystem', ':').toLowerCase(),
731
- mount: util.getValue(lines, 'caption', ':'),
732
- size: util.getValue(lines, 'size', ':'),
733
- physical: drivetype >= 0 && drivetype <= 6 ? drivetypes[drivetype] : drivetypes[0],
734
- uuid: util.getValue(lines, 'volumeserialnumber', ':'),
735
- label: util.getValue(lines, 'volumename', ':'),
736
- model: '',
737
- serial: util.getValue(lines, 'volumeserialnumber', ':'),
738
- removable: drivetype === '2',
739
- protocol: '',
740
- group: '',
741
- device: ''
742
- });
743
- }
744
- });
745
- // match devices
746
- data = matchDevicesWin(data, diskDrives);
747
- if (callback) {
748
- callback(data);
749
- }
750
- resolve(data);
751
- });
752
- } catch {
753
- if (callback) {
754
- callback(data);
755
- }
756
- resolve(data);
757
- }
758
- }
759
- if (_freebsd || _openbsd || _netbsd) {
760
- // will follow
761
- if (callback) {
762
- callback(null);
763
- }
764
- resolve(null);
765
- }
766
- });
767
- });
768
- }
769
-
770
- exports.blockDevices = blockDevices;
771
-
772
- // --------------------------
773
- // FS - speed
774
-
775
- function calcFsSpeed(rx, wx) {
776
- const result = {
777
- rx: 0,
778
- wx: 0,
779
- tx: 0,
780
- rx_sec: null,
781
- wx_sec: null,
782
- tx_sec: null,
783
- ms: 0
784
- };
785
-
786
- if (_fs_speed && _fs_speed.ms) {
787
- result.rx = rx;
788
- result.wx = wx;
789
- result.tx = result.rx + result.wx;
790
- result.ms = Date.now() - _fs_speed.ms;
791
- result.rx_sec = (result.rx - _fs_speed.bytes_read) / (result.ms / 1000);
792
- result.wx_sec = (result.wx - _fs_speed.bytes_write) / (result.ms / 1000);
793
- result.tx_sec = result.rx_sec + result.wx_sec;
794
- _fs_speed.rx_sec = result.rx_sec;
795
- _fs_speed.wx_sec = result.wx_sec;
796
- _fs_speed.tx_sec = result.tx_sec;
797
- _fs_speed.bytes_read = result.rx;
798
- _fs_speed.bytes_write = result.wx;
799
- _fs_speed.bytes_overall = result.rx + result.wx;
800
- _fs_speed.ms = Date.now();
801
- _fs_speed.last_ms = result.ms;
802
- } else {
803
- result.rx = rx;
804
- result.wx = wx;
805
- result.tx = result.rx + result.wx;
806
- _fs_speed.rx_sec = null;
807
- _fs_speed.wx_sec = null;
808
- _fs_speed.tx_sec = null;
809
- _fs_speed.bytes_read = result.rx;
810
- _fs_speed.bytes_write = result.wx;
811
- _fs_speed.bytes_overall = result.rx + result.wx;
812
- _fs_speed.ms = Date.now();
813
- _fs_speed.last_ms = 0;
814
- }
815
- return result;
816
- }
817
-
818
- function fsStats(callback) {
819
- return new Promise((resolve) => {
820
- process.nextTick(() => {
821
- if (_windows || _freebsd || _openbsd || _netbsd || _sunos) {
822
- return resolve(null);
823
- }
824
-
825
- let result = {
826
- rx: 0,
827
- wx: 0,
828
- tx: 0,
829
- rx_sec: null,
830
- wx_sec: null,
831
- tx_sec: null,
832
- ms: 0
833
- };
834
-
835
- let rx = 0;
836
- let wx = 0;
837
- if ((_fs_speed && !_fs_speed.ms) || (_fs_speed && _fs_speed.ms && Date.now() - _fs_speed.ms >= 500)) {
838
- if (_linux) {
839
- // exec("df -k | grep /dev/", function(error, stdout) {
840
- const procLsblk = exec('lsblk -r 2>/dev/null | grep /', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
841
- if (!error) {
842
- const lines = stdout.toString().split('\n');
843
- const fs_filter = [];
844
- lines.forEach((line) => {
845
- if (line !== '') {
846
- line = line.trim().split(' ');
847
- const dev = util.sanitizeShellString(line[0], true);
848
- if (dev && fs_filter.indexOf(dev) === -1) {
849
- fs_filter.push(dev);
850
- }
851
- }
852
- });
853
-
854
- const output = fs_filter.join('|');
855
- const procCat = exec('cat /proc/diskstats | egrep "' + output + '"', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
856
- if (!error) {
857
- const lines = stdout.toString().split('\n');
858
- lines.forEach((line) => {
859
- line = line.trim();
860
- if (line !== '') {
861
- line = line.replace(/ +/g, ' ').split(' ');
862
-
863
- rx += parseInt(line[5], 10) * 512;
864
- wx += parseInt(line[9], 10) * 512;
865
- }
866
- });
867
- result = calcFsSpeed(rx, wx);
868
- }
869
- if (callback) {
870
- callback(result);
871
- }
872
- resolve(result);
873
- });
874
- procCat.on('error', () => {
875
- if (callback) {
876
- callback(result);
877
- }
878
- resolve(result);
879
- });
880
- } else {
881
- if (callback) {
882
- callback(result);
883
- }
884
- resolve(result);
885
- }
886
- });
887
- procLsblk.on('error', () => {
888
- if (callback) {
889
- callback(result);
890
- }
891
- resolve(result);
892
- });
893
- }
894
- if (_darwin) {
895
- const procIoreg = exec(
896
- 'ioreg -c IOBlockStorageDriver -k Statistics -r -w0 | sed -n "/IOBlockStorageDriver/,/Statistics/p" | grep "Statistics" | tr -cd "01234567890,\n"',
897
- { maxBuffer: 1024 * 1024 },
898
- (error, stdout) => {
899
- if (!error) {
900
- const lines = stdout.toString().split('\n');
901
- lines.forEach((line) => {
902
- line = line.trim();
903
- if (line !== '') {
904
- line = line.split(',');
905
-
906
- rx += parseInt(line[2], 10);
907
- wx += parseInt(line[9], 10);
908
- }
909
- });
910
- result = calcFsSpeed(rx, wx);
911
- }
912
- if (callback) {
913
- callback(result);
914
- }
915
- resolve(result);
916
- }
917
- );
918
- procIoreg.on('error', () => {
919
- if (callback) {
920
- callback(result);
921
- }
922
- resolve(result);
923
- });
924
- }
925
- } else {
926
- result.ms = _fs_speed.last_ms;
927
- result.rx = _fs_speed.bytes_read;
928
- result.wx = _fs_speed.bytes_write;
929
- result.tx = _fs_speed.bytes_read + _fs_speed.bytes_write;
930
- result.rx_sec = _fs_speed.rx_sec;
931
- result.wx_sec = _fs_speed.wx_sec;
932
- result.tx_sec = _fs_speed.tx_sec;
933
- if (callback) {
934
- callback(result);
935
- }
936
- resolve(result);
937
- }
938
- });
939
- });
940
- }
941
-
942
- exports.fsStats = fsStats;
943
-
944
- function calcDiskIO(rIO, wIO, rWaitTime, wWaitTime, tWaitTime) {
945
- const result = {
946
- rIO: 0,
947
- wIO: 0,
948
- tIO: 0,
949
- rIO_sec: null,
950
- wIO_sec: null,
951
- tIO_sec: null,
952
- rWaitTime: 0,
953
- wWaitTime: 0,
954
- tWaitTime: 0,
955
- rWaitPercent: null,
956
- wWaitPercent: null,
957
- tWaitPercent: null,
958
- ms: 0
959
- };
960
- if (_disk_io && _disk_io.ms) {
961
- result.rIO = rIO;
962
- result.wIO = wIO;
963
- result.tIO = rIO + wIO;
964
- result.ms = Date.now() - _disk_io.ms;
965
- result.rIO_sec = (result.rIO - _disk_io.rIO) / (result.ms / 1000);
966
- result.wIO_sec = (result.wIO - _disk_io.wIO) / (result.ms / 1000);
967
- result.tIO_sec = result.rIO_sec + result.wIO_sec;
968
- result.rWaitTime = rWaitTime;
969
- result.wWaitTime = wWaitTime;
970
- result.tWaitTime = tWaitTime;
971
- result.rWaitPercent = ((result.rWaitTime - _disk_io.rWaitTime) * 100) / result.ms;
972
- result.wWaitPercent = ((result.wWaitTime - _disk_io.wWaitTime) * 100) / result.ms;
973
- result.tWaitPercent = ((result.tWaitTime - _disk_io.tWaitTime) * 100) / result.ms;
974
- _disk_io.rIO = rIO;
975
- _disk_io.wIO = wIO;
976
- _disk_io.rIO_sec = result.rIO_sec;
977
- _disk_io.wIO_sec = result.wIO_sec;
978
- _disk_io.tIO_sec = result.tIO_sec;
979
- _disk_io.rWaitTime = rWaitTime;
980
- _disk_io.wWaitTime = wWaitTime;
981
- _disk_io.tWaitTime = tWaitTime;
982
- _disk_io.rWaitPercent = result.rWaitPercent;
983
- _disk_io.wWaitPercent = result.wWaitPercent;
984
- _disk_io.tWaitPercent = result.tWaitPercent;
985
- _disk_io.last_ms = result.ms;
986
- _disk_io.ms = Date.now();
987
- } else {
988
- result.rIO = rIO;
989
- result.wIO = wIO;
990
- result.tIO = rIO + wIO;
991
- result.rWaitTime = rWaitTime;
992
- result.wWaitTime = wWaitTime;
993
- result.tWaitTime = tWaitTime;
994
- _disk_io.rIO = rIO;
995
- _disk_io.wIO = wIO;
996
- _disk_io.rIO_sec = null;
997
- _disk_io.wIO_sec = null;
998
- _disk_io.tIO_sec = null;
999
- _disk_io.rWaitTime = rWaitTime;
1000
- _disk_io.wWaitTime = wWaitTime;
1001
- _disk_io.tWaitTime = tWaitTime;
1002
- _disk_io.rWaitPercent = null;
1003
- _disk_io.wWaitPercent = null;
1004
- _disk_io.tWaitPercent = null;
1005
- _disk_io.last_ms = 0;
1006
- _disk_io.ms = Date.now();
1007
- }
1008
- return result;
1009
- }
1010
-
1011
- function disksIO(callback) {
1012
- return new Promise((resolve) => {
1013
- process.nextTick(() => {
1014
- if (_windows) {
1015
- return resolve(null);
1016
- }
1017
- if (_sunos) {
1018
- return resolve(null);
1019
- }
1020
-
1021
- let result = {
1022
- rIO: 0,
1023
- wIO: 0,
1024
- tIO: 0,
1025
- rIO_sec: null,
1026
- wIO_sec: null,
1027
- tIO_sec: null,
1028
- rWaitTime: 0,
1029
- wWaitTime: 0,
1030
- tWaitTime: 0,
1031
- rWaitPercent: null,
1032
- wWaitPercent: null,
1033
- tWaitPercent: null,
1034
- ms: 0
1035
- };
1036
- let rIO = 0;
1037
- let wIO = 0;
1038
- let rWaitTime = 0;
1039
- let wWaitTime = 0;
1040
- let tWaitTime = 0;
1041
-
1042
- if ((_disk_io && !_disk_io.ms) || (_disk_io && _disk_io.ms && Date.now() - _disk_io.ms >= 500)) {
1043
- if (_linux || _freebsd || _openbsd || _netbsd) {
1044
- // prints Block layer statistics for all mounted volumes
1045
- // var cmd = "for mount in `lsblk | grep / | sed -r 's/│ └─//' | cut -d ' ' -f 1`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
1046
- // var cmd = "for mount in `lsblk | grep / | sed 's/[│└─├]//g' | awk '{$1=$1};1' | cut -d ' ' -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r 's/ +/;/g' | sed -r 's/^;//'; done";
1047
- const cmd =
1048
- 'for mount in `lsblk 2>/dev/null | grep " disk " | sed "s/[│└─├]//g" | awk \'{$1=$1};1\' | cut -d " " -f 1 | sort -u`; do cat /sys/block/$mount/stat | sed -r "s/ +/;/g" | sed -r "s/^;//"; done';
1049
-
1050
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1051
- if (!error) {
1052
- const lines = stdout.split('\n');
1053
- lines.forEach((line) => {
1054
- // ignore empty lines
1055
- if (!line) {
1056
- return;
1057
- }
1058
-
1059
- // sum r/wIO of all disks to compute all disks IO
1060
- const stats = line.split(';');
1061
- rIO += parseInt(stats[0], 10);
1062
- wIO += parseInt(stats[4], 10);
1063
- rWaitTime += parseInt(stats[3], 10);
1064
- wWaitTime += parseInt(stats[7], 10);
1065
- tWaitTime += parseInt(stats[10], 10);
1066
- });
1067
- result = calcDiskIO(rIO, wIO, rWaitTime, wWaitTime, tWaitTime);
1068
-
1069
- if (callback) {
1070
- callback(result);
1071
- }
1072
- resolve(result);
1073
- } else {
1074
- if (callback) {
1075
- callback(result);
1076
- }
1077
- resolve(result);
1078
- }
1079
- });
1080
- }
1081
- if (_darwin) {
1082
- exec(
1083
- 'ioreg -c IOBlockStorageDriver -k Statistics -r -w0 | sed -n "/IOBlockStorageDriver/,/Statistics/p" | grep "Statistics" | tr -cd "01234567890,\n"',
1084
- { maxBuffer: 1024 * 1024 },
1085
- (error, stdout) => {
1086
- if (!error) {
1087
- const lines = stdout.toString().split('\n');
1088
- lines.forEach((line) => {
1089
- line = line.trim();
1090
- if (line !== '') {
1091
- line = line.split(',');
1092
-
1093
- rIO += parseInt(line[10], 10);
1094
- wIO += parseInt(line[0], 10);
1095
- }
1096
- });
1097
- result = calcDiskIO(rIO, wIO, rWaitTime, wWaitTime, tWaitTime);
1098
- }
1099
- if (callback) {
1100
- callback(result);
1101
- }
1102
- resolve(result);
1103
- }
1104
- );
1105
- }
1106
- } else {
1107
- result.rIO = _disk_io.rIO;
1108
- result.wIO = _disk_io.wIO;
1109
- result.tIO = _disk_io.rIO + _disk_io.wIO;
1110
- result.ms = _disk_io.last_ms;
1111
- result.rIO_sec = _disk_io.rIO_sec;
1112
- result.wIO_sec = _disk_io.wIO_sec;
1113
- result.tIO_sec = _disk_io.tIO_sec;
1114
- result.rWaitTime = _disk_io.rWaitTime;
1115
- result.wWaitTime = _disk_io.wWaitTime;
1116
- result.tWaitTime = _disk_io.tWaitTime;
1117
- result.rWaitPercent = _disk_io.rWaitPercent;
1118
- result.wWaitPercent = _disk_io.wWaitPercent;
1119
- result.tWaitPercent = _disk_io.tWaitPercent;
1120
- if (callback) {
1121
- callback(result);
1122
- }
1123
- resolve(result);
1124
- }
1125
- });
1126
- });
1127
- }
1128
-
1129
- exports.disksIO = disksIO;
1130
-
1131
- function diskLayout(callback) {
1132
- function getVendorFromModel(model) {
1133
- const diskManufacturers = [
1134
- { pattern: 'WESTERN.*', manufacturer: 'Western Digital' },
1135
- { pattern: '^WDC.*', manufacturer: 'Western Digital' },
1136
- { pattern: 'WD.*', manufacturer: 'Western Digital' },
1137
- { pattern: 'TOSHIBA.*', manufacturer: 'Toshiba' },
1138
- { pattern: 'HITACHI.*', manufacturer: 'Hitachi' },
1139
- { pattern: '^IC.*', manufacturer: 'Hitachi' },
1140
- { pattern: '^HTS.*', manufacturer: 'Hitachi' },
1141
- { pattern: 'SANDISK.*', manufacturer: 'SanDisk' },
1142
- { pattern: 'KINGSTON.*', manufacturer: 'Kingston Technology' },
1143
- { pattern: '^SONY.*', manufacturer: 'Sony' },
1144
- { pattern: 'TRANSCEND.*', manufacturer: 'Transcend' },
1145
- { pattern: 'SAMSUNG.*', manufacturer: 'Samsung' },
1146
- { pattern: '^ST(?!I\\ ).*', manufacturer: 'Seagate' },
1147
- { pattern: '^STI\\ .*', manufacturer: 'SimpleTech' },
1148
- { pattern: '^D...-.*', manufacturer: 'IBM' },
1149
- { pattern: '^IBM.*', manufacturer: 'IBM' },
1150
- { pattern: '^FUJITSU.*', manufacturer: 'Fujitsu' },
1151
- { pattern: '^MP.*', manufacturer: 'Fujitsu' },
1152
- { pattern: '^MK.*', manufacturer: 'Toshiba' },
1153
- { pattern: 'MAXTO.*', manufacturer: 'Maxtor' },
1154
- { pattern: 'PIONEER.*', manufacturer: 'Pioneer' },
1155
- { pattern: 'PHILIPS.*', manufacturer: 'Philips' },
1156
- { pattern: 'QUANTUM.*', manufacturer: 'Quantum Technology' },
1157
- { pattern: 'FIREBALL.*', manufacturer: 'Quantum Technology' },
1158
- { pattern: '^VBOX.*', manufacturer: 'VirtualBox' },
1159
- { pattern: 'CORSAIR.*', manufacturer: 'Corsair Components' },
1160
- { pattern: 'CRUCIAL.*', manufacturer: 'Crucial' },
1161
- { pattern: 'ECM.*', manufacturer: 'ECM' },
1162
- { pattern: 'INTEL.*', manufacturer: 'INTEL' },
1163
- { pattern: 'EVO.*', manufacturer: 'Samsung' },
1164
- { pattern: 'APPLE.*', manufacturer: 'Apple' }
1165
- ];
1166
-
1167
- let result = '';
1168
- if (model) {
1169
- model = model.toUpperCase();
1170
- diskManufacturers.forEach((manufacturer) => {
1171
- const re = RegExp(manufacturer.pattern);
1172
- if (re.test(model)) {
1173
- result = manufacturer.manufacturer;
1174
- }
1175
- });
1176
- }
1177
- return result;
1178
- }
1179
-
1180
- return new Promise((resolve) => {
1181
- process.nextTick(() => {
1182
- const commitResult = (res) => {
1183
- for (let i = 0; i < res.length; i++) {
1184
- delete res[i].BSDName;
1185
- }
1186
- if (callback) {
1187
- callback(res);
1188
- }
1189
- resolve(res);
1190
- };
1191
-
1192
- const result = [];
1193
- let cmd = '';
1194
-
1195
- if (_linux) {
1196
- let cmdFullSmart = '';
1197
-
1198
- exec('export LC_ALL=C; lsblk -ablJO 2>/dev/null; unset LC_ALL', { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1199
- if (!error) {
1200
- try {
1201
- const out = stdout.toString().trim();
1202
- let devices = [];
1203
- try {
1204
- const outJSON = JSON.parse(out);
1205
- if (outJSON && {}.hasOwnProperty.call(outJSON, 'blockdevices')) {
1206
- devices = outJSON.blockdevices.filter((item) => {
1207
- return (
1208
- item.type === 'disk' &&
1209
- item.size > 0 &&
1210
- (item.model !== null ||
1211
- (item.mountpoint === null &&
1212
- item.label === null &&
1213
- item.fstype === null &&
1214
- item.parttype === null &&
1215
- item.path &&
1216
- item.path.indexOf('/ram') !== 0 &&
1217
- item.path.indexOf('/loop') !== 0 &&
1218
- item['disc-max'] &&
1219
- item['disc-max'] !== 0))
1220
- );
1221
- });
1222
- }
1223
- } catch {
1224
- // fallback to older version of lsblk
1225
- try {
1226
- const out2 = execSync(
1227
- 'export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL',
1228
- util.execOptsLinux
1229
- ).toString();
1230
- const lines = blkStdoutToObject(out2).split('\n');
1231
- const data = parseBlk(lines);
1232
- devices = data.filter((item) => {
1233
- return item.type === 'disk' && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mount === '' && item.label === '' && item.fsType === ''));
1234
- });
1235
- } catch {
1236
- util.noop();
1237
- }
1238
- }
1239
- devices.forEach((device) => {
1240
- let mediumType = '';
1241
- const logical = util.sanitizeShellString(device.name, true);
1242
- const BSDName = '/dev/' + logical;
1243
- try {
1244
- mediumType = execSync('cat /sys/block/' + logical + '/queue/rotational 2>/dev/null', util.execOptsLinux)
1245
- .toString()
1246
- .split('\n')[0];
1247
- } catch {
1248
- util.noop();
1249
- }
1250
- let interfaceType = device.tran ? device.tran.toUpperCase().trim() : '';
1251
- if (interfaceType === 'NVME') {
1252
- mediumType = '2';
1253
- interfaceType = 'PCIe';
1254
- }
1255
- result.push({
1256
- device: BSDName,
1257
- type:
1258
- mediumType === '0'
1259
- ? 'SSD'
1260
- : mediumType === '1'
1261
- ? 'HD'
1262
- : mediumType === '2'
1263
- ? 'NVMe'
1264
- : device.model && device.model.indexOf('SSD') > -1
1265
- ? 'SSD'
1266
- : device.model && device.model.indexOf('NVM') > -1
1267
- ? 'NVMe'
1268
- : 'HD',
1269
- name: device.model || '',
1270
- vendor: getVendorFromModel(device.model) || (device.vendor ? device.vendor.trim() : ''),
1271
- size: device.size || 0,
1272
- bytesPerSector: null,
1273
- totalCylinders: null,
1274
- totalHeads: null,
1275
- totalSectors: null,
1276
- totalTracks: null,
1277
- tracksPerCylinder: null,
1278
- sectorsPerTrack: null,
1279
- firmwareRevision: device.rev ? device.rev.trim() : '',
1280
- serialNum: device.serial ? device.serial.trim() : '',
1281
- interfaceType: interfaceType,
1282
- smartStatus: 'unknown',
1283
- temperature: null,
1284
- BSDName: BSDName
1285
- });
1286
- cmd += `printf "\n${BSDName}|"; smartctl -H ${BSDName} | grep overall;`;
1287
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
1288
- });
1289
- } catch {
1290
- util.noop();
1291
- }
1292
- }
1293
- // check S.M.A.R.T. status
1294
- if (cmdFullSmart) {
1295
- exec(cmdFullSmart, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1296
- try {
1297
- const data = JSON.parse(`[${stdout}]`);
1298
- data.forEach((disk) => {
1299
- const diskBSDName = disk.smartctl.argv[disk.smartctl.argv.length - 1];
1300
-
1301
- for (let i = 0; i < result.length; i++) {
1302
- if (result[i].BSDName === diskBSDName) {
1303
- result[i].smartStatus = disk.smart_status.passed ? 'Ok' : disk.smart_status.passed === false ? 'Predicted Failure' : 'unknown';
1304
- if (disk.temperature && disk.temperature.current) {
1305
- result[i].temperature = disk.temperature.current;
1306
- }
1307
- result[i].smartData = disk;
1308
- }
1309
- }
1310
- });
1311
- commitResult(result);
1312
- } catch {
1313
- if (cmd) {
1314
- cmd = cmd + 'printf "\n"';
1315
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1316
- const lines = stdout.toString().split('\n');
1317
- lines.forEach((line) => {
1318
- if (line) {
1319
- const parts = line.split('|');
1320
- if (parts.length === 2) {
1321
- const BSDName = parts[0];
1322
- parts[1] = parts[1].trim();
1323
- const parts2 = parts[1].split(':');
1324
- if (parts2.length === 2) {
1325
- parts2[1] = parts2[1].trim();
1326
- const status = parts2[1].toLowerCase();
1327
- for (let i = 0; i < result.length; i++) {
1328
- if (result[i].BSDName === BSDName) {
1329
- result[i].smartStatus = status === 'passed' ? 'Ok' : status === 'failed!' ? 'Predicted Failure' : 'unknown';
1330
- }
1331
- }
1332
- }
1333
- }
1334
- }
1335
- });
1336
- commitResult(result);
1337
- });
1338
- } else {
1339
- commitResult(result);
1340
- }
1341
- }
1342
- });
1343
- } else {
1344
- commitResult(result);
1345
- }
1346
- });
1347
- }
1348
- if (_freebsd || _openbsd || _netbsd) {
1349
- if (callback) {
1350
- callback(result);
1351
- }
1352
- resolve(result);
1353
- }
1354
- if (_sunos) {
1355
- if (callback) {
1356
- callback(result);
1357
- }
1358
- resolve(result);
1359
- }
1360
- if (_darwin) {
1361
- let cmdFullSmart = '';
1362
- exec(`system_profiler SPSerialATADataType SPNVMeDataType SPUSBDataType SPStorageDataType`, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1363
- if (!error) {
1364
- // split by type:
1365
- const lines = stdout.toString().split('\n');
1366
- const linesSATA = [];
1367
- const linesNVMe = [];
1368
- const linesStorage = [];
1369
- const linesUSB = [];
1370
- let dataType = 'SATA';
1371
- lines.forEach((line) => {
1372
- if (line === 'NVMExpress:') {
1373
- dataType = 'NVMe';
1374
- } else if (line === 'Storage:') {
1375
- dataType = 'Storage';
1376
- } else if (line === 'USB:') {
1377
- dataType = 'USB';
1378
- } else if (line === 'SATA/SATA Express:') {
1379
- dataType = 'SATA';
1380
- } else if (dataType === 'SATA') {
1381
- linesSATA.push(line);
1382
- } else if (dataType === 'NVMe') {
1383
- linesNVMe.push(line);
1384
- } else if (dataType === 'Storage') {
1385
- linesStorage.push(line);
1386
- } else if (dataType === 'USB') {
1387
- linesUSB.push(line);
1388
- }
1389
- });
1390
- try {
1391
- // Serial ATA Drives
1392
- const devices = linesSATA.join('\n').split(' Physical Interconnect: ');
1393
- devices.shift();
1394
- devices.forEach((device) => {
1395
- device = 'InterfaceType: ' + device;
1396
- const lines = device.split('\n');
1397
- const mediumType = util.getValue(lines, 'Medium Type', ':', true).trim();
1398
- const sizeStr = util.getValue(lines, 'capacity', ':', true).trim();
1399
- const BSDName = util.sanitizeShellString(util.getValue(lines, 'BSD Name', ':', true).trim(), true);
1400
- if (sizeStr) {
1401
- let sizeValue = 0;
1402
- if (sizeStr.indexOf('(') >= 0) {
1403
- sizeValue = parseInt(
1404
- sizeStr
1405
- .match(/\(([^)]+)\)/)[1]
1406
- .replace(/\./g, '')
1407
- .replace(/,/g, '')
1408
- .replace(/\s/g, ''),
1409
- 10
1410
- );
1411
- }
1412
- if (!sizeValue) {
1413
- sizeValue = parseInt(sizeStr, 10);
1414
- }
1415
- if (sizeValue) {
1416
- const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
1417
- result.push({
1418
- device: BSDName,
1419
- type: mediumType.startsWith('Solid') ? 'SSD' : 'HD',
1420
- name: util.getValue(lines, 'Model', ':', true).trim(),
1421
- vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()) || util.getValue(lines, 'Manufacturer', ':', true),
1422
- size: sizeValue,
1423
- bytesPerSector: null,
1424
- totalCylinders: null,
1425
- totalHeads: null,
1426
- totalSectors: null,
1427
- totalTracks: null,
1428
- tracksPerCylinder: null,
1429
- sectorsPerTrack: null,
1430
- firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
1431
- serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
1432
- interfaceType: util.getValue(lines, 'InterfaceType', ':', true).trim(),
1433
- smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
1434
- temperature: null,
1435
- BSDName: BSDName
1436
- });
1437
- cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
1438
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
1439
- }
1440
- }
1441
- });
1442
- } catch {
1443
- util.noop();
1444
- }
1445
-
1446
- // NVME Drives
1447
- try {
1448
- const devices = linesNVMe.join('\n').split('\n\n Capacity:');
1449
- devices.shift();
1450
- devices.forEach((device) => {
1451
- device = `!Capacity: ${device}`;
1452
- const lines = device.split('\n');
1453
- const linkWidth = util.getValue(lines, 'link width', ':', true).trim();
1454
- const sizeStr = util.getValue(lines, '!capacity', ':', true).trim();
1455
- const BSDName = util.sanitizeShellString(util.getValue(lines, 'BSD Name', ':', true).trim(), true);
1456
- if (sizeStr) {
1457
- let sizeValue = 0;
1458
- if (sizeStr.indexOf('(') >= 0) {
1459
- sizeValue = parseInt(
1460
- sizeStr
1461
- .match(/\(([^)]+)\)/)[1]
1462
- .replace(/\./g, '')
1463
- .replace(/,/g, '')
1464
- .replace(/\s/g, ''),
1465
- 10
1466
- );
1467
- }
1468
- if (!sizeValue) {
1469
- sizeValue = parseInt(sizeStr, 10);
1470
- }
1471
- if (sizeValue) {
1472
- const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
1473
- result.push({
1474
- device: BSDName,
1475
- type: 'NVMe',
1476
- name: util.getValue(lines, 'Model', ':', true).trim(),
1477
- vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
1478
- size: sizeValue,
1479
- bytesPerSector: null,
1480
- totalCylinders: null,
1481
- totalHeads: null,
1482
- totalSectors: null,
1483
- totalTracks: null,
1484
- tracksPerCylinder: null,
1485
- sectorsPerTrack: null,
1486
- firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
1487
- serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
1488
- interfaceType: ('PCIe ' + linkWidth).trim(),
1489
- smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
1490
- temperature: null,
1491
- BSDName: BSDName
1492
- });
1493
- cmd = `${cmd}printf "\n${BSDName}|"; diskutil info /dev/${BSDName} | grep SMART;`;
1494
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
1495
- }
1496
- }
1497
- });
1498
- } catch {
1499
- util.noop();
1500
- }
1501
- // USB Drives (older macOS report storage devices under SPUSBDataType)
1502
- try {
1503
- const devices = linesUSB.join('\n').replace(/Media:\n /g, 'Model:').split('\n\n Product ID:');
1504
- devices.shift();
1505
- devices.forEach((device) => {
1506
- const lines = device.split('\n');
1507
- const sizeStr = util.getValue(lines, 'Capacity', ':', true).trim();
1508
- const BSDName = util.sanitizeShellString(util.getValue(lines, 'BSD Name', ':', true).trim(), true);
1509
- if (sizeStr) {
1510
- let sizeValue = 0;
1511
- if (sizeStr.indexOf('(') >= 0) {
1512
- sizeValue = parseInt(
1513
- sizeStr
1514
- .match(/\(([^)]+)\)/)[1]
1515
- .replace(/\./g, '')
1516
- .replace(/,/g, '')
1517
- .replace(/\s/g, ''),
1518
- 10
1519
- );
1520
- }
1521
- if (!sizeValue) {
1522
- sizeValue = parseInt(sizeStr, 10);
1523
- }
1524
- if (sizeValue) {
1525
- const smartStatusString = util.getValue(lines, 'S.M.A.R.T. status', ':', true).trim().toLowerCase();
1526
- result.push({
1527
- device: BSDName,
1528
- type: 'USB',
1529
- name: util.getValue(lines, 'Model', ':', true).trim().replace(/:/g, ''),
1530
- vendor: getVendorFromModel(util.getValue(lines, 'Model', ':', true).trim()),
1531
- size: sizeValue,
1532
- bytesPerSector: null,
1533
- totalCylinders: null,
1534
- totalHeads: null,
1535
- totalSectors: null,
1536
- totalTracks: null,
1537
- tracksPerCylinder: null,
1538
- sectorsPerTrack: null,
1539
- firmwareRevision: util.getValue(lines, 'Revision', ':', true).trim(),
1540
- serialNum: util.getValue(lines, 'Serial Number', ':', true).trim(),
1541
- interfaceType: 'USB',
1542
- smartStatus: smartStatusString === 'verified' ? 'OK' : smartStatusString || 'unknown',
1543
- temperature: null,
1544
- BSDName: BSDName
1545
- });
1546
- cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
1547
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
1548
- }
1549
- }
1550
- });
1551
- } catch {
1552
- util.noop();
1553
- }
1554
- // External drives (USB, Thunderbolt, ...) via SPStorageDataType
1555
- // only add drives not already reported by the SATA/NVMe/USB data types above
1556
- try {
1557
- const seen = {};
1558
- result.forEach((d) => {
1559
- const m = (d.BSDName || '').match(/disk\d+/);
1560
- if (m) {
1561
- seen[m[0]] = true;
1562
- }
1563
- });
1564
- const devices = linesStorage.join('\n').split(' Free:');
1565
- devices.shift();
1566
- devices.forEach((device) => {
1567
- const lines = device.split('\n');
1568
- const internal = util.getValue(lines, 'Internal', ':', true).trim().toLowerCase();
1569
- if (internal !== 'no') {
1570
- return;
1571
- }
1572
- const bsdMatch = util
1573
- .getValue(lines, 'BSD Name', ':', true)
1574
- .trim()
1575
- .match(/disk\d+/);
1576
- const BSDName = bsdMatch ? bsdMatch[0] : '';
1577
- if (!BSDName || seen[BSDName]) {
1578
- return;
1579
- }
1580
- const sizeStr = util.getValue(lines, 'Capacity', ':', true).trim();
1581
- if (sizeStr) {
1582
- let sizeValue = 0;
1583
- if (sizeStr.indexOf('(') >= 0) {
1584
- sizeValue = parseInt(
1585
- sizeStr
1586
- .match(/\(([^)]+)\)/)[1]
1587
- .replace(/\./g, '')
1588
- .replace(/,/g, '')
1589
- .replace(/\s/g, ''),
1590
- 10
1591
- );
1592
- }
1593
- if (!sizeValue) {
1594
- sizeValue = parseInt(sizeStr, 10);
1595
- }
1596
- if (sizeValue) {
1597
- seen[BSDName] = true;
1598
- const protocol = util.getValue(lines, 'Protocol', ':', true).trim();
1599
- const model = util.getValue(lines, 'Device Name', ':', true).trim();
1600
- result.push({
1601
- device: BSDName,
1602
- type: protocol && protocol !== 'USB' ? protocol : 'USB',
1603
- name: model,
1604
- vendor: getVendorFromModel(model),
1605
- size: sizeValue,
1606
- bytesPerSector: null,
1607
- totalCylinders: null,
1608
- totalHeads: null,
1609
- totalSectors: null,
1610
- totalTracks: null,
1611
- tracksPerCylinder: null,
1612
- sectorsPerTrack: null,
1613
- firmwareRevision: '',
1614
- serialNum: '',
1615
- interfaceType: protocol || 'USB',
1616
- smartStatus: 'unknown',
1617
- temperature: null,
1618
- BSDName: BSDName
1619
- });
1620
- cmd = cmd + 'printf "\n' + BSDName + '|"; diskutil info /dev/' + BSDName + ' | grep SMART;';
1621
- cmdFullSmart += `${cmdFullSmart ? 'printf ",";' : ''}smartctl -a -j ${BSDName};`;
1622
- }
1623
- }
1624
- });
1625
- } catch {
1626
- util.noop();
1627
- }
1628
- // check S.M.A.R.T. status
1629
- if (cmdFullSmart) {
1630
- exec(cmdFullSmart, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1631
- try {
1632
- const data = JSON.parse(`[${stdout}]`);
1633
- data.forEach((disk) => {
1634
- const diskBSDName = disk.smartctl.argv[disk.smartctl.argv.length - 1];
1635
-
1636
- for (let i = 0; i < result.length; i++) {
1637
- if (result[i].BSDName === diskBSDName) {
1638
- result[i].smartStatus = disk.smart_status.passed ? 'Ok' : disk.smart_status.passed === false ? 'Predicted Failure' : 'unknown';
1639
- if (disk.temperature && disk.temperature.current) {
1640
- result[i].temperature = disk.temperature.current;
1641
- }
1642
- result[i].smartData = disk;
1643
- }
1644
- }
1645
- });
1646
- commitResult(result);
1647
- } catch (e) {
1648
- if (cmd) {
1649
- cmd = cmd + 'printf "\n"';
1650
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1651
- const lines = stdout.toString().split('\n');
1652
- lines.forEach((line) => {
1653
- if (line) {
1654
- const parts = line.split('|');
1655
- if (parts.length === 2) {
1656
- const BSDName = parts[0];
1657
- parts[1] = parts[1].trim();
1658
- const parts2 = parts[1].split(':');
1659
- if (parts2.length === 2) {
1660
- parts2[1] = parts2[1].trim();
1661
- const status = parts2[1].toLowerCase();
1662
- for (let i = 0; i < result.length; i++) {
1663
- if (result[i].BSDName === BSDName) {
1664
- result[i].smartStatus = status === 'passed' ? 'Ok' : status === 'failed!' ? 'Predicted Failure' : 'unknown';
1665
- }
1666
- }
1667
- }
1668
- }
1669
- }
1670
- });
1671
- commitResult(result);
1672
- });
1673
- } else {
1674
- commitResult(result);
1675
- }
1676
- }
1677
- });
1678
- } else if (cmd) {
1679
- cmd = cmd + 'printf "\n"';
1680
- exec(cmd, { maxBuffer: 1024 * 1024 }, (error, stdout) => {
1681
- const lines = stdout.toString().split('\n');
1682
- lines.forEach((line) => {
1683
- if (line) {
1684
- const parts = line.split('|');
1685
- if (parts.length === 2) {
1686
- const BSDName = parts[0];
1687
- parts[1] = parts[1].trim();
1688
- const parts2 = parts[1].split(':');
1689
- if (parts2.length === 2) {
1690
- parts2[1] = parts2[1].trim();
1691
- const status = parts2[1].toLowerCase();
1692
- for (let i = 0; i < result.length; i++) {
1693
- if (result[i].BSDName === BSDName) {
1694
- result[i].smartStatus = status === 'not supported' ? 'not supported' : status === 'verified' ? 'Ok' : status === 'failing' ? 'Predicted Failure' : 'unknown';
1695
- }
1696
- }
1697
- }
1698
- }
1699
- }
1700
- });
1701
- commitResult(result);
1702
- });
1703
- } else {
1704
- commitResult(result);
1705
- }
1706
- } else {
1707
- commitResult(result);
1708
- }
1709
- });
1710
- }
1711
- if (_windows) {
1712
- try {
1713
- const workload = [];
1714
- workload.push(
1715
- util.powerShell(
1716
- 'Get-CimInstance Win32_DiskDrive | select Caption,Size,Status,PNPDeviceId,DeviceId,BytesPerSector,TotalCylinders,TotalHeads,TotalSectors,TotalTracks,TracksPerCylinder,SectorsPerTrack,FirmwareRevision,SerialNumber,InterfaceType | fl'
1717
- )
1718
- );
1719
- workload.push(util.powerShell('Get-PhysicalDisk | select BusType,MediaType,FriendlyName,Model,SerialNumber,Size | fl'));
1720
- if (util.smartMonToolsInstalled()) {
1721
- try {
1722
- const smartDev = JSON.parse(execSync('smartctl --scan -j').toString());
1723
- if (smartDev && smartDev.devices && smartDev.devices.length > 0) {
1724
- smartDev.devices.forEach((dev) => {
1725
- workload.push(execPromiseSave(`smartctl -j -a ${dev.name}`, util.execOptsWin));
1726
- });
1727
- }
1728
- } catch {
1729
- util.noop();
1730
- }
1731
- }
1732
- function hasControlCharacters(str) {
1733
- return /\p{Cc}/u.test(str);
1734
- }
1735
- util.promiseAll(workload).then((data) => {
1736
- let devices = data.results[0].toString().split(/\n\s*\n/);
1737
- devices.forEach((device) => {
1738
- const lines = device.split('\r\n');
1739
- const size = util.getValue(lines, 'Size', ':').trim();
1740
- const status = util.getValue(lines, 'Status', ':').trim().toLowerCase();
1741
- let serialNum = util.getValue(lines, 'SerialNumber', ':').trim();
1742
- if (hasControlCharacters(serialNum)) {
1743
- const instanceId = util.getValue(lines, 'PNPDeviceId', ':').trim().split('\\')[2];
1744
- if (instanceId) {
1745
- const parts = instanceId.split('&');
1746
- // instanceId can contain device serial number or be generated by PnP manager
1747
- // in first case it will be "<serial number>&0"
1748
- // in second case it will be opaque generated value that looks like this: "5&<8-symbol hex code>&0&000000"
1749
- // https://learn.microsoft.com/en-us/windows-hardware/drivers/install/instance-ids
1750
- if (parts.length == 2 && parts[1] === '0') {
1751
- serialNum = parts[0]
1752
- }
1753
- }
1754
- }
1755
- if (size) {
1756
- result.push({
1757
- device: util.getValue(lines, 'DeviceId', ':'), // changed from PNPDeviceId to DeviceID (be be able to match devices)
1758
- type: device.indexOf('SSD') > -1 ? 'SSD' : 'HD', // just a starting point ... better: MSFT_PhysicalDisk - Media Type ... see below
1759
- name: util.getValue(lines, 'Caption', ':'),
1760
- vendor: getVendorFromModel(util.getValue(lines, 'Caption', ':', true).trim()),
1761
- size: parseInt(size, 10),
1762
- bytesPerSector: parseInt(util.getValue(lines, 'BytesPerSector', ':'), 10),
1763
- totalCylinders: parseInt(util.getValue(lines, 'TotalCylinders', ':'), 10),
1764
- totalHeads: parseInt(util.getValue(lines, 'TotalHeads', ':'), 10),
1765
- totalSectors: parseInt(util.getValue(lines, 'TotalSectors', ':'), 10),
1766
- totalTracks: parseInt(util.getValue(lines, 'TotalTracks', ':'), 10),
1767
- tracksPerCylinder: parseInt(util.getValue(lines, 'TracksPerCylinder', ':'), 10),
1768
- sectorsPerTrack: parseInt(util.getValue(lines, 'SectorsPerTrack', ':'), 10),
1769
- firmwareRevision: util.getValue(lines, 'FirmwareRevision', ':').trim(),
1770
- serialNum,
1771
- interfaceType: util.getValue(lines, 'InterfaceType', ':').trim(),
1772
- smartStatus: status === 'ok' ? 'Ok' : status === 'degraded' ? 'Degraded' : status === 'pred fail' ? 'Predicted Failure' : 'Unknown',
1773
- temperature: null
1774
- });
1775
- }
1776
- });
1777
- devices = data.results[1].split(/\n\s*\n/);
1778
- devices.forEach((device) => {
1779
- const lines = device.split('\r\n');
1780
- const serialNum = util.getValue(lines, 'SerialNumber', ':').trim();
1781
- const name = util.getValue(lines, 'FriendlyName', ':').trim().replace('Msft ', 'Microsoft');
1782
- const size = util.getValue(lines, 'Size', ':').trim();
1783
- const model = util.getValue(lines, 'Model', ':').trim();
1784
- const interfaceType = util.getValue(lines, 'BusType', ':').trim();
1785
- let mediaType = util.getValue(lines, 'MediaType', ':').trim();
1786
- if (mediaType === '3' || mediaType === 'HDD') {
1787
- mediaType = 'HD';
1788
- }
1789
- if (mediaType === '4') {
1790
- mediaType = 'SSD';
1791
- }
1792
- if (mediaType === '5') {
1793
- mediaType = 'SCM';
1794
- }
1795
- if (mediaType === 'Unspecified' && (model.toLowerCase().indexOf('virtual') > -1 || model.toLowerCase().indexOf('vbox') > -1)) {
1796
- mediaType = 'Virtual';
1797
- }
1798
- if (size) {
1799
- let i = util.findObjectByKey(result, 'serialNum', serialNum);
1800
- if (i === -1 || serialNum === '') {
1801
- i = util.findObjectByKey(result, 'name', name);
1802
- }
1803
- if (i !== -1) {
1804
- result[i].type = mediaType;
1805
- result[i].interfaceType = interfaceType;
1806
- }
1807
- }
1808
- });
1809
- // S.M.A.R.T
1810
- data.results.shift();
1811
- data.results.shift();
1812
- if (data.results.length) {
1813
- data.results.forEach((smartStr) => {
1814
- try {
1815
- const smartData = JSON.parse(smartStr);
1816
- if (smartData.serial_number) {
1817
- const serialNum = smartData.serial_number;
1818
- const i = util.findObjectByKey(result, 'serialNum', serialNum);
1819
- if (i !== -1) {
1820
- result[i].smartStatus =
1821
- smartData.smart_status && smartData.smart_status.passed ? 'Ok' : smartData.smart_status && smartData.smart_status.passed === false ? 'Predicted Failure' : 'unknown';
1822
- if (smartData.temperature && smartData.temperature.current) {
1823
- result[i].temperature = smartData.temperature.current;
1824
- }
1825
- result[i].smartData = smartData;
1826
- }
1827
- }
1828
- } catch {
1829
- util.noop();
1830
- }
1831
- });
1832
- }
1833
- if (callback) {
1834
- callback(result);
1835
- }
1836
- resolve(result);
1837
- });
1838
- } catch {
1839
- if (callback) {
1840
- callback(result);
1841
- }
1842
- resolve(result);
1843
- }
1844
- }
1845
- });
1846
- });
1847
- }
1848
-
1849
- exports.diskLayout = diskLayout;