Created
February 29, 2016 03:29
-
-
Save DylanGraham/6c7cb8273ae58aad8736 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
fail() { | |
echo "Failed: $1" | |
exit 1 | |
} | |
NODES=$(ssh mgt "diagnose -n | egrep '^comp[0-1][0-9][0-9].*Idle' | awk {'print \$1'}") | |
WORDS=$(echo ${NODES} | wc -w) | |
let "NUM_OF_NODES = $WORDS - 1" | |
NODES=$(echo $NODES | tr ' ' ',') | |
if [[ $? -ne 0 ]]; then | |
fail "Query mgt for idle nodes" | |
fi | |
echo -e "About to shutdown $NUM_OF_NODES nodes:\n " | |
echo "${NODES}" | |
echo | |
read -p "Are you sure? " -n 1 -r | |
echo | |
if [[ "${REPLY}" =~ ^[Yy]$ ]]; then | |
xdsh ${NODES} 'shutdown -h now' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment