Number of Users/Clients per Band per SSID and per AP via Python Module

peagacebe
Here to help

Number of Users/Clients per Band per SSID and per AP via Python Module

Is it possible to get the number of clients/users on each channel/band (2.4 Ghz, 5 Ghz and so on) by SSID and also by AP via API in a Python Module? For example, I could get how many clients there are on that channel, for that SSID and the same for the AP.

7 Replies 7
alemabrahao
Kind of a big deal
Kind of a big deal

Yes it is, but it will be necessary to create some kind of filter in the script.

 

Use the getNetworkClients endpoint to retrieve clients connected to a specific network.
Use the getDeviceClients endpoint to get clients connected to a specific AP.
Use the getDeviceWirelessConnectionStats endpoint to get connection statistics for a device, which includes information about the band (2.4 GHz, 5 GHz).

 

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

I am not a Cisco Meraki employee. My suggestions are based on documentation of Meraki best practices and day-to-day experience.

Please, if this post was useful, leave your kudos and mark it as solved.
peagacebe
Here to help

In this GetDeviceWirelessConnectionStats endpoint, it doesn't give me the exact bandwidth of each client. I'm having to get the information from the endpoint's filter, which can be filtered by band (2.4 GHz, 5 GHz). However, many clients don't come back when I test the 3 filters, 2.4, 5 and 6 Ghz. Do you know an endpoint or something I'm doing wrong?

Messy
Getting noticed

do you just need a count of the number of devices? or do you need to know details of each individual client?

GetDeviceWirelessConnectionStats seems like the only way to get a count of devices per band. If you are not seeing the number you expect, have you set the timespan correctly?

For client specific info, this gives good details per client, but not the band (make sure you script handles multi-page responses correctly)
/networks/{networkId}/clients

[
{
"id": "k74272e",
"mac": "22:33:44:55:66:77",
"ip": "1.2.3.4",
"ip6": "2001:db8:3c4d:15::1",
"description": "Miles's phone",
"firstSeen": 1518365681,
"lastSeen": 1526087474,
"manufacturer": "Apple",
"os": "iOS",
"user": "milesmeraki",
"vlan": "100",
"ssid": "My SSID",
"switchport": "My switch port",
"wirelessCapabilities": "802.11b - 2.4 GHz",
"smInstalled": true,
"recentDeviceMac": "22:33:44:55:66:77",
"status": "Online",
"usage": { "sent": 138, "recv": 61 },
"namedVlan": "My VLAN",
"adaptivePolicyGroup": "2: Infrastructure",
"deviceTypePrediction": "iPhone SE, iOS9.3.5",
"recentDeviceSerial": "Q234-ABCD-5678",
"recentDeviceName": "00:11:22:33:44:55",
"recentDeviceConnection": "Wired",
"notes": "My AP's note",
"ip6Local": "fe80:0:0:0:1430:aac1:6826:75ab",
"groupPolicy8021x": "Student_Access",
"pskGroup": "Group 1"
}
]

peagacebe
Here to help

Either the count of clients per band or in detail would be useful, but I need to relate this count of clients per band by SSID, Network and AP.

However, when I try the
GetNetworkWirelessClientConnectionStats


First of all, the output doesn't give me the number of clients per band, since the output is this example

{
“mac": ‘00:11:22:33:44:55’,
“connectionStats": {
“assoc": 3,
“auth": 4,
“dhcp": 4,
“success": 5

}


}

and when I try to apply the 3 possible filters some give me nothing as output


band | string
Filter results by band (either '2.4', '5' or '6'). Note that data prior to February 2020 will not have band information.

enum = [“2.4”, “5”, “6”]

Messy
Getting noticed

so it doesnt give the clients per band directly, it gives a count of clients per AP for the timespan. "success" is your client count. (EDIT: although now i think about it, using the connection success as a measure of clients - if a client disconnected and re-connected multiple times in the timeframe, each one would be counted as a separate client :/)

You would have to call it once for each band to get the stats for each.


I just did a quick test from the cisco web developer tool thing
Get Network Wireless Clients Connection Stats - Meraki Dashboard API v1 - Cisco Meraki Developer Hub

works fine for me when I specify a band filter - could you try a test from this to see if it works?

You will need to add a header for your api key - 
X-Cisco-Meraki-API-Key

Messy
Getting noticed

Get Network Wireless Client Count History - Meraki Dashboard API v1 - Cisco Meraki Developer Hub

this endpoint would give you a more reliable count of actual clients - but would be a ball-ache to use (might be your only option)

You would have to call it multiple times per ap. Once for each SSID and band.

Jamieinbox
Building a reputation

Hi, here's a script I made that may get you really close. I don't have here it per AP. But yes per network, SSID. I have a lot of code out there an would happy to know people use it/like it- and requested improvements.

Cheers- Jamie

Merakicode/SSID_ConfigDetail at main · jadexing/Merakicode

"

APIs Used:
GET /organizations: Retrieves all organizations associated with the provided Meraki API key.
GET /organizations/{organizationId}/networks: Fetches all networks under a specific organization.
GET /networks/{networkId}/wireless/ssids/{ssidNumber}: Retrieves SSID data for a specific SSID within a network.
Function Summary:
This script allows the user to interact with the Meraki API to retrieve and display SSID data for selected networks
within a Meraki organization. The user is prompted to enter an API key, and the script then lists the available
organizations, networks, and SSIDs. It fetches SSID data for each network (either all networks or a selected one)
and includes SSIDs that are enabled or have an "Open" encryption mode. The retrieved data is written to a CSV file,
including network names, SSID names, and default VLAN IDs. The script also tracks and displays the time taken for
the process to complete.

#Twitter @jamiegprice https://jamiegprice.substack.com/ CWNE #510"

Get notified when there are additional replies to this discussion.