Skip to content

Commit 0ae80e4

Browse files
committed
chore: more checks with lscpu
1 parent 85acbf7 commit 0ae80e4

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/system/system.service.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,33 @@ export class SystemService {
184184
encoding: "utf8",
185185
}).trim();
186186

187-
const biosModel = execSync(
188-
"lscpu | grep 'BIOS Model name' | awk '{print $3}'",
189-
{ encoding: "utf8" },
190-
).trim();
187+
let cpuGHz: string | undefined;
191188

192-
const modelGHzMatch = model.match(/(\d+\.?\d*)\s*GHz/i);
189+
if (!cpuGHz) {
190+
const modelGHzMatch = model.match(/(\d+\.?\d*)\s*GHz/i);
193191

194-
let cpuGHz: string | undefined;
192+
if (modelGHzMatch) {
193+
cpuGHz = modelGHzMatch.at(1);
194+
}
195+
}
195196

196-
if (modelGHzMatch) {
197-
cpuGHz = modelGHzMatch.at(1);
197+
if (!cpuGHz) {
198+
const maxMHz = execSync("lscpu | grep 'CPU max MHz:'", {
199+
encoding: "utf8",
200+
}).trim();
201+
202+
const maxMHzMatch = maxMHz.match(/(\d+\.?\d*)\s*MHz/i);
203+
if (maxMHzMatch) {
204+
cpuGHz = maxMHzMatch.at(1);
205+
}
198206
}
199207

200208
if (!cpuGHz) {
209+
const biosModel = execSync(
210+
"lscpu | grep 'BIOS Model name' | awk '{print $3}'",
211+
{ encoding: "utf8" },
212+
).trim();
213+
201214
const biosModelGHzMatch = biosModel.match(/(\d+\.?\d*)\s*GHz/i);
202215

203216
if (biosModelGHzMatch) {

0 commit comments

Comments
 (0)