Skip to content

Instantly share code, notes, and snippets.

@aaroncaito
Created February 17, 2017 17:16
Show Gist options
  • Save aaroncaito/618e70d7d8eabeb95b1d1fba2e4b8f70 to your computer and use it in GitHub Desktop.
Save aaroncaito/618e70d7d8eabeb95b1d1fba2e4b8f70 to your computer and use it in GitHub Desktop.
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