mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new & opt
new: `net` total in & out bytes opt: i18n for `ssh` opt: disk path ignore
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import '../../res/misc.dart';
|
||||
|
||||
class DiskInfo {
|
||||
/*
|
||||
{
|
||||
@@ -26,3 +28,24 @@ class DiskInfo {
|
||||
this.avail,
|
||||
);
|
||||
}
|
||||
|
||||
List<DiskInfo> parseDisk(String raw) {
|
||||
final list = <DiskInfo>[];
|
||||
final items = raw.split('\n');
|
||||
items.removeAt(0);
|
||||
for (var item in items) {
|
||||
if (item.isEmpty) {
|
||||
continue;
|
||||
}
|
||||
final vals = item.split(numReg);
|
||||
list.add(DiskInfo(
|
||||
vals[0],
|
||||
vals[5],
|
||||
int.parse(vals[4].replaceFirst('%', '')),
|
||||
vals[2],
|
||||
vals[1],
|
||||
vals[3],
|
||||
));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedInBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalIn({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalInBytes = _now[idx].bytesIn;
|
||||
return totalInBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
String speedOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb/s';
|
||||
final idx = deviceIdx(device);
|
||||
@@ -44,6 +51,13 @@ class NetSpeed {
|
||||
return buildStandardOutput(speedOutBytesPerSecond);
|
||||
}
|
||||
|
||||
String totalOut({String? device}) {
|
||||
if (_old[0].device == '' || _now[0].device == '') return '0kb';
|
||||
final idx = deviceIdx(device);
|
||||
final totalOutBytes = _now[idx].bytesOut;
|
||||
return totalOutBytes.toInt().convertBytes;
|
||||
}
|
||||
|
||||
int deviceIdx(String? device) {
|
||||
if (device != null) {
|
||||
for (var item in _now) {
|
||||
@@ -55,10 +69,15 @@ class NetSpeed {
|
||||
return 0;
|
||||
}
|
||||
|
||||
String buildStandardOutput(double speed) =>
|
||||
'${speed.convertBytes.toLowerCase()}/s';
|
||||
String buildStandardOutput(double speed) => '${speed.convertBytes}/s';
|
||||
}
|
||||
|
||||
/// [raw] example:
|
||||
/// Inter-| Receive | Transmit
|
||||
/// face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
|
||||
/// lo: 45929941 269112 0 0 0 0 0 0 45929941 269112 0 0 0 0 0 0
|
||||
/// eth0: 48481023 505772 0 0 0 0 0 0 36002262 202307 0 0 0 0 0 0
|
||||
/// 1635752901
|
||||
List<NetSpeedPart> parseNetSpeed(String raw) {
|
||||
final split = raw.split('\n');
|
||||
if (split.length < 4) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import '../../../core/extension/stringx.dart';
|
||||
import '../../res/misc.dart';
|
||||
|
||||
///
|
||||
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
|
||||
@@ -42,8 +43,6 @@ class TcpStatus {
|
||||
}
|
||||
}
|
||||
|
||||
final numReg = RegExp(r'\s{1,}');
|
||||
|
||||
TcpStatus? parseTcp(String raw) {
|
||||
final lines = raw.split('\n');
|
||||
final idx = lines.lastWhere((element) => element.startsWith('Tcp:'),
|
||||
|
||||
Reference in New Issue
Block a user