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
|
|
@ -26,6 +26,35 @@
|
|||
export PATH="${pkgs.nvd}/bin:${pkgs.coreutils}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin:$PATH"
|
||||
exec ${pkgs.bash}/bin/bash ${../scripts/record-update.sh} "$@"
|
||||
'')
|
||||
# Stats stream for the quickshell server monitor on the desktops:
|
||||
# `ssh mediaserver qs-stats` = top's 2s batch stream, interleaved with
|
||||
# one @STAT line per tick (hottest coretemp across both sockets, WAN
|
||||
# byte rates from eno1). Everything rides one SSH connection.
|
||||
(pkgs.writeShellScriptBin "qs-stats" ''
|
||||
C=${pkgs.coreutils}/bin
|
||||
export LC_ALL=C
|
||||
${pkgs.procps}/bin/top -b -d 2 -w 512 &
|
||||
trap 'kill $! 2>/dev/null' EXIT
|
||||
prev_rx=""
|
||||
while :; do
|
||||
t=0
|
||||
for h in /sys/class/hwmon/*; do
|
||||
if [ "$($C/cat "$h/name" 2>/dev/null)" = coretemp ]; then
|
||||
for f in "$h"/temp*_input; do
|
||||
v=$($C/cat "$f" 2>/dev/null || echo 0)
|
||||
[ "$v" -gt "$t" ] && t=$v
|
||||
done
|
||||
fi
|
||||
done
|
||||
read -r rx tx < <(${pkgs.gawk}/bin/awk '$1 == "eno1:" {print $2, $10}' /proc/net/dev)
|
||||
if [ -n "$prev_rx" ]; then
|
||||
echo "@STAT temp=$((t / 1000)) rxbps=$(( (rx - prev_rx) / 2 )) txbps=$(( (tx - prev_tx) / 2 ))"
|
||||
fi
|
||||
prev_rx=$rx
|
||||
prev_tx=$tx
|
||||
$C/sleep 2
|
||||
done
|
||||
'')
|
||||
];
|
||||
|
||||
# Basic networking
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue