Device Status Verification Automation via Meraki API Python

mga_monitoramen
Just browsing

Device Status Verification Automation via Meraki API Python

Caros,

 

Estou implementando uma automação usando a biblioteca Meraki Python e gostaria de receber orientação sobre como otimizar um processo que atualmente realizo manualmente por meio do painel do Meraki.

 

O processo manual envolve as seguintes etapas:

 

  • Acess the Meraki Dashboard
  • Navigate to Network and then click on View all networks.
  • In the network view, locate, the Devices column and search for the specific name of the location or device.
  • Check the status of each device through the status circles that appear next to the model.

 

Minha dúvida é como posso automatizar esse processo usando a biblioteca Meraki Python.

Especificamente, gostaria de saber como acessar programaticamente essas informações (nomes de dispositivos e seus status) sem navegar manualmente, pelo Painel.

 

Agradecemos antecipadamente qualquer ajuda ou orientação sobre como automatizar esse processo de forma eficiente.

 

Atenciosamente

mga_monitoramento

 

 

5 Replies 5
sungod
Kind of a big deal
Kind of a big deal
mga_monitoramen
Just browsing

Thank you so much for your help and for pointing me to the getOrganizationDevicesAvailabilities endpoint!

I’ve studied its documentation and I can see that it’s an excellent tool for analyzing uptime and downtime history, which will definitely be very useful to me in the future when I need to create performance reports.

For my immediate need, which is to check the device status in real-time (the exact moment a ticket is closed), the getOrganizationDeviceStatuses endpoint ended up being a bit more straightforward.

In the end, I found that my main challenge was actually a permission issue with my API key, which wasn’t able to list the devices through any of the methods.

Anyway, your help was crucial in helping me better understand the different possibilities with the API. Thanks again!

 

sungod
Kind of a big deal
Kind of a big deal

Be aware that the statuses endpoint is deprecated, it still works at the moment, but could be removed.

 

The availabilities endpoint is the replacement and will be the best to use.

 

 

Deprecation is explained here... https://developer.cisco.com/meraki/api-v1/deprecation/#deprecated-operations

 

...and the statuses endpoint advisory is here... https://developer.cisco.com/meraki/api-v1/deprecated-operations/#2024-may

 

sungod
Kind of a big deal
Kind of a big deal

Leaving out error handling etc., the core elements to take a 'snapshot' of current status for all devices are in the code snippet below (I use aio in most of my scripts, and I've extracted this direct from one of those, but for this simple purpose you could rewrite without aio).

 

The availabilities endpoint doesn't return as rich a response, but if you also get the network and device details for the organization, you can then look up things like network names, device models etc.

 

    async with meraki.aio.AsyncDashboardAPI(
        api_key=API_KEY,
        base_url='https://api.meraki.com/api/v1/',
        print_console=False,
        output_log=False,
        suppress_logging=True,
        wait_on_rate_limit=True,
        maximum_retries=10

    ) as aiomeraki:

        # get the list of networks and devices so that you can look up extra info relating to the status responses
        networks = await aiomeraki.organizations.getOrganizationNetworks(ORG_ID, perPage=1000, total_pages="all")

        devices = await aiomeraki.organizations.getOrganizationDevices(ORG_ID, perPage=1000, total_pages="all")

        statuses = await aiomeraki.organizations.getOrganizationDevicesAvailabilities(ORG_ID, perPage=1000, total_pages="all")

 

mga_monitoramen
Just browsing

Hey! I used exactly the endpoint you provided, tested it, understood how it works, and it performed perfectly for what I needed. While running a test script to list the organizations in the dashboard, I analyzed it and noticed there were two with the same name but different IDs: one was empty, and the other contained the networks and devices. I greatly appreciate your help, may God bless you!

Get notified when there are additional replies to this discussion.