diff --git a/powerwall.sh b/powerwall.sh index 2c09c3af..fdb1cd2a 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -24,17 +24,18 @@ CHECKTEMP(){ for SENSOR in ${!PW_SENSOR_ID[@]}; do if [ "${1}" == "" ] || [[ "${SENSOR}" = *"${1}"* ]]; then - echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..." if [ "${PW_SENSOR_TYPE[${SENSOR}]}" == "esxi" ]; then vHOSTIP=${PW_ESXI_MON_HOSTS[${SENSOR}]} vHOSTNAME=${PW_ESXI_HOST_NAMES[${vHOSTIP}]} + echo -e "\r\033[K${idsCL[Cyan]}${SENSOR} Host Sensors -${spc}${idsCL[Default]}" + echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..." + if [ "$(CHECK_HOST ${vHOSTIP})" != "false" ]; then vHOSTDATA=$(ssh root@${PW_RACADM_ACCESS} racadm -r ${vHOSTIP} -u ${PW_ESXI_USER} -p "'${PW_ESXI_PASS}'" getsensorinfo | grep " Temp" 2>&1) if (( $(grep -c . <<<"${vHOSTDATA}") > 1 )); then IFS=$'\n' read -rd '' -a vHOSTDATA <<<"${vHOSTDATA}"; unset IFS - echo -e "\r\033[K${idsCL[Cyan]}- ${SENSOR} Host Sensors -${spc}${idsCL[Default]}" - + echo -e "\r\033[K" for sensordata in "${vHOSTDATA[@]}"; do vSENSOR=$(echo ${sensordata} | cut -d'T' -f1 | xargs) temp_c=$(echo ${sensordata} | cut -d'p' -f2 | awk '/ / {print $2}' | sed -e 's/C//g'); temp_c=${temp_c/ /} @@ -42,8 +43,8 @@ CHECKTEMP(){ temp_crit=$(echo ${sensordata} | cut -d'p' -f2 | awk '/ / {print $4}' | sed -e 's/C//g'); temp_crit=${temp_crit/ /} reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit}) - c=0; spc=''; spc1=`expr ${cw} - ${#vSENSOR} - 2`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done - echo -e "${idsCL[LightCyan]} ${vSENSOR}${spc}${idsCL[Default]}: ${reading}" + c=0; spc=''; spc1=`expr ${cw} - ${#vSENSOR} - 1`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -e "${idsCL[LightCyan]} ${vSENSOR}${spc}${idsCL[Default]}: ${reading}" done @@ -60,6 +61,7 @@ CHECKTEMP(){ fi else + echo -en "${idsCL[Yellow]}Pulling data and calculating averages for '${SENSOR}' ..." reading=$(CHECKTEMPSENSOR ${SENSOR}) c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -e "\r\033[K${idsCL[LightCyan]}${SENSOR}${spc}${idsCL[Default]}: ${reading}"