Created
February 17, 2017 17:16
-
-
Save aaroncaito/618e70d7d8eabeb95b1d1fba2e4b8f70 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
servers=$(aws ec2 describe-instances --filters "Name=tag:opsworks:stack,Values=$$<TAG>" --profile AIM --query "Reservations[*].Instances[*].PublicIpAddress") | |
for server in ${servers[@]} | |
do | |
echo "-=# $server #=-" | |
test=`ssh -t -i .ssh/$$<KEY> ubuntu@$server 'if tail /var/log/apache2/error.log | grep Segmentation > /dev/null; then echo -n "1"; else echo -n "0"; fi'` | |
echo $test | |
if [ $test == 1 ] | |
then | |
echo "Segmentation fault found, restarting apache2 on $server" | |
ssh -t -i .ssh/$$<KEY> ubuntu@$server 'sudo service apache2 restart' | |
else | |
echo "No Segmentation fault found on $server" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment