Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fabiojaniolima
Last active October 19, 2019 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiojaniolima/b5f6fddd061555167b7f55046201ea8f to your computer and use it in GitHub Desktop.
Save fabiojaniolima/b5f6fddd061555167b7f55046201ea8f to your computer and use it in GitHub Desktop.
Verifica se determinado ponto de montagem está presente em hosts remotos
#!/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