I haven't tested this in action, but something I suppose it's something along the lines of this. Feel free to use it as inspiration. #! /usr/bin/env python3
import meraki
from datetime import datetime
def main():
dashboard = meraki.DashboardAPI()
organization_id = ''
TargetTag = ''
# https://developer.cisco.com/meraki/api-v1/#!get-organization-switch-ports-by-switch
AllSwitchportsBySwitch = dashboard.switch.getOrganizationSwitchPortsBySwitch(
organization_id, total_pages='all'
)
Target = []
for switch in AllSwitchportsBySwitch:
TargetPortIds = []
for port in switch['ports']:
if TargetTag in port['tags']:
TargetPortIds.append(port['portId'])
Target.append(
{
"serial": switch['serial'],
"name": switch['name'],
"portId": TargetPortIds,
}
)
for switch in Target:
# https://developer.cisco.com/meraki/api-v1/#!get-device-switch-ports-statuses
SwitchPorts = dashboard.switch.getDeviceSwitchPortsStatuses(
switch['serial']
)
for port in SwitchPorts:
if port['portId'] in switch['portId']:
print(port['usageInKb'])
if __name__ == "__main__":
StartTime = datetime.now()
main()
print("\nTime to execute:",datetime.now()-StartTime)
... View more