getDeviceSwitchPortsStatuses

RobHuijser
Getting noticed

getDeviceSwitchPortsStatuses

Hi,

 

I want to use this call in Python scripting and get the trafficInKbps field for the last 30 days, but the param input value does not seem to work. please help, look like a simple solution

 

ts=30*3600 (seconds)

switch_ports_json = dashboard.switch.getDeviceSwitchPortsStatuses(device_serial, timespan=ts)

 

or

 

switch_ports_json = dashboard.switch.getDeviceSwitchPortsStatuses(device_serial, t0='30')

 

None of these are working in my environment.

 

11 Replies 11
Inderdeep
Kind of a big deal
Kind of a big deal

@RobHuijser :  /devices/{serial}/switch/ports/statuses/packets

https://developer.cisco.com/meraki/api-v1/#!get-device-switch-ports-statuses-packets

 

Regards/Inder
Cisco IT Blogs awarded in 2020 & 2021
www.thenetworkdna.com
RobHuijser
Getting noticed

 

 

PhilipDAth
Kind of a big deal
Kind of a big deal

I believe the time span parameter is a Unix time string in the zulu timezone.  You then get all data since then.

 

Something like this (may not be exactly correct):

2017-07-01T14:59:55.711

Stipriaan
Here to help

I'm struggling with the same issue.
I can't find a way to change the timespan to 31 days. (the default is 1 day)
How do you add the query parameters to the function call ?
The link given by Inderdeep is for the 

getDeviceSwitchPortsStatusesPackets

which is limited to 1 day.

sungod
Kind of a big deal

This call  https://developer.cisco.com/meraki/api-v1/#!get-device-switch-ports-statuses

 

allows timespan up to 31 days (timespan=2678400).

 

The way you add the parameters depends how you are coding, i.e. Meraki Python library, crafting you own URLs, something else etc.

 

I suggest look at the linked page (see the 'template' tab on the right for a few examples) and associated usage info.

Stipriaan
Here to help

Looking at the 4 examples shown on the page it almost looks like it is not supported when using the Meraki Python Library.

The Curl, Python-Request, and Nodejs-Request examples all show the timespan parameter (when selected), the Meraki Python Library however does not.

Stipriaan
Here to help

When using a URL to collect the information it works fine. (using ?timespan=2678400)

When using the Meraki Python Library however it does not allow me to add the additional (timespan) parameter, I get an error that I have added too many parameters to the function call.

So the big question is, now do you add the timespan parameter to the getDeviceSwitchPortsStatuses() function call.

The meraki website (https://developer.cisco.com/meraki/api-v1/#!get-device-switch-ports-statuses) only shows the URL approach.

sungod
Kind of a big deal

The Python library supports timespan...

 

def getDeviceSwitchPortsStatuses(self, serial: str, **kwargs):
        """
        **Return the status for all the ports of a switch**
        https://developer.cisco.com/meraki/api-v1/#!get-device-switch-ports-statuses
        - serial (string): (required)
        - t0 (string): The beginning of the timespan for the data. The maximum lookback period is 31 days from today.
        - timespan (number): The timespan for which the information will be fetched. If specifying timespan, do not specify parameter t0. The value must be in seconds and be less than or equal to 31 days. The default is 1 day.
        """

 

Usage would be like...

 

serial="1234-1234-1234"
t=31*24*60*60
getDeviceSwitchPortsStatuses(serial, timespan=t)

 

Stipriaan
Here to help

When I add the ", timespan=t" or ", timespan=2678400" to the function call it returns an error telling me there are too many parameters.

sungod
Kind of a big deal

I just cut/pasted direct from a script that I added timespan to, it works when I run it...

 

t=31*24*60*60
ports = await aiomeraki.switch.getDeviceSwitchPortsStatuses(d['serial'], timespan=t)

 

Stipriaan
Here to help

I just tested it again and now it works.
Not sure what was different yesterday.

Thanks.

Get notified when there are additional replies to this discussion.