diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index d8f868b3..35932453 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -29,14 +29,16 @@ CHECKTEMP(){ while [ $# -gt 0 ]; do case "$1" in -a|-avg) avgdays=${2};; - -S|-sensors) temptype="sensors";; - -e|-esxi) temptype="esxi";; - -f|-fans) temptype="fans";; + -S|-sensors) TTYPE="sensors";; + -o|-offsite) STYPE=offsite;; + -m|-mainsite) STYPE=mainsite;; + -e|-esxi) TTYPE="esxi";; + -f|-fans) TTYPE="fans";; -s|-search) search=${2};; esac shift 1 done - if [ "${temptype}" != "sensors" ]; then + if [ "${TTYPE}" != "sensors" ]; then for ESXIHOST in "${PW_ALLHOSTS[@]}"; do if [ ! -f ${PW_TMPFOLDER}/${PW_ESXI_HOST_NAMES[${ESXIHOST}]}.down ] && ([ "${search}" == "" ] || [[ "${PW_ESXI_HOST_NAMES[${ESXIHOST}],,}" = *"${search,,}"* ]]); then GET_HOST_FANSPEED ${ESXIHOST} ${cdt} & @@ -63,7 +65,7 @@ CHECKTEMP(){ avgdays=noavg fi - if [ "${temptype}" != "esxi" ]; then + if [ "${TTYPE}" != "esxi" ]; then DIVIDER . yellow ${PRI_WIDTH} if [ "${avgdays}" != "noavg" ]; then echo -e "${idsCL[LightYellow]}SENSOR TEMPERATURE(S) Current / ${idsCL[LightYellow]}${avgdays_disp}AVG ${idsCL[Yellow]}warning${idsCL[Default]} / ${idsCL[LightRed]}critical${idsCL[Default]}" @@ -72,7 +74,7 @@ CHECKTEMP(){ fi DIVIDER . yellow ${PRI_WIDTH} for SENSOR in ${PW_SENSOR_ORD[@]}; do - if ([ "${search}" == "" ] || [[ "${SENSOR,,}" = *"${search,,}"* ]]) && [ "${PW_SENSOR_TYPE[${SENSOR}]}" != "esxi" ] && ([ "${temptype}" != "fans" ] || ([ "${temptype}" == "fans" ] && [[ "${SENSOR}" = *"Room"* ]])); then + if [ "${PW_SENSOR_TYPE[${SENSOR}]}" != "esxi" ] && ([ "${search}" == "" ] || [[ "${SENSOR,,}" = *"${search,,}"* ]]) && ([ "${STYPE}" = "" ] || ([ "${STYPE}" = "mainsite" ] && [ "${PW_REMOTE_SENSORS[${SENSOR}]}" != "" ] && ([ "${PW_REMOTE_SENSORS[${SENSOR}]}" = "127.0.0.1" ] || [[ "${PW_REMOTE_SENSORS[${SENSOR}]}" = *"10.10."* ]])) || ([ "${STYPE}" = "offsite" ] && [ "${PW_REMOTE_SENSORS[${SENSOR}]}" != "" ] && [[ "${PW_REMOTE_SENSORS[${SENSOR}]}" = *"10.2.1."* ]])) && ([ "${TTYPE}" != "fans" ] || ([ "${TTYPE}" == "fans" ] && [[ "${SENSOR}" = *"Room"* ]])); then [ "${last_sensor%%-*}" == "${SENSOR%%-*}" ] && [ "${last_sensor}" != "Offsite-ServerRoom" ] && echo -en "\033[1A" c=0; spc=''; spc1=`expr ${cw} - ${#SENSOR}`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then @@ -103,7 +105,7 @@ CHECKTEMP(){ DIVIDER . yellow ${PRI_WIDTH} fi - if [ "${temptype}" != "sensors" ]; then + if [ "${TTYPE}" != "sensors" ]; then DIVIDER . yellow ${PRI_WIDTH} if [ "${avgdays}" != "noavg" ]; then echo -e "${idsCL[LightYellow]}ESXI HOST TEMPERATURE(S) Current / ${idsCL[LightYellow]}${avgdays_disp}AVG ${idsCL[Yellow]}warning${idsCL[Default]} / ${idsCL[LightRed]}critical${idsCL[Default]}" @@ -117,7 +119,7 @@ CHECKTEMP(){ vHOSTIP=${PW_HOST_ADDRESSES[${SENSOR}]} vHOSTNAME=${PW_ESXI_HOST_NAMES[${vHOSTiDRACIP}]} - ([ "${temptype}" == "fans" ] && [ "${SENSOR}" == "iDS-vMS-Host6" ]) && echo -e "${idsCL[LightYellow]}${SENSOR} PSU is not compatible, Fans are instead synced with 'iDS-vMS-Host7'${idsCL[Default]}" + ([ "${TTYPE}" == "fans" ] && [ "${SENSOR}" == "iDS-vMS-Host6" ]) && echo -e "${idsCL[LightYellow]}${SENSOR} PSU is not compatible, Fans are instead synced with 'iDS-vMS-Host7'${idsCL[Default]}" echo -en "\r\033[K${idsCL[White]}${idsST[Bold]}${SENSOR} Host Sensors ${idsST[Reset]}${idsCL[White]}[${vHOSTiDRACIP}]" if [ ! -f ${PW_TMPFOLDER}/${SENSOR}.down ]; then if [ "${avgdays}" != "noavg" ]; then @@ -147,7 +149,7 @@ CHECKTEMP(){ else echo -e "${idsCL[Default]}" fi - # if [ "${temptype}" != "fans" ]; then + # if [ "${TTYPE}" != "fans" ]; then DIVIDER . lightCyan ${PRI_WIDTH} echo -en "${idsCL[Yellow]}Pulling data for '${SENSOR}' ... " @@ -161,7 +163,7 @@ CHECKTEMP(){ if [ ${#vHOST_TEMPNAMES[@]} -gt 1 ]; then t=1 for sensorname in "${vHOST_TEMPNAMES[@]}"; do - if [ "${temptype}" != "fans" ] || ([ "${temptype}" == "fans" ] && [[ "${sensorname}" = *"Exhaust"* ]]); then + if [ "${TTYPE}" != "fans" ] || ([ "${TTYPE}" == "fans" ] && [[ "${sensorname}" = *"Exhaust"* ]]); then temp_c=$(snmpwalk -v 1 -c public -t 2 ${vHOSTiDRACIP} .1.3.6.1.4.1.674.10892.5.4.700.20.1.6.1.${t} -O vq | sed -e 's/"//g') temp_c=`echo "scale=1; ${temp_c}/10" | bc` temp_warn=$(snmpwalk -v 1 -c public -t 2 ${vHOSTiDRACIP} .1.3.6.1.4.1.674.10892.5.4.700.20.1.11.1.${t} -O vq | sed -e 's/"//g') @@ -170,10 +172,10 @@ CHECKTEMP(){ temp_crit=`echo "scale=1; ${temp_crit}/10" | bc` c=0; spc=''; spc1=`expr ${cw} - ${#sensorname} - 1`; until [ ${c} = ${spc1} ]; do spc="${spc} "; c=`expr ${c} + 1`; done [ "${avgdays}" != "noavg" ] && echo -en "${idsCL[LightCyan]} ${sensorname}${spc}${idsCL[Default]}: ${idsCL[Yellow]}Calculating ${avgdays_disp} average ... " - reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit} ${sensorname// /_} ${avgdays} ${temptype}) + reading=$(CHECKTEMPSENSOR ${SENSOR} ${temp_c} ${temp_warn} ${temp_crit} ${sensorname// /_} ${avgdays} ${TTYPE}) [ "${avgdays}" != "noavg" ] && echo -en "\r\033[K" echo -e "${idsCL[LightCyan]} ${sensorname}${spc}${idsCL[Default]}: ${reading}" - if [ "${temptype}" == "fans" ]; then + if [ "${TTYPE}" == "fans" ]; then if [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.gl ]; then FSC="${idsCL[LightGreen]}" elif [ -f ${PW_TMPFOLDER}/.lastfancheck/${cSENSOR}.set ]; then @@ -202,7 +204,7 @@ CHECKTEMP(){ # fi fi # fi - ([ "${temptype}" != "fans" ] || ([ "${temptype}" == "fans" ] && [ "${SENSOR}" != "iDS-vMS-Host6" ])) && echo + ([ "${TTYPE}" != "fans" ] || ([ "${TTYPE}" == "fans" ] && [ "${SENSOR}" != "iDS-vMS-Host6" ])) && echo fi done fi