-
-
Save vinnix/8649ec82eab7c5885176 to your computer and use it in GitHub Desktop.
Revisions
-
kkung revised this gist
Mar 5, 2014 . 2 changed files with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ $ python get_logs.py rds-db-instance-name rds.log aws-access-key aws-secret-key $ ./pgbadger -p '%t:%r:%u@%d:[%p]:' ./rds.log $ open out.html This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,14 +17,17 @@ def get_all_logs(dbinstance_id, output, max_records=None, max_records=max_records): print 'Download %s(%d)' % (log_file.log_filename, int(log_file.size)) try: log = conn.get_log_file(dbinstance_id, log_file.log_filename) try: f.write(log.data) except AttributeError: pass except: print 'Error while download %s' % log_file.log_filename if __name__ == '__main__': get_all_logs(dbinstance_id=sys.argv[1], output=sys.argv[2], aws_access_key_id=sys.argv[3], aws_secret_access_key=sys.argv[4]) -
kkung created this gist
Mar 5, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ $ python get_logs.py rds-db-instance-name rds.log aws-access-key aws-secret-key $ ./pgbadger -p '%t:%r:%u@%d:[%p]:' ./rds.log $ open out.html This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # -*- encoding: utf-8 -*- import sys import boto.rds AWS_REGION = 'ap-northeast-1' def get_all_logs(dbinstance_id, output, max_records=None, aws_access_key_id=None, aws_secret_access_key=None): conn = boto.rds.connect_to_region( AWS_REGION, aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key) with open(output, 'w') as f: for log_file in conn.get_all_logs(dbinstance_id, max_records=max_records): print 'Download %s(%d)' % (log_file.log_filename, int(log_file.size)) log = conn.get_log_file(dbinstance_id, log_file.log_filename) try: f.write(log.data) except AttributeError: pass if __name__ == '__main__': get_all_logs(dbinstance_id=sys.argv[1], output=sys.argv[2], aws_access_key_id=sys.argv[3], aws_secret_access_key=sys.argv[4])