Created
May 14, 2016 19:18
-
-
Save hgmiguel/5fefea815a85af0d5f3fe9be4e314762 to your computer and use it in GitHub Desktop.
script para deterctar errores en los logs de postgres rds
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 | |
INSTANCES="sepa-prod-db-replica-analysis sepa-prod-db-replica1 sepa-prod-db-replica2 sepa-prod-db-replica3 sepa-prod-db-replica4" | |
DATE=$(date +"%Y-%m-%d") | |
FILENAME=$(aws rds describe-db-log-files --db-instance-identifier sepa-prod-db-replica1 --filename-contains $DATE --max-items 1 --output text | awk '{print $3}') | |
#filename="error/postgresql.log.2016-05-14-13" | |
for DB_INSTANCE in $INSTANCES ; do | |
echo $DB_INSTANCE | |
aws rds download-db-log-file-portion --db-instance-identifier $DB_INSTANCE --log-file-name $FILENAME --output text | grep 'ERROR: prepared statement\|connection to client lost' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment