Update 2022-12-05 17:03 Linux/x86_64

This commit is contained in:
Stefan Hagen 2022-12-05 17:03:22 +01:00
parent 4ad2e85880
commit e5a3d424cc

View File

@ -1,20 +1,40 @@
#!/bin/ksh
out() { printf '%s/1000/1000\n' "$1" | bc; }
linux_server() {
while true
do
printf " %s   %3s%%   %s°C   %s (priv)   %4sMhz  \n" \
"$(who | cut -d" " -f1 | sort -u | wc -l)" \
"$(ps -u d034266 -o pcpu | awk '/[0-9\.]/ { s=s+$1 } END { printf("%.0d\n", s); }')" \
"$(sensors | awk '/^Core/ { s=$3+s } END { printf("%2d\n", s/60); }')" \
"$(df -h --output=avail /priv/ | tail -1)" \
"$(lscpu | awk '/^CPU MHz:/ { printf("%.4d", $3) }')"
sleep 5
done
}
while true
do
set -A _SYSV -- $(sysctl -n hw.sensors.cpu0.temp0 \
hw.sensors.acpithinkpad0.fan0 \
hw.cpuspeed \
| cut -d" " -f1)
openbsd_laptop() {
out() { printf '%s/1000/1000\n' "$1" | bc; }
while true
do
set -A _SYSV -- $(sysctl -n hw.sensors.cpu0.temp0 \
hw.sensors.acpithinkpad0.fan0 \
hw.cpuspeed \
| cut -d" " -f1)
_TMP="$(sysctl -n hw.sensors.cpu{0,1,2,3,4,5,6,7,8,9,10,11}.frequency0 \
| cut -d. -f1)"
AVG="$(printf '(%s)/12' "$_TMP" | tr '\n' '+')"
printf " %s%%   %2s°C   %4sRPM   %4sMhz (~%4sMhz)  \n" \
"$(apm -l)" "${_SYSV[0]}" "${_SYSV[1]}" "${_SYSV[2]}" "$(out $AVG)";
sleep 5
done
}
_TMP="$(sysctl -n hw.sensors.cpu{0,1,2,3,4,5,6,7,8,9,10,11}.frequency0 \
| cut -d. -f1)"
case $(hostname) in
ld*) linux_server; ;;
*.home.codevoid.de) openbsd_laptop; ;;
esac
AVG="$(printf '(%s)/12' "$_TMP" | tr '\n' '+')"
printf " %s%%   %2s°C   %4sRPM   %4sMhz (~%4sMhz)  \n" \
"$(apm -l)" "${_SYSV[0]}" "${_SYSV[1]}" "${_SYSV[2]}" "$(out $AVG)";
sleep 5
done