I got the script. import meraki import pandas as pd import json # Replace with your Meraki Dashboard API key API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # Organization ID (can be found in the URL when logged in to your dashboard) ORGANIZATION_ID = "XXXXXX" # Function to fetch management interface information for devices in a network def get_management_interface_info(network_id, org_name, network_name): dashboard = meraki.DashboardAPI(API_KEY) devices = dashboard.networks.getNetworkDevices(network_id) management_info = [] for device in devices: try: management_interface = dashboard.devices.getDeviceManagementInterface(serial=device['serial']) device_info = { "Organization": org_name, "Organization ID": ORGANIZATION_ID, "Network": network_name, "Network ID": network_id, "Serial": device['serial'], "Device Name": device['name'], "Active DDNS Hostname": management_interface.get('ddnsHostnames', {}).get('activeDdnsHostname', ''), "DDNS Hostname WAN1": management_interface.get('ddnsHostnames', {}).get('ddnsHostnameWan1', ''), "DDNS Hostname WAN2": management_interface.get('ddnsHostnames', {}).get('ddnsHostnameWan2', ''), "WAN1 Enabled": management_interface.get('wan1', {}).get('wanEnabled', ''), "WAN1 Using Static IP": management_interface.get('wan1', {}).get('usingStaticIp', ''), "WAN1 Static IP": management_interface.get('wan1', {}).get('staticIp', ''), "WAN1 Static Subnet Mask": management_interface.get('wan1', {}).get('staticSubnetMask', ''), "WAN1 Static Gateway IP": management_interface.get('wan1', {}).get('staticGatewayIp', ''), "WAN1 Static DNS": ', '.join(management_interface.get('wan1', {}).get('staticDns', [])), "WAN1 VLAN": management_interface.get('wan1', {}).get('vlan', ''), "WAN2 Enabled": management_interface.get('wan2', {}).get('wanEnabled', ''), "WAN2 Using Static IP": management_interface.get('wan2', {}).get('usingStaticIp', ''), "WAN2 Static IP": management_interface.get('wan2', {}).get('staticIp', ''), "WAN2 Static Subnet Mask": management_interface.get('wan2', {}).get('staticSubnetMask', ''), "WAN2 Static Gateway IP": management_interface.get('wan2', {}).get('staticGatewayIp', ''), "WAN2 Static DNS": ', '.join(management_interface.get('wan2', {}).get('staticDns', [])), "WAN2 VLAN": management_interface.get('wan2', {}).get('vlan', '') } management_info.append(device_info) except meraki.APIError as e: print(f"Error fetching management interface information for device {device['serial']}: {e}") return management_info # Function to fetch management interface information for devices in all networks of an organization def get_organization_management_interface_info(org_id): dashboard = meraki.DashboardAPI(API_KEY) org_name = dashboard.organizations.getOrganization(org_id)['name'] networks = dashboard.organizations.getOrganizationNetworks(org_id) org_management_info = [] for network in networks: network_id = network['id'] network_name = network['name'] management_info = get_management_interface_info(network_id, org_name, network_name) org_management_info.extend(management_info) return org_management_info # Fetch management interface information for devices within the organization org_management_info = get_organization_management_interface_info(ORGANIZATION_ID) # Convert to DataFrame df = pd.DataFrame(org_management_info) # Save to CSV df.to_csv("organization_management_interface_info.csv", index=False) print("Management interface information retrieved and saved to organization_management_interface_info.csv.")
... View more