Last active
October 19, 2019 20:42
-
-
Save fabiojaniolima/b5f6fddd061555167b7f55046201ea8f to your computer and use it in GitHub Desktop.
Verifica se determinado ponto de montagem está presente em hosts remotos
This file contains hidden or 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 | |
FILESYSTEM="/storage" | |
SERVERS=(host01 host02 host03) | |
for i in "${!SERVERS[@]}" | |
do | |
STATUS=$(ssh -q -oStrictHostKeyChecking=no ${SERVERS[i]} "if mountpoint -q ${FILESYSTEM}; then echo "OK"; else echo "NOK"; fi") | |
if [[ $? != 0 ]]; | |
then | |
RESULT+="${SERVERS[i]}: SSH ERROR"; | |
elif [[ "$STATUS" == "OK" ]]; | |
then | |
RESULT+="${SERVERS[i]}: OK"; | |
elif [[ "$STATUS" == "NOK" ]]; | |
then | |
RESULT+="*${SERVERS[i]}: NOK*"; | |
else | |
RESULT+="${SERVERS[i]}: UNDETERMINED ERROR"; | |
fi | |
RESULT+="\n" | |
done | |
if [[ $RESULT == *"NOK"* || $RESULT == *"ERROR"* ]]; | |
then | |
echo "**Status do FileSystem ${FILESYSTEM}:** " | |
echo -e $RESULT | sed '/^$/d' | sort | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment