diff --git a/defaults.inc b/defaults.inc index 3030eaef..d6cd820f 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='2.5.288-02102024' +VERS='2.5.289-02102024' noheader=' update service dailytemp confsync -r -report ' diff --git a/powerwall.sh b/powerwall.sh index 82942cf2..3944ed83 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -723,6 +723,100 @@ CONFSYNC(){ rsync -az --timeout=3 ${PW_FOLDER}/settings.conf root@10.10.10.50:/opt/idssys/nodemgmt/conf/powerwall.settings.conf & >/dev/null 2>&1 } +DOWNLIST(){ + declare -i cw; declare -i spc1; declare -i c + DOWN_LIST=`find ${PW_TMPFOLDER}/ -iname "*.down"` + IFS=$'\n' + read -rd '' -a DOWN_LIST <<<"${DOWN_LIST}" + unset IFS + if [ "${1}" == "report" ]; then + unset idsCL idsBG idsST + idsCL=('') + idsBG=('') + idsST=('') + DOWNLIST=() + for dli in "${DOWN_LIST[@]}"; do + [ ! -f ${dli//.down/.disable} ] && DOWNLIST+=(${dli}) + done + else + DOWNLIST=(${DOWN_LIST[@]}) + fi + + echo + + if [ "${DOWNLIST}" != "" ]; then + [ "${1}" == "report" ] && dlen=100 || dlen=110 + echo -e "${idsCL[LightGreen]}Current List of Items Down...${idsCL[Default]}" + DIVIDER false yellow ${dlen} + if [ "${1}" == "report" ]; then + echo -e "${idsCL[Yellow]}[Type] [Host/Service/Docker Name] [Host] [Down_Time]${idsCL[Default]}" + else + echo -e "${idsCL[Yellow]} [Type] [Host/Service/Docker Name] [Host] [Down_Time] [Notifications]${idsCL[Default]}" + fi + DIVIDER false yellow ${dlen} + + until [ "${choice^^}" = "E" ]; do + cw=35; cw1=11; cw2=20; is=1; + for downitem in ${DOWNLIST[@]}; do + ditem=${downitem##*/}; ditem=${ditem//.down} + if [ "${PW_SENSOR_TYPE[${ditem}]}" == "esxi" ]; then + itemname=${ditem} + itemtype=HOST + elif [ "${PW_SENSOR_TYPE[${ditem}]}" == "system" ] || [ "${PW_SENSOR_TYPE[${ditem}]}" == "cpu" ] || [ "${PW_SENSOR_TYPE[${ditem}]}" == "remotesystem" ]; then + itemname=${ditem} + itemtype=DEVICE + else + itemname=${ditem} + itemtype=SENSOR + fi + + if [ -f ${PW_TMPFOLDER}/${ditem}-error.reading ]; then + toterrtime=$(expr $(date +%s) - $(stat -c %Y ${PW_TMPFOLDER}/${ditem}-error.reading)) + else + toterrtime=$(expr $(date +%s) - $(stat -c %Y ${PW_TMPFOLDER}/${ditem}.down)) + fi + + c=0; spc=''; spc1=`expr ${cw} - ${#itemname}`; until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + c=0; spca=''; spc1=`expr ${cw1} - ${#itemtype}`; until [ $c = ${spc1} ]; do spca="${spca} "; c=`expr $c + 1`; done + c=0; spc2=''; spc1=`expr ${cw2} - ${#host}`; until [ $c = ${spc1} ]; do spc2="${spc2} "; c=`expr $c + 1`; done + time=$(SHOW_TIME ${toterrtime}) + if [ "${1}" == "report" ]; then + echo -e "${idsCL[LightRed]}${itemtype}${spca}${itemname}${spc}${host}${spc2}${time}${idsCL[Default]}" + else + if [ "${choice^^}" == "A" ] || ([[ ${choice} == ?(-)+([0-9]) ]] && [ ${choice} -gt 0 ] 2>/dev/null && [ ${is} -eq ${choice} ]); then + [ ! -f ${PW_TMPFOLDER}/${ditem}.disable ] && touch ${PW_TMPFOLDER}/${ditem}.disable || rm -f ${PW_TMPFOLDER}/${ditem}.disable + fi + + [ ${is} -lt 10 ] && ignsel=" ${is}) " || ignsel="${is}) " + [ -f ${PW_TMPFOLDER}/${ditem}.disable ] && dstatus="OFF" || dstatus="${idsCL[Green]}ON" + c=0; spc3=''; until [ $c = `expr 26 - ${#time}` ]; do spc3="${spc3} "; ((c++)); done + echo -e "\033[K${idsCL[LightRed]}${idsST[Bold]}${ignsel}${idsST[Reset]}${idsCL[LightRed]}${itemtype}${spca}${itemname}${spc}${host}${spc2}${time}${spc3}${dstatus}${idsCL[Default]}" + fi + + DIVIDER false darkGray ${dlen} + ((is++)) + done + + if [ "${1}" != "report" ]; then + echo -en "\n\033[K${idsCL[LightCyan]}Enter # to change notifications [${idsCL[Default]}Change (${idsCL[LightYellow]}A${idsCL[Default]})ll, ${idsCL[Default]}(${idsCL[LightYellow]}E${idsCL[Default]})xit${idsCL[LightCyan]}] : ${idsCL[Default]}" + read choice + else + choice=E + fi + [ "${choice^^}" == "E" ] && break + + echo -e "\033[$(echo "scale=1; (${#DOWNLIST[@]}*2)+3" | bc)A" + for (( c=1; c<$(echo "scale=1; (${#DOWNLIST[@]}*2)+3" | bc); c++ )); do echo -e "\033[K"; done + echo -e "\033[$(echo "scale=1; (${#DOWNLIST[@]}*2)+3" | bc)A" + + done + echo + + fi + echo +} + + TEST(){ start=`date +%s` temptotal=0 @@ -935,7 +1029,7 @@ fi tempdiff) SERVERROOM_TEMP_DIFFERENCE ${2} ${3} ${4};; average) AVERAGETEMP ${2} ${3} ${4};; - conserve) CONSERVE_POWER;; + dl|downlist) DOWNLIST;; oldhelp) echo -e "${idsCL[White]} Usage: ${idsCL[LightYellow]}[powerwall or pw]${idsCL[LightCyan]} {option}"