How to monitor the status of a switch port via API

Namgyu
Getting noticed

How to monitor the status of a switch port via API

Hi,

 

I wonder how to monitor the status, especially connectivity of a switch port.

When I put the cursor on the connectivity bar whose color is red, it shows a message saying "Feb 26 xx:xx – Feb 27 xx:xx, 1 Gigabit link failed, speed downshifted".

 

캡처.PNG

 

What is the standard of changing color and how can I get the information of the status of the switch port via API?

 

p.s. I know how to get configuration of a switch port via the API(GET /devices/{serial}/switchPorts).

 

 

15 Replies 15
BrechtSchamp
Kind of a big deal
Namgyu
Getting noticed

@BrechtSchamp Thank you at all times. 👍

ptouch
Just browsing

I'm using the same API but I get conflicting Traffic reporting between UI and API.

On the UI I have 

ptouch_0-1733222094878.png

 

while on the JSON output I get:

        "usageInKb": {
            "total"1051718192,
            "sent"329072260,
            "recv"722645932
        },
        "clientCount"1,
        "powerUsageInWh"0.0,
        "trafficInKbps": {
            "total"99718.4,
            "sent"31200.9,
            "recv"68517.5
        }
    },
 
also I don't know the timespan to use as I want to get updates every 5 or so seconds like the UI

Any idea on what's the most recent timespan to use and why those values are different between UI and API (even it is in Mbps vs Kbps)
 
BTW the API call used is:
https://api.meraki.com/api/v1/devices/{serialnumberofswitch}/switch/ports/statuses?timespan=86400
(I don't know the minimum timespan possible)
Oren
Meraki Employee
Meraki Employee

This might be a matter of conversion.
1Mb = 1,024 Kb (not 1,000).
1Gb = 1,024 Mb = 1,048,576 Kb.

Therefore 1,051,718,192 Kb = 1,003 Gb.
Does it make sense?

Prodrick
Building a reputation

Unless you have a very small environment, I wouldn’t recommend a timespan lower than 300 seconds as this is a device-level API call and you can get rate limited if you’re not careful.  I make these every 900 seconds and use SNMP if I have more than 1000 switches or need more frequent updates.

MartinS
Building a reputation

There are some nice Org wide calls for this now (some in beta), so scaling to thousands of switches on a 5 min polling interval via the dashboard API is totally possible (we do this!)

---
COO
Highlight - Service Observability Platform
www.highlight.net
Prodrick
Building a reputation

Agreed. We’re very much looking forward to using the two new org-level switch endpoints when they graduate from early access to general availability. They are orders of magnitude more scalable than the current statuses endpoint, so they will provide more flexibility. However, I still have customers with thousands of switches who using my observability platform and run automation scripts for IMACD IT Operations, so we still need to exercise extreme caution to  avoid introducing or being affected by rate limiting and to have options when the API is already clogged by some other tool.

MartinS
Building a reputation

Yes, really we need a way to carve out API resources so we don't impact, or are impacted by other API apps. @Oren please please please!

---
COO
Highlight - Service Observability Platform
www.highlight.net
Oren
Meraki Employee
Meraki Employee

getOrganizationSwitchPortsStatusesBySwitch is now GA. Our documentation will reflect it on our coming update later this week.

Port statuses of 50 switches in a single API call.

@MartinS, I hear you loud and clear. I don't have news to share on that front yet.

Prodrick
Building a reputation

Thanks @Oren.  I just tested this and got a 404.

curl -L --request GET \
--url 'https://api.meraki.com/api/v1/organizations/[OrgID]/getOrganizationSwitchPortsStatusesBySwitch?perPa...' \
--header 'Authorization: Bearer [API Key]' \
--header 'Accept: application/json'
{"status":"404","error":"Not Found"}%  

Oren
Meraki Employee
Meraki Employee

Try api.meraki.com/api/v1/organizations/[organizationId]/switch/ports/statuses/bySwitch.

Prodrick
Building a reputation

Thanks @Oren.  That worked.  However, I had to limit the perPage input parameter to 20.  

Oren
Meraki Employee
Meraki Employee

Great to hear!
What happens for greater values?

Prodrick
Building a reputation

I got this when I used 50:

{
"errors":["The perPage parameter must be between 3 and 20"]
}

Oren
Meraki Employee
Meraki Employee

Got it. The new documentation (that's about to be released) states:

The number of entries per page returned. Acceptable range is 3 - 20. Default is 10.

I didn't notice that.

Get notified when there are additional replies to this discussion.