feat: output in markdown table
This commit is contained in:
@@ -18,6 +18,11 @@ def main() -> None:
|
||||
cf = boto3.client('cloudfront', region_name='us-east-1')
|
||||
distros = cf.list_distributions()['DistributionList']['Items']
|
||||
dist_ids = [d['Id'] for d in distros if d['Status'] == 'Deployed']
|
||||
print(f"Distributions discovered: {len(dist_ids)}")
|
||||
|
||||
# print markdown table headers
|
||||
print("| DistId | Month | NoRequests | Download |")
|
||||
print("| ------ | ----- | ---------- | -------- |")
|
||||
|
||||
for dist_id in dist_ids:
|
||||
for month_offset in range(-3, 0): # Past 3 months
|
||||
@@ -43,8 +48,8 @@ def main() -> None:
|
||||
reqs_total = reqs_resp['Datapoints'][0]['Sum'] if reqs_resp['Datapoints'] else 0
|
||||
|
||||
# only interested in distro with high traffic (>10G)
|
||||
if bytes_total > 10 * 1024 ** 3:
|
||||
print(f"{dist_id}: {start:%Y-%b} Requests: {reqs_total:,.0f} BytesDownloaded: {humanize.naturalsize(bytes_total)}")
|
||||
# if bytes_total > 10 * 1024 ** 3:
|
||||
print(f"| {dist_id} | {start:%Y-%b} | {reqs_total:,.0f} | {humanize.naturalsize(bytes_total)} |")
|
||||
|
||||
|
||||
# Call main function
|
||||
|
||||
Reference in New Issue
Block a user