update
This commit is contained in:
15
bin/st-power
15
bin/st-power
@ -6,13 +6,16 @@ DATA_CMD="upsc ups@localhost"
|
|||||||
|
|
||||||
# on debian and freebsd, ups.realpower is not available.
|
# on debian and freebsd, ups.realpower is not available.
|
||||||
# calculate load in watts with load percent and max output instead.
|
# calculate load in watts with load percent and max output instead.
|
||||||
MAX_OUTPUT=$($DATA_CMD | grep ups.realpower.nominal: | awk '{print $2}')
|
#MAX_OUTPUT=$($DATA_CMD | grep ups.realpower.nominal: | awk '{print $2}')
|
||||||
LOAD_VALUE=$($DATA_CMD | grep ups.load: | awk '{print $2}')
|
#LOAD_VALUE=$($DATA_CMD | grep ups.load: | awk '{print $2}')
|
||||||
LOAD_PERCENT=$(echo "scale=2; $LOAD_VALUE/100" | bc)
|
#LOAD_PERCENT=$(echo "scale=2; $LOAD_VALUE/100" | bc)
|
||||||
POWER=$(echo "scale=0; $LOAD_PERCENT*$MAX_OUTPUT" | bc)
|
#POWER=$(echo "scale=0; $LOAD_PERCENT*$MAX_OUTPUT" | bc)
|
||||||
|
|
||||||
# "round" to integer. just removes decimal and whatevers after.
|
# on void, ups.realpower is available!
|
||||||
POWER="${POWER%.*} W"
|
POWER="$($DATA_CMD | grep ups.realpower: | awk '{print $2}') W"
|
||||||
|
|
||||||
|
# "round" to integer. just removes decimal and whatevers after. not necessary with ups.realpower.
|
||||||
|
#POWER="${POWER%.*} W"
|
||||||
CHARGE="$($DATA_CMD | grep battery.charge: | awk '{print $2}')%"
|
CHARGE="$($DATA_CMD | grep battery.charge: | awk '{print $2}')%"
|
||||||
|
|
||||||
if [ "$CHARGE" = "100%" ]; then
|
if [ "$CHARGE" = "100%" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user