How do I check the Internet availability of all devices?

Solved
LostInTranslate
Conversationalist

How do I check the Internet availability of all devices?

Hi there,


I'm trying to get stats from our Ipad devices about the time the devices are connected to the internet.


I am using the meraki python package. So far I have not been able to find a way to get this info using the least amount of API calls possible.


I've got an empty array with the following calls: getOrganizationDevicesAvailabilities, getOrganizationDevicesAvailabilitiesChangeHistory or getOrganizationDevicesStatuses (without any optionnal params).


I've got some results targeting a specific device with getNetworkSmDeviceConnectivity, but the info doesn't seem to correlate with the "Online Status" stat displayed on the device page.


Any tips?

Thanks.

1 Accepted Solution
David_Jirku
Meraki Employee
Meraki Employee
28 Replies 28
MartinS
Building a reputation

Do you want to do this as a historical availability or do you want something more real time? If you're just interested in historical getOrganizationDevicesAvailabilitiesChangeHistory is your friend, but note that anything down for the whole period or up for the whole period won't be included. If you need a real time view, ideally combined an occasional call to getOrganizationDevicesAvailabilities to get the whole estate, with then changes caught from getOrganizationDevicesAvailabilitiesChangeHistory

 

If all of this sounds too much like hard work, the Meraki Ecosystem partners have your back - Cisco Meraki Marketplace | Cisco Meraki

---
COO
Highlight - Service Observability Platform
www.highlight.net
LostInTranslate
Conversationalist

Hi there,

It does not matter if it is historical or real time values, I want to be able to retrieve data about internet availability from (for example) the previous month, or to build data for the next month.


My main problem is that the two methods you cite return an empty array. I just created my API key yesterday, but I dont think I need to wait before getting results?


Also, /organizations/{organizationId}/devices/statuses/overview returns 0 for all statuses, confirming that I cannot reach devices from my org for a reason I do not understand.


Regards.

AxL1971
Building a reputation

I have done a similair where I collect wireless devices connected to the access points, this data is used for how many people are in the office. The data is written to a back end database and can be visually displayed using Power BI reports. I also created a very simple website to see how many devices are connected to a given access point in an office. This is so other people can view this data as thus do not need access to the dashboard

 

This is the URL I call to collect the data - I pass the network ID

 

https://api.meraki.com/api/v1/networks/<network ID>/clients?timespan=300&recentDeviceConnections[]=Wireless&statuses[]=Online&perPage=2000

LostInTranslate
Conversationalist

Thanks for your answer,

 

I've tried but get a 400 error

meraki: INFO , GET https://api.meraki.com/api/v1/networks/<network_id>/clients
meraki: ERROR, networks, getNetworkClients - 400 Bad Request, {'errors': ['Invalid device type']}

 

The devices are all iPad Pro 11 (2nd Gen.)

 

AxL1971
Building a reputation

what programming language are you using, are you passing your API call and also your network ID 

LostInTranslate
Conversationalist

I'm using meraki python package, copying snippet code from the API doc, and i know that the meraki key is ok, and that the network id is also ok (get it from an API call dashboard.organizations.getOrganizationNetworks(ORG_ID, total_pages='all') )

 

    dashboard = meraki.DashboardAPI(MERAKY_KEY)
    response = dashboard.networks.getNetworkClients(
        network_id
    )
 
 
LostInTranslate
Conversationalist

Now https://api.meraki.com/api/v1/networks/<network_id>/clients returns an empty array

 

https://api.meraki.com/api/v1/networks/<network_id>/policies/byClient returns :

ERROR > networks, getNetworkPoliciesByClient - 400 Bad Request, {'errors': ['<network name> - <network id> cannot have any clients']}

AxL1971
Building a reputation

for 

 

https://api.meraki.com/api/v1/networks/<network_id>/clients 

 

you need to pass additional parameters, as an example

 

 

more info here

 

https://developer.cisco.com/meraki/api-v1/get-network-clients/

LostInTranslate
Conversationalist

Seems that i have a problem of device type (?)

 

url = f"https://api.meraki.com/api/v1/networks/{NETWORK_ID}/clients?timespan=10000&statuses[]=Online"
headers = {"Authorization": f"Bearer {MERAKI_KEY}", "Accept": "application/json"}
resp = requests.request("GET", url, headers=headers, data=None)
 
Return a 400 error "Invalid device type"
LostInTranslate
Conversationalist

If i try https://api.meraki.com/api/v1/devices/<SERIAL>/clients?timespan=10000 with a serial copied from the device page of one of the device, i get a 404.

 

I'm lost.

AxL1971
Building a reputation

I would also pass recentDeviceConnections[]=Wireless to get all wireless devices

 

 

LostInTranslate
Conversationalist

Still get a 400 bad device type with this argument

AxL1971
Building a reputation

can you paste the full URL

LostInTranslate
Conversationalist

Here is the url :

https://api.meraki.com/api/v1/networks/{NETWORK_ID}/clients?timespan=3000&recentDeviceConnections[]=Wireless&perPage=2000 

AxL1971
Building a reputation

can you try this

 

https://api.meraki.com/api/v1/networks/{NETWORK_ID}/clients?timespan=3000&recentDeviceConnections[]=Wireless&statuses[]=Online&perPage=2000 

LostInTranslate
Conversationalist

I've got the same 400 / invalid device type

AxL1971
Building a reputation

lets see if we can get the data using something as simple as vbscript 

if you are on a Windows machine, copy the following to a text file and rename is to what ever you want, test.vbs as an example. then run the vbscript via command line

 

Obviosuly change the sNet and xAPIKey variables

 

cscript <name of vbs file>

 

'start of code

sUrl = "https://api.meraki.com/api/v1/networks/" & sNet & "/clients?timespan=300&recentDeviceConnections[]=Wireless&statuses[]=Online&perPage=2000"
set http=createObject("Microsoft.XMLHTTP")
http.open "GET",sUrl,false
http.setRequestHeader "Content-Type","application/json"
http.setRequestHeader "Accept","application/json"
http.setRequestHeader "X-Cisco-Meraki-API-Key",xAPIKey
http.send
responseText=http.responseText

wscript.echo http.Status

If http.Status = 200 Then
  wscript.echo responseText

else

  wscript.echo "Error With The API Call " & http.status

end if

'end of code

LostInTranslate
Conversationalist

The problem is from the server, not my request, but i dont get why.

I got the same problem using the "purest" form of querying, curl :

 

 

 

curl -L --request GET --url 'https://api.meraki.com/api/v1/networks/<nertwork_id>/clients?timespan=300&recentDeviceConnections[]=Wireless&statuses[]=Online&perPage=2000' --header 'Authorization: Bearer <api_key>' --header 'Accept: application/json'


{"errors":["Invalid device type"]}

 

 

 

AxL1971
Building a reputation

I assume in the CURL code you are passing your network ID

LostInTranslate
Conversationalist

I pasted the network id and API key values directly into the curl statement, but redacted them for posting here.

David_Jirku
Meraki Employee
Meraki Employee

Does your network ID start like 'L_6......' ? 

 

For {{baseUrl}}/organizations/:organizationId/networks what is the output if you can share (feel free to hide specific values)

LostInTranslate
Conversationalist

Hi David,

 

I have several network listed, all starting with N_6

 

Here is a redacted result of the API call /organizations/:organizationId/networks  for the network i'm interested on (containing the ipads)

 

{
            "id": "N_6XXXXXXXXXXXXX",
            "organizationId": "6XXXXXXXXXXXXX",
            "name": "XXXXXXXX-IPAD",
            "productTypes": [
                "systemsManager"
            ],
            "timeZone": "Europe/London",
            "tags": [],
            "enrollmentString": null,
            "url": "https://n184.meraki.com/XXXXXXXXx-IP/n/XXXXXX/manage/clients",
            "notes": "",
            "isBoundToConfigTemplate": false,
            "isVirtual": false
        }

 

David_Jirku
Meraki Employee
Meraki Employee

This network doesn't have any Meraki network devices (MX, MR) which is what this endpoint uses to collect information about clients. This is a systemsManager-only network, so this isn't the correct tool to use. 

 

You can see SM specific API endpoints here https://developer.cisco.com/meraki/api-v1/create-organization-sm-admins-role/ under the tree.

 

Do you have Meraki network devices that these devices traverse? Call on that network instead.

David_Jirku
Meraki Employee
Meraki Employee

LostInTranslate
Conversationalist

Thanks David,

It seems that /sm/ apis yields results, thank you for the solution.

 

But now i'm not sure about the results of get-network-sm-device-connectivity/

 

Here is the device i'm targeting (i've pasted multiple screen shot to get info popups)

LostInTranslate_2-1732031254623.png

 

LostInTranslate_1-1732031234455.png

 

LostInTranslate_0-1732031188292.png

 

The result of the api call :

LostInTranslate_3-1732031386435.png

It seems that the info is quite sparse, and does not permit to deduce the same connectivity as the green timeline of the device page ?

 

 

David_Jirku
Meraki Employee
Meraki Employee

Not sure, but if you feel like the API is returning invalid data, please open a case with Meraki support to troubleshoot.

LostInTranslate
Conversationalist

Thanks i will study the values and open a case if needed.

AxL1971
Building a reputation

the sample vbscript I posted, have you tried that (assuming you are on a Windows OS)

Get notified when there are additional replies to this discussion.