mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: gpu percent / fanSpeed
This commit is contained in:
@@ -66,21 +66,31 @@ class NvdiaSmi {
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
memoryProcesses.removeWhere((element) => element == null);
|
memoryProcesses.removeWhere((element) => element == null);
|
||||||
|
final percent = gpu
|
||||||
|
.findElements('utilization')
|
||||||
|
.firstOrNull
|
||||||
|
?.findElements('gpu_util')
|
||||||
|
.firstOrNull
|
||||||
|
?.innerText;
|
||||||
|
final fanSpeed = gpu.findElements('fan_speed').firstOrNull?.innerText;
|
||||||
if (name != null &&
|
if (name != null &&
|
||||||
temp != null &&
|
temp != null &&
|
||||||
powerDraw != null &&
|
powerDraw != null &&
|
||||||
powerLimit != null &&
|
powerLimit != null &&
|
||||||
memory != null) {
|
memory != null) {
|
||||||
return NvdiaSmiItem(
|
return NvdiaSmiItem(
|
||||||
name,
|
name: name,
|
||||||
int.parse(temp.split(' ').firstOrNull ?? '0'),
|
uuid: gpu.findElements('uuid').firstOrNull?.innerText ?? '',
|
||||||
'$powerDraw / $powerLimit',
|
temp: int.parse(temp.split(' ').firstOrNull ?? '0'),
|
||||||
NvdiaSmiMem(
|
percent: int.parse(percent?.split(' ').firstOrNull ?? '0'),
|
||||||
|
power: '$powerDraw / $powerLimit',
|
||||||
|
memory: NvdiaSmiMem(
|
||||||
int.parse(memoryTotal?.split(' ').firstOrNull ?? '0'),
|
int.parse(memoryTotal?.split(' ').firstOrNull ?? '0'),
|
||||||
int.parse(memoryUsed?.split(' ').firstOrNull ?? '0'),
|
int.parse(memoryUsed?.split(' ').firstOrNull ?? '0'),
|
||||||
'MiB',
|
'MiB',
|
||||||
List.from(memoryProcesses),
|
List.from(memoryProcesses),
|
||||||
),
|
),
|
||||||
|
fanSpeed: int.parse(fanSpeed?.split(' ').firstOrNull ?? '0'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -91,12 +101,23 @@ class NvdiaSmi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class NvdiaSmiItem {
|
class NvdiaSmiItem {
|
||||||
|
final String uuid;
|
||||||
final String name;
|
final String name;
|
||||||
final int temp;
|
final int temp;
|
||||||
final String power;
|
final String power;
|
||||||
final NvdiaSmiMem memory;
|
final NvdiaSmiMem memory;
|
||||||
|
final int percent;
|
||||||
|
final int fanSpeed;
|
||||||
|
|
||||||
const NvdiaSmiItem(this.name, this.temp, this.power, this.memory);
|
const NvdiaSmiItem({
|
||||||
|
required this.uuid,
|
||||||
|
required this.name,
|
||||||
|
required this.temp,
|
||||||
|
required this.power,
|
||||||
|
required this.memory,
|
||||||
|
required this.percent,
|
||||||
|
required this.fanSpeed,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
|||||||
@@ -327,18 +327,24 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
}
|
}
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(item.name, style: UIs.textSize13),
|
title: Text(item.name, style: UIs.textSize13),
|
||||||
leading: Text(
|
|
||||||
'${item.temp}°C',
|
|
||||||
style: UIs.textSize11Grey,
|
|
||||||
textScaler: _textFactor,
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
'${item.power} - ${mem.used} / ${mem.total} ${mem.unit}',
|
'${item.power} - ${item.temp} °C\n${mem.used} / ${mem.total} ${mem.unit} - ${item.fanSpeed} RPM',
|
||||||
style: UIs.textSize11Grey,
|
style: UIs.textSize11Grey,
|
||||||
textScaler: _textFactor,
|
textScaler: _textFactor,
|
||||||
),
|
),
|
||||||
trailing: InkWell(
|
contentPadding: const EdgeInsets.only(left: 17, right: 17),
|
||||||
onTap: () {
|
trailing: SizedBox(
|
||||||
|
width: 67,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'${item.percent}%',
|
||||||
|
style: UIs.textSize11Grey,
|
||||||
|
textScaler: _textFactor,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
final height = () {
|
final height = () {
|
||||||
if (processes.length > 5) {
|
if (processes.length > 5) {
|
||||||
return 5 * 47.0;
|
return 5 * 47.0;
|
||||||
@@ -352,7 +358,8 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
height: height,
|
height: height,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: processes.length,
|
itemCount: processes.length,
|
||||||
itemBuilder: (_, idx) => _buildGpuProcessItem(processes[idx]),
|
itemBuilder: (_, idx) =>
|
||||||
|
_buildGpuProcessItem(processes[idx]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
@@ -363,7 +370,10 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Icon(Icons.info_outline, size: 17),
|
icon: const Icon(Icons.info_outline, size: 17),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -393,6 +403,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
|||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
|
UIs.height13,
|
||||||
Text('Memory: ${process.memory} MiB'),
|
Text('Memory: ${process.memory} MiB'),
|
||||||
UIs.height13,
|
UIs.height13,
|
||||||
Text('Process: ${process.name}')
|
Text('Process: ${process.name}')
|
||||||
|
|||||||
Reference in New Issue
Block a user