Update powerwall.sh

This commit is contained in:
2023-11-01 19:47:51 -05:00
parent fc6f503494
commit be669a135f

View File

@@ -541,8 +541,7 @@ CHECKPOWER(){
if [ "${1}" == "" ] || [ "${1}" == "hosts" ]; then if [ "${1}" == "" ] || [ "${1}" == "hosts" ]; then
for SENSOR in ${PW_SENSOR_ORD[@]}; do for SENSOR in ${PW_SENSOR_ORD[@]}; do
if [ "${PW_HOST_IDRACS[${SENSOR}]}" != "" ] && [[ "${SENSOR}" = *"iDS"* ]]; then if [ "${PW_HOST_IDRACS[${SENSOR}]}" != "" ]; then
echo $SENSOR
GETHOSTPOWER ${PW_HOST_IDRACS[${SENSOR}]} & GETHOSTPOWER ${PW_HOST_IDRACS[${SENSOR}]} &
fi fi
done done
@@ -617,39 +616,6 @@ CHECKPOWER(){
echo echo
fi fi
echo -e "${idsCL[LightBlue]}ESXi Hosts"
DIVIDER . lightBlue 75
if [ "${1}" == "" ] || [ "${1}" == "hosts" ]; then
finalcheck=""
until [ "${finalcheck}" != "" ]; do
for hostfile in ${PW_TMPFOLDER}/*.hostpower; do
if [ -f ${hostfile} ] && [ "${hostfile}" != "${PW_TMPFOLDER}/*.hostpower" ]; then
host=${hostfile%.*}; host=${host##*/}
if [ "${host}" != "*" ] && [ "${host}" != "done" ]; then
watts=$(cat ${hostfile})
if [ "${watts}" == "down" ]; then
hostpower="${idsCL[LightRed]}Host Offline"
elif [ "${watts}" == "0" ]; then
hostpower="${idsCL[Default]}n/a"
else
[[ "${watts}" == *"."* ]] && [[ "${watts}" != *".0"* ]] && watts=`printf "%'.1f\n" ${watts}` || watts=`printf "%'.0f\n" ${watts}`
hostpower="${idsCL[Green]}${watts}'W"
fi
echo -e "${idsCL[LightCyan]}HOST '${PW_iDRACHOST_SHORTNAMES[${host}]}' ${idsCL[Default]}: ${hostpower}${idsCL[Default]}"
mv ${hostfile} ${hostfile}.done
elif [ "${host}" == "done" ]; then
finalcheck=done
rm -f ${PW_TMPFOLDER}/*.hostpower*
fi
fi
done
sleep 0.25
done
fi
######## ########
DIVIDER . yellow 75 DIVIDER . yellow 75
@@ -677,35 +643,39 @@ CHECKPOWER(){
######## ########
# if [ "${1}" == "" ] || [ "${1}" == "hosts" ]; then DIVIDER . yellow 75
# finalcheck="" echo -e "${idsCL[Yellow]}ESXi Host Power Information"
# until [ "${finalcheck}" != "" ]; do DIVIDER . yellow 75
# for hostfile in ${PW_TMPFOLDER}/*.hostpower; do
# if [ -f ${hostfile} ] && [ "${hostfile}" != "${PW_TMPFOLDER}/*.hostpower" ]; then if [ "${1}" == "" ] || [ "${1}" == "hosts" ]; then
# host=${hostfile%.*}; host=${host##*/} finalcheck=""
# if [ "${host}" != "*" ] && [ "${host}" != "done" ]; then until [ "${finalcheck}" != "" ]; do
# watts=$(cat ${hostfile}) for hostfile in ${PW_TMPFOLDER}/*.hostpower; do
# if [ "${watts}" == "down" ]; then if [ -f ${hostfile} ] && [ "${hostfile}" != "${PW_TMPFOLDER}/*.hostpower" ]; then
# hostpower="${idsCL[LightRed]}Host Offline" host=${hostfile%.*}; host=${host##*/}
# elif [ "${watts}" == "0" ]; then if [ "${host}" != "*" ] && [ "${host}" != "done" ]; then
# hostpower="${idsCL[Default]}n/a" watts=$(cat ${hostfile})
# else if [ "${watts}" == "down" ]; then
# [[ "${watts}" == *"."* ]] && [[ "${watts}" != *".0"* ]] && watts=`printf "%'.1f\n" ${watts}` || watts=`printf "%'.0f\n" ${watts}` hostpower="${idsCL[LightRed]}Host Offline"
# hostpower="${idsCL[Green]}${watts}'W" elif [ "${watts}" == "0" ]; then
# fi hostpower="${idsCL[Default]}n/a"
# echo -e "${idsCL[LightCyan]}HOST '${PW_iDRACHOST_SHORTNAMES[${host}]}' ${idsCL[Default]}: ${hostpower}${idsCL[Default]}" else
# mv ${hostfile} ${hostfile}.done [[ "${watts}" == *"."* ]] && [[ "${watts}" != *".0"* ]] && watts=`printf "%'.1f\n" ${watts}` || watts=`printf "%'.0f\n" ${watts}`
# hostpower="${idsCL[Green]}${watts}'W"
# elif [ "${host}" == "done" ]; then fi
# finalcheck=done echo -e "${idsCL[LightCyan]}HOST '${PW_iDRACHOST_SHORTNAMES[${host}]}' ${idsCL[Default]}: ${hostpower}${idsCL[Default]}"
# rm -f ${PW_TMPFOLDER}/*.hostpower* mv ${hostfile} ${hostfile}.done
# fi
# fi elif [ "${host}" == "done" ]; then
# done finalcheck=done
# sleep 0.25 rm -f ${PW_TMPFOLDER}/*.hostpower*
# done fi
# fi fi
done
sleep 0.25
done
fi
end=`date +%s`; runtime=$((end-start)); echo -e "\nruntime: ${runtime}" end=`date +%s`; runtime=$((end-start)); echo -e "\nruntime: ${runtime}"
[ "${action}" != "" ] && echo [ "${action}" != "" ] && echo