Skip to content

Commit

Permalink
less wide report
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Mar 10, 2026
1 parent b5469b7 commit 14779c3
Showing 1 changed file with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def main():

asg_names = set()
eks_clusters = set()
ec2_groups = Counter({"plain": 0, "asg": 0, "eks": 0})
total_resources = 0
all_envs = set()

Expand All @@ -46,10 +47,17 @@ def main():
res_type = val.get("type", "unknown")

# Sub-type categorizations
if res_type == "eks_node": cat = "eks_ec2"
elif res_type == "asg_member": cat = "asg_ec2"
elif res_type == "rds": cat = "rds"
else: cat = "plain_ec2"
if res_type == "eks_node":
cat = "eks_ec2"
ec2_groups["eks"] += 1
elif res_type == "asg_member":
cat = "asg_ec2"
ec2_groups["asg"] += 1
elif res_type == "rds":
cat = "rds"
else:
cat = "plain_ec2"
ec2_groups["plain"] += 1

# EKS/ASG Metadata
if val.get("eks_cluster") and val.get("eks_cluster") != "N/A":
Expand Down Expand Up @@ -77,13 +85,29 @@ def main():
category_env_totals[cat][env] += 1

sorted_envs = sorted(list(all_envs))
report_width = 130

# EKS Metrics
eks_cluster_count = len(eks_clusters)
eks_node_count = type_totals['eks_ec2']
eks_avg = (eks_node_count / eks_cluster_count) if eks_cluster_count > 0 else 0

# ... [Report 1 & 2 logic preserved from v1.4.0] ...
# --- REPORT 1: BREAKDOWN BY ENVIRONMENT ---
print(f"\nREPORT 1: BREAKDOWN BY ENVIRONMENT")
print("-" * report_width)
for env in sorted_envs:
print(f"\nEnvironment: {env} (Total: {env_totals[env]})")
for sched, count in sorted(env_matrix[env].items()):
pct = (count / env_totals[env]) * 100
print(f" {sched:<30} | {count:<5} | {pct:>5.1f}%")

# --- REPORT 2: BREAKDOWN BY RESOURCE TYPE ---
print(f"\n\nREPORT 2: BREAKDOWN BY RESOURCE TYPE")
print("-" * report_width)
ec2_total = ec2_groups["plain"] + ec2_groups["asg"] + ec2_groups["eks"]
print(f"Resource Group: EC2 (Total: {ec2_total})")
print(f" -> Plain: {ec2_groups['plain']} | ASG: {ec2_groups['asg']} | EKS: {ec2_groups['eks']}")
print(f"Resource Group: RDS (Total: {type_totals['rds']})")

# --- REPORT 3: SCHEDULING MATRIX BY CATEGORY ---
print(f"\n\nREPORT 3: SCHEDULING MATRIX BY CATEGORY")
Expand All @@ -92,7 +116,6 @@ def main():
if cat_total == 0: continue

print(f"\n{cat.upper()} SCHEDULING DETAIL")
# Condensed Header: No percentages in Environment columns
header = f"{'PowerSchedule Tag':<25} | {'Org Total (%%)':<16}"
for env in sorted_envs: header += f" | {env[:10]:<10}"
print("-" * len(header))
Expand All @@ -105,24 +128,21 @@ def main():
for tag in all_tags:
row_total = sum(r3_data[cat][tag].values())
row_pct = (row_total / cat_total) * 100
# Org Total includes count and percentage
line = f"{tag[:25]:<25} | {row_total:<5} ({row_pct:>3.0f}%)"

for env in sorted_envs:
count = r3_data[cat][tag][env]
# Environment columns now only show count
line += f" | {count:<10}"
print(line)

# --- ORG SUMMARY ---
print("\n" + "=" * 120)
print("\n" + "=" * report_width)
print(f"ORGANIZATION SUMMARY")
print(f" Accounts Checked: {len(data)}")
print(f" Total Resources Scanned: {total_resources}")
print(f" Total ASGs Identified: {len(asg_names)}")
print(f" Total EKS Clusters: {eks_cluster_count}")
print(f" Total EKS Nodes: {eks_node_count}")
print(f" Average Nodes/Cluster: {eks_avg:.1f}")
print("=" * 120)
print("=" * report_width)

if __name__ == "__main__": main()

0 comments on commit 14779c3

Please sign in to comment.