Skip to content

Instantly share code, notes, and snippets.

@rifki192
Last active August 4, 2016 02:56
Show Gist options
  • Save rifki192/53dc766ac8077ec7372fd4c61183a158 to your computer and use it in GitHub Desktop.
Save rifki192/53dc766ac8077ec7372fd4c61183a158 to your computer and use it in GitHub Desktop.
#!/bin/bash
instanceID=$1
date=$(date +%Y%m%d)
downloadLog () {
local log=$1
aws rds download-db-log-file-portion \
--output text \
--db-instance-identifier $instanceID \
--log-file-name $log
}
downloadLog slowquery/mysql-slowquery.log > slow-$date.log
for i in $(seq 0 23); do
downloadLog slowquery/mysql-slowquery.log.$i >> slow-$date.log
done
# Runs pt-query-digest from the Percona toolkit, if found
if which pt-query-digest >/dev/null; then
pt-query-digest slow-$date.log > slow-digest-$date.log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment