31 lines
1.0 KiB
Bash
Executable File
31 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# for UPS monitoring with NUT
|
|
#
|
|
#POWER="$(upsc titanium-power@localhost | grep ups.realpower: | awk '{print $2}')W"
|
|
#CHARGE="$(upsc titanium-power@localhost | grep battery.charge: | awk '{print $2}')%"
|
|
#if [ "$CHARGE" = "100%" ]; then
|
|
# echo $POWER
|
|
#else
|
|
# echo "$CHARGE $POWER"
|
|
#fi
|
|
|
|
# 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)
|
|
|
|
# freebsd
|
|
#CHARGE=$(acpiconf -i 0 | grep "Remaining capacity" | awk '{print $3}')
|
|
#POWER_RAW=$(acpiconf -i 0 | grep "Present rate:" | awk '{print $3}')
|
|
#POWER="$(echo "scale=1; $POWER_RAW/1000" | bc)W"
|
|
|
|
# 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"
|