GUIDE - how to display current wattage with shell from UPS

nankeen

Cadet
Joined
Jan 20, 2024
Messages
2
P.s it would be great to have this as a built In feature

Run the following command in shell AFTER the ups is linked

load_percentage=$(upsc ups@localhost | grep "ups.load" | awk '{print $2}')
nominal_real_power=$(upsc ups@localhost | grep "ups.realpower.nominal" | awk '{print $2}')

current_wattage=$(awk -v load_pct="$load_percentage" -v power="$nominal_real_power" 'BEGIN {printf "%.2f", (load_pct / 100) * power}')

echo "Current Load Percentage: $load_percentage%"
echo "Nominal Real Power: $nominal_real_power watts"
echo "Current Wattage: $current_wattage watts"
 
Top