Quantcast
Viewing all articles
Browse latest Browse all 4860

Beginners • Re: Connecting UPS to Battery Monitor

With NUT installed, you should be able to retrieve UPS info:

Code:

#!/bin/bashSERVER=w.x.y.zUPSINFO=$(upsc pbx@${SERVER} 2> /dev/null)if [ ${#UPSINFO} -eq 0 ]; then  echo ""  echo "Unable to retrieve UPS information"  echo ""  exit 1fiecho ""MODEL=$(sed -n 's/^ups.model: \(\S\+\)/\1/p' <<< ${UPSINFO})echo "UPS model number: ${MODEL}"echo ""STATUS=$(sed -n 's/^ups.status: \(\S\+\)/\1/p' <<< ${UPSINFO})echo -n "Input power source: "if [ "${STATUS:0:2}" = "OL" ]; then  echo "AC Power Line"else  echo "Internal Battery"fiecho ""RUNTIME=$(sed -n 's/^battery.runtime: \(\S\+\)/\1/p' <<< ${UPSINFO})echo "Estimated run time: $((${RUNTIME} / 60)) minutes"echo ""CHARGE=$(sed -n 's/^battery.charge: \(\S\+\)/\1/p' <<< ${UPSINFO})echo "Battery charged to: ${CHARGE} percent"echo ""

Statistics: Posted by RonR — Sun Jun 09, 2024 11:57 pm



Viewing all articles
Browse latest Browse all 4860

Trending Articles