opt. & new

- opt.: docker page perf
- new: docker stats
This commit is contained in:
lollipopkit
2023-08-02 23:07:11 +08:00
parent 336c31e48d
commit 0038ed347f
10 changed files with 215 additions and 136 deletions

View File

@@ -36,7 +36,8 @@ enum DockerErrType {
noClient,
notInstalled,
invalidVersion,
cmdNoPrefix
cmdNoPrefix,
segmentsNotMatch,
}
class DockerErr extends Err<DockerErrType> {

View File

@@ -1,9 +1,13 @@
import '../../res/server_cmd.dart';
class AppShellFunc {
final String name;
final String cmd;
final String flag;
const AppShellFunc(this.name, this.cmd, this.flag);
String get exec => 'sh $shellPath -$flag';
}
typedef AppShellFuncs = List<AppShellFunc>;
@@ -39,3 +43,8 @@ esac
return sb.toString();
}
}
// enum AppShellFuncType {
// status,
// docker;
// }

View File

@@ -8,6 +8,10 @@ class DockerPsItem {
late String status;
late String ports;
late String name;
String? cpu;
String? mem;
String? net;
String? disk;
DockerPsItem(
this.containerId,
@@ -37,6 +41,20 @@ class DockerPsItem {
}
}
void parseStats(String rawString) {
if (rawString.isEmpty) {
return;
}
final parts = rawString.split(_seperator);
if (parts.length != 8) {
return;
}
cpu = parts[2];
mem = parts[3];
net = parts[5];
disk = parts[6];
}
bool get running => status.contains('Up ');
@override