mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
feat: display cpu model (#477)
This commit is contained in:
@@ -4,11 +4,14 @@ import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:server_box/data/model/server/time_seq.dart';
|
||||
import 'package:server_box/data/res/status.dart';
|
||||
|
||||
/// Capacity of the FIFO queue
|
||||
const _kCap = 30;
|
||||
|
||||
class Cpus extends TimeSeq<List<SingleCpuCore>> {
|
||||
Cpus(super.init1, super.init2);
|
||||
|
||||
final Map<String, int> brand = {};
|
||||
|
||||
@override
|
||||
void onUpdate() {
|
||||
_coresCount = now.length;
|
||||
@@ -175,6 +178,22 @@ class SingleCpuCore extends TimeSeqIface<SingleCpuCore> {
|
||||
}
|
||||
}
|
||||
|
||||
final class CpuBrand {
|
||||
static Map<String, int> parse(String raw) {
|
||||
final lines = raw.split('\n');
|
||||
// {brand: count}
|
||||
final brands = <String, int>{};
|
||||
for (var line in lines) {
|
||||
if (line.contains('model name')) {
|
||||
final model = line.split(':').last.trim();
|
||||
final count = brands[model] ?? 0;
|
||||
brands[model] = count + 1;
|
||||
}
|
||||
}
|
||||
return brands;
|
||||
}
|
||||
}
|
||||
|
||||
final _bsdCpuPercentReg = RegExp(r'(\d+\.\d+)%');
|
||||
|
||||
/// TODO: Change this implementation to parse cpu status on BSD system
|
||||
|
||||
Reference in New Issue
Block a user