summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/st-power55
-rwxr-xr-xbin/st-temp13
2 files changed, 31 insertions, 37 deletions
diff --git a/bin/st-power b/bin/st-power
index e3fe69a..ebed025 100755
--- a/bin/st-power
+++ b/bin/st-power
@@ -1,8 +1,8 @@
#!/bin/sh
-# for UPS monitoring with NUT
+# for UPS monitoring with NUT, and AMD GPU power querying through lm_sensors (09-26-2026)
#
-#DATA_CMD="upsc ups@localhost"
+DATA_CMD="upsc ups@localhost"
# on debian and freebsd, ups.realpower is not available.
# calculate load in watts with load percent and max output instead.
@@ -10,45 +10,30 @@
#LOAD_VALUE=$($DATA_CMD | grep ups.load: | awk '{print $2}')
#LOAD_PERCENT=$(echo "scale=2; $LOAD_VALUE/100" | bc)
#POWER=$(echo "scale=0; $LOAD_PERCENT*$MAX_OUTPUT" | bc)
+UPS_POWER="$($DATA_CMD | grep ups.realpower: | awk '{print $2}')W"
-# on void, ups.realpower is available!
-#POWER="$($DATA_CMD | grep ups.realpower: | awk '{print $2}') W"
-
-# "round" to integer. just removes decimal and whatevers after. not necessary with ups.realpower.
+# "round" to integer. just removes decimal and whatevers after.
#POWER="${POWER%.*} W"
-#CHARGE="$($DATA_CMD | grep battery.charge: | awk '{print $2}')%"
+UPS_CHARGE="$($DATA_CMD | grep battery.charge: | awk '{print $2}')%"
-#if [ "$CHARGE" = "100%" ]; then
-# echo $POWER
-#else
-# echo "$CHARGE $POWER"
-#fi
+GPU_POWER="$(sensors | grep "PPT" | awk '{print $2}' | sed 's/\.00//g')W"
-# for battery monitoring everywhere else
-#
-# if power_now is present, just divide it to watts.
-# (from micro watts on thinkpads, perhaps something else on other platforms)
-if test -f /sys/class/power_supply/BAT*/power_now; then
- POWER=$(cat /sys/class/power_supply/BAT*/power_now)
- POWER="$(echo "scale=2; $POWER/1000000" | bc)W"
+if [ "$UPS_CHARGE" = "100%" ]; then
+ echo "UPS: $UPS_POWER GPU: $GPU_POWER"
else
-# if power_now is not present, calculate it:
- VOLTAGE=$(cat /sys/class/power_supply/BAT*/voltage_now)
- CURRENT=$(cat /sys/class/power_supply/BAT*/current_now)
- POWER="$(echo "scale=2; $VOLTAGE*$CURRENT/1000000000000" | bc)W"
+ echo "UPS: $UPS_CHARGE $UPS_POWER GPU: $GPU_POWER"
fi
-STATUS=$(cat /sys/class/power_supply/BAT*/status)
-
-#case "$STATUS" in
-# "Charging")
-# STATUS="+";;
-# "Discharging")
-# STATUS="-";;
-# "Not Charging")
-# STATUS="...";;
-#esac
+# for battery monitoring everywhere else
+#
+# if power_now is not present, calculate it:
+#VOLTAGE=$(cat /sys/class/power_supply/BAT*/voltage_now)
+#CURRENT=$(cat /sys/class/power_supply/BAT*/current_now)
+#POWER=$(echo "scale=2; $VOLTAGE*$CURRENT/1000000000000" | bc)
-CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%"
+# if it is present, just divide it to watts (from micro watts on thinkpads, perhaps something else on other platforms)
+#POWER=$(cat /sys/class/power_supply/BAT*/power_now)
+#POWER="$(echo "scale=2; $POWER/1000000" | bc)W"
+#CHARGE="$(cat /sys/class/power_supply/BAT*/capacity)%"
-echo "$CHARGE $POWER $STATUS"
+#echo "$CHARGE $POWER"
diff --git a/bin/st-temp b/bin/st-temp
index 20d7a01..25333fa 100755
--- a/bin/st-temp
+++ b/bin/st-temp
@@ -1,5 +1,14 @@
#!/bin/sh
-CPUTEMP=$(sensors | grep "Package id 0" | awk '{print $4}' | sed 's/+//;s/\.0//g' )
+RAW=$(sensors | grep -e "Package id 0" -e "edge" -e "PPT")
+
+CPUTEMP=$(echo $RAW | awk '{print $4}' | sed 's/+//;s/\.0//g')
+#CPUPOWER=$(turbostat -Sq -i 1 --show PkgWatt --num_iterations 1 | awk 'NR==2')
+
+#GPUTEMP=$(sensors | grep "edge" | awk '{print $2}' | sed 's/+//;s/\.0//g')
+GPUTEMP=$(echo $RAW | awk '{print $12}' | sed 's/+//;s/\.0//g')
+#GPUPOWER=$(echo $RAW | awk '{print $20}' | sed 's/\.00//g')
+
+
# freebsd
#CORETEMPS=$(sysctl dev.cpu | grep temperature | awk '{print $2}' | sed s/.[0-9]C$//g)
@@ -15,4 +24,4 @@ CPUTEMP=$(sensors | grep "Package id 0" | awk '{print $4}' | sed 's/+//;s/\.0//g
#
#CPUTEMP="$((SUM / CORE_COUNT)) C"
-echo $CPUTEMP
+echo "CPU: $CPUTEMP GPU: $GPUTEMP"