From 7c3b84e174dc23f9eafe877c8d9f895470f1713a Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sun, 3 Dec 2023 13:11:01 -0600 Subject: [PATCH] Update powerwall.sh --- powerwall.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/powerwall.sh b/powerwall.sh index 9b0df58e..96835777 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -1568,6 +1568,33 @@ HOSTPOWER(){ echo -e "\n" } +PDUCONTROL(){ + while [ $# -gt 0 ]; do + case "$1" in + -port) PORTSEL=${2};; + esac + shift 1 + done + echo + DIVIDER . yellow 75 + echo -e "${idsCL[Yellow]}APC-PDU Power Control" + DIVIDER true yellow 75 + + if [ "${PORT}" == "" ]; then + PORT_DESC=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.2 -O vq 2> /dev/null | sed -e 's/"//g') + IFS=$'\n' + read -rd '' -a PORT_DESC <<<"${PORT_DESC}" + unset IFS + p=1 + for port in "${PORT_DESC[@]}"; do + portpower=$(snmpwalk -t 1 -r 0 -v 1 -c public ${PW_APCPDU_IP} .1.3.6.1.4.1.318.1.1.12.3.3.1.1.4.${p} -O vq 2> /dev/null | sed -e 's/"//g') + [ ${portpower} -eq 1 ] && portpower_disp="${idsCL[Green]}ON" || portpower_disp="${idsCL[LightRed]}OFF" + [ ${p} -lt 10 ] && pp=" ${p}" || pp=${p} + echo -e "${ii}) ${idsCL[LightCyan]}${port} - ${portpower_disp}${idsCL[Default]}" + done + fi +} + LOGROTATE(){ STOPALL_SERVICES lm=`expr $(date +'%m') - 1` @@ -1696,6 +1723,7 @@ fi shutdownhost) SHUTDOWN_SERVER ${2};; shutdown_servers) SHUTDOWN_SERVERS ${2} ${3};; hostpower) HOSTPOWER ${2} ${3};; + pdu) PDUCONTROL ${2} ${3};; get-snapshots) GET_SNAPSHOTS;;