Skip to content

Instantly share code, notes, and snippets.

@blemmenes
Created February 4, 2019 19:12
Show Gist options
  • Save blemmenes/5fc4a7bfbaf2a17fc566d14a1d607085 to your computer and use it in GitHub Desktop.
Save blemmenes/5fc4a7bfbaf2a17fc566d14a1d607085 to your computer and use it in GitHub Desktop.
Simple script to test usage gathering
#!/usr/bin/python
import requests
import json
import argparse
from awsauth import S3Auth
def parse_args():
parser = argparse.ArgumentParser(
description='RADOSGW address S3 access_key and secret_key'
)
parser.add_argument(
'-H', '--host',
required=False,
help='Server URL for the RADOSGW api'
)
parser.add_argument(
'-a', '--access_key',
required=False,
help='S3 access key'
)
parser.add_argument(
'-s', '--secret_key',
required=False,
help='S3 secrest key'
)
parser.add_argument(
'-u', '--uid',
required=False,
help='RADOSGW UID'
)
return parser.parse_args()
args = parse_args()
server = args.host
aws_key = args.access_key
secret = args.secret_key
uid = args.uid
url = 'https://%s/admin/bucket?format=json&stats=True' % (server)
response = requests.get(url, auth=S3Auth(aws_key, secret, server),verify=False)
#print response
print json.dumps(response.json(), sort_keys=True, indent=4, separators=(',', ':'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment