@axium/sysadmin 0.3.0 → 0.3.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.
- package/dist/client/info.js +19 -8
- package/package.json +1 -1
package/dist/client/info.js
CHANGED
|
@@ -65,7 +65,7 @@ function gpus() {
|
|
|
65
65
|
}
|
|
66
66
|
return result;
|
|
67
67
|
}
|
|
68
|
-
/** PCIe generations by their per-lane transfer rate in GT/s, as reported by `
|
|
68
|
+
/** PCIe generations by their per-lane transfer rate in GT/s, as reported by `max_link_speed`. */
|
|
69
69
|
const pcieGenerations = {
|
|
70
70
|
'2.5': '1.0',
|
|
71
71
|
'5.0': '2.0',
|
|
@@ -79,6 +79,16 @@ const pcieGenerations = {
|
|
|
79
79
|
function formatLinkRate(mbps) {
|
|
80
80
|
return mbps >= 1000 ? `${(mbps / 1000).toFixed(1).replace(/\.0$/, '')} Gbps` : `${mbps} Mbps`;
|
|
81
81
|
}
|
|
82
|
+
/** A PCIe `*_link_speed` value (`16.0 GT/s PCIe`) in GT/s, or Infinity when it is missing or unparseable. */
|
|
83
|
+
function linkRate(path) {
|
|
84
|
+
const rate = Number(read(path)?.split(' ')[0]);
|
|
85
|
+
return rate > 0 ? rate : Infinity;
|
|
86
|
+
}
|
|
87
|
+
/** A PCIe `*_link_width` value in lanes, or Infinity when it is missing or unparseable. */
|
|
88
|
+
function linkWidth(path) {
|
|
89
|
+
const width = Number(read(path));
|
|
90
|
+
return width > 0 ? width : Infinity;
|
|
91
|
+
}
|
|
82
92
|
/** The SATA link speed of an `ataN` device directory, e.g. '6.0 Gbps'. */
|
|
83
93
|
function sataSpeed(ata) {
|
|
84
94
|
for (const link of list(ata)) {
|
|
@@ -108,13 +118,14 @@ function diskInterface(dev) {
|
|
|
108
118
|
const speed = sataSpeed(dir);
|
|
109
119
|
return speed ? `SATA ${speed}` : 'SATA';
|
|
110
120
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
121
|
+
if (fs.existsSync(`${dir}/max_link_speed`)) {
|
|
122
|
+
const parent = path.dirname(dir);
|
|
123
|
+
const rate = Math.min(linkRate(`${dir}/max_link_speed`), linkRate(`${parent}/max_link_speed`));
|
|
124
|
+
const width = Math.min(linkWidth(`${dir}/max_link_width`), linkWidth(`${parent}/max_link_width`));
|
|
125
|
+
if (Number.isFinite(rate)) {
|
|
126
|
+
const generation = pcieGenerations[rate.toFixed(1)];
|
|
127
|
+
return `PCIe ${generation ?? `${rate} GT/s`}${Number.isFinite(width) ? ` x${width}` : ''}`;
|
|
128
|
+
}
|
|
118
129
|
}
|
|
119
130
|
// USB devices (as opposed to their interfaces) carry the descriptor fields; `speed` is in Mbit/s.
|
|
120
131
|
if (fs.existsSync(`${dir}/idVendor`)) {
|