server monitor: qs-stats stream adds cpu temp + wan throughput
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
87165b5a62
commit
72864463d0
2 changed files with 90 additions and 2 deletions
|
|
@ -1748,11 +1748,31 @@ in
|
|||
property string uptime: ""
|
||||
property string load: ""
|
||||
property var procs: []
|
||||
property int tempC: -1
|
||||
property real rxBps: 0
|
||||
property real txBps: 0
|
||||
|
||||
function fmtRate(bps) {
|
||||
const b = bps * 8;
|
||||
if (b >= 1e9) return (b / 1e9).toFixed(2) + " Gb/s";
|
||||
if (b >= 1e6) return (b / 1e6).toFixed(1) + " Mb/s";
|
||||
if (b >= 1e3) return Math.round(b / 1e3) + " Kb/s";
|
||||
return Math.round(b) + " b/s";
|
||||
}
|
||||
|
||||
property var _procsPending: []
|
||||
property bool _collecting: false
|
||||
|
||||
function _parseLine(line) {
|
||||
if (line.indexOf("@STAT ") === 0) {
|
||||
const t = line.match(/temp=(\d+)/);
|
||||
if (t) tempC = parseInt(t[1]);
|
||||
const rx = line.match(/rxbps=(-?\d+)/);
|
||||
if (rx) rxBps = Math.max(0, parseInt(rx[1]));
|
||||
const tx = line.match(/txbps=(-?\d+)/);
|
||||
if (tx) txBps = Math.max(0, parseInt(tx[1]));
|
||||
return;
|
||||
}
|
||||
if (line.indexOf("top - ") === 0) {
|
||||
if (_collecting) procs = _procsPending;
|
||||
_collecting = false;
|
||||
|
|
@ -1792,8 +1812,7 @@ in
|
|||
command: [Commands.ssh, "-o", "BatchMode=yes", "-o", "ConnectTimeout=3",
|
||||
"-o", "StrictHostKeyChecking=accept-new",
|
||||
"-o", "ServerAliveInterval=5", "-o", "ServerAliveCountMax=2",
|
||||
"fred@10.0.0.1",
|
||||
"env", "LC_ALL=C", "top", "-b", "-d", "2", "-w", "512"]
|
||||
"fred@10.0.0.1", "qs-stats"]
|
||||
running: true
|
||||
stdout: SplitParser {
|
||||
onRead: data => srvWidget._parseLine(data)
|
||||
|
|
@ -2867,6 +2886,46 @@ in
|
|||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: 10
|
||||
SText { width: 42; text: "temp"; color: Theme.base04 }
|
||||
SText {
|
||||
text: srvWidget.tempC < 0 ? "--" : srvWidget.tempC + "°C"
|
||||
font.weight: Font.Medium
|
||||
color: srvWidget.tempC < 0 ? Theme.base03
|
||||
: srvWidget.tempC >= 85 ? Theme.base08
|
||||
: srvWidget.tempC >= 70 ? Theme.base0A : Theme.base05
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: 10
|
||||
SText { width: 42; text: "wan"; color: Theme.base04 }
|
||||
Row {
|
||||
spacing: 14
|
||||
Row {
|
||||
spacing: 4
|
||||
SIcon { text: "arrow_downward"; font.pixelSize: 14; color: Theme.base0B; anchors.verticalCenter: parent.verticalCenter }
|
||||
SText {
|
||||
text: srvWidget.fmtRate(srvWidget.rxBps)
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
Row {
|
||||
spacing: 4
|
||||
SIcon { text: "arrow_upward"; font.pixelSize: 14; color: Theme.base09; anchors.verticalCenter: parent.verticalCenter }
|
||||
SText {
|
||||
text: srvWidget.fmtRate(srvWidget.txBps)
|
||||
font.weight: Font.Medium
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: 10
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue