import json from collections import defaultdict with open('/Users/azcomputerguru/ClaudeTools/.glaztech-sessions.json') as f: data = json.load(f) print(f'Total machines: {len(data)}') # Extract IPs and current sites subnet_info = defaultdict(lambda: {'count': 0, 'machines': [], 'current_sites': set()}) for session in data: ip = session.get('GuestInfo', {}).get('PrivateNetworkAddress', '') name = session.get('Name', 'Unknown') current_site = session.get('CustomProperties', {}).get('CustomProperty2', '') if ip and ip != '': # Extract /24 subnet subnet = '.'.join(ip.split('.')[:3]) + '.0/24' subnet_info[subnet]['count'] += 1 subnet_info[subnet]['machines'].append({'name': name, 'ip': ip}) if current_site: subnet_info[subnet]['current_sites'].add(current_site) # Sort by count descending sorted_subnets = sorted(subnet_info.items(), key=lambda x: x[1]['count'], reverse=True) print('\n=== Subnet Distribution ===') for subnet, info in sorted_subnets: sites_str = ', '.join(sorted(info['current_sites'])) if info['current_sites'] else 'No site tag' print(f'{subnet:20s} {info["count"]:3d} machines Current tags: {sites_str}') # Show first 3 machines as examples for m in info['machines'][:3]: print(f' - {m["name"]:30s} {m["ip"]}') if len(info['machines']) > 3: print(f' ... and {len(info["machines"]) - 3} more')