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
for SENSOR in ${PW_SENSOR_ORD[@]}; do
if [ "${PW_HOST_IDRACS[${SENSOR}]}" != "" ] && [[ "${SENSOR}" = *"iDS"* ]]; then
echo $SENSOR
if [ "${PW_HOST_IDRACS[${SENSOR}]}" != "" ]; then
GETHOSTPOWER ${PW_HOST_IDRACS[${SENSOR}]} &
fi
done
@@ -617,39 +616,6 @@ CHECKPOWER(){
echo
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
@@ -677,35 +643,39 @@ CHECKPOWER(){
########
# 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
echo -e "${idsCL[Yellow]}ESXi Host Power Information"
DIVIDER . yellow 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
end=`date +%s`; runtime=$((end-start)); echo -e "\nruntime: ${runtime}"
[ "${action}" != "" ] && echo