Developer

 View Only
Expand all | Collapse all

Poll switch metrics via API

This thread has been viewed 3 times
  • 1.  Poll switch metrics via API

    Posted Oct 27, 2019 06:34 AM

    Hi,

    I am not a developer so I may say things the wrong way, but is it possible to get metrics via API from Aruba switches or do you have to use SNMP? If you would like to export data to Elasticsearch for example.

     

    Regards

     


  • 2.  RE: Poll switch metrics via API

    Posted Oct 27, 2019 09:06 AM

    Hi Mrklister,

     

    It depends on which platform you try to gather metrics.

    If you switch is CX-Based, ans you want to get an "event-driven" approach, you can use websockets, or an NAE script which would push informations to your remote server each time a defined value change.

    But if you prefer a periodic approach, meaning each xx seconds a value is pushed, you can do that also with an NAE agent installed in the switch, or you could also use a script on your server which polls API in background in a periodic way as well.

    This last approach would be the one to use with AOS-Switch devices, as they don't support websockets.

     

    This is currently our way to do Streaming Telemetry.

     

    Does that make sense and help ?



  • 3.  RE: Poll switch metrics via API

    Posted Oct 27, 2019 03:57 PM

    Hi,

     

    Thanx! The last solution I think is best when it comes to 2930f switches. I'm just glad it's possible :). For a layman who reads the documentation over the API, it seems to cover more configuration than data polling. But I may have too little knowledge to understand what is what.



  • 4.  RE: Poll switch metrics via API

    Posted Oct 28, 2019 04:26 AM

    What "metrics" do you need ?

     

    Because if it is octet in / out from a port, you can use

    GET.../port-statisticsN/ACommonElementListReturns All Ports statistics.

     

    and you get :

            "id":
            {
                "description": "The unique ID of the Port.", 
                "type": "string", 
                "maxLength": 9
            }, 
            "name":
            {
                "description": "The name of the Port.", 
                "type": "string", 
                "maxLength": 64
            }, 
            "packets_tx":
            {
                "description": "Packets Uploaded By Interface", 
                "type": "integer"
            }, 
            "packets_rx":
            {
                "description": "Packets Downloaded By Interface", 
                "type": "integer"
            }, 
            "bytes_tx":
            {
                "description": "Bytes Uploaded By Interface", 
                "type": "integer"
            }, 
            "bytes_rx":
            {
                "description": "Bytes Downloaded By Interface", 
                "type": "integer"
            }, 
            "throughput_tx_bps":
            {
                "description": "Upload throughput By Interface", 
                "type": "integer"
            }, 
            "throughput_rx_bps":
            {
                "description": "Download throughput By Interface", 
                "type": "integer"
            }, 
            "error_tx":
            {
                "description": "Upload Error Count", 
                "type": "integer"
            }, 
            "error_rx":
            {
                "description": "Download Error Count", 
                "type": "integer"
            }, 
            "drop_tx":
            {
                "description": "Packets Dropped by Interface", 
                "type": "integer"
            }, 
            "port_speed_mbps":
            {
                "description": "Specifies the Port Speed.", 
                "type": "integer"
            }


  • 5.  RE: Poll switch metrics via API

    Posted Nov 04, 2019 04:21 PM

    Hi,

     

    Thx for your help! Is there more commands then specified in the Aruba REST API Guide. If I for example whant the same output as when i type "show mac-address" or get LLDP information.



  • 6.  RE: Poll switch metrics via API

    Posted Nov 04, 2019 05:24 PM

    Hi,

     

    Yes, on AOS-Switch, you can use the AnyCLI API.

    You can pass your command in your request, as if you were on terminal, and it will give the same output still as if you were on CLI.

    If you need a specific information into this output, you'll need to use Regex or an additional module like TextFSM.



  • 7.  RE: Poll switch metrics via API

    Posted Nov 04, 2019 11:16 PM

     

    @arnaud.legall wrote:

    Hi,

     

    Yes, on AOS-Switch, you can use the AnyCLI API.

    You can pass your command in your request, as if you were on terminal, and it will give the same output still as if you were on CLI.

    If you need a specific information into this output, you'll need to use Regex or an additional module like TextFSM.


    Why use AnyCli when there is a API Call ;-)


    @Mrklister wrote:

    Hi,

     

    Thx for your help! Is there more commands then specified in the Aruba REST API Guide. If I for example whant the same output as when i type "show mac-address" or get LLDP information.




    For LLDP, i think you need neighbor (Remote), you can use :

    rest/v4/lldp/remote-device

    (there is sometime some missing entry...)

     

    for show mac-address, there is

    rest/v4/mac-table


  • 8.  RE: Poll switch metrics via API

    Posted Nov 05, 2019 03:02 AM

    Hi,

    That did it :)! Thank you. Is there any more documentation than the Aruba REST API guide. The examples you wrote are not in there. Or have I been affected by temporary blindness :)?



  • 9.  RE: Poll switch metrics via API

    Posted Nov 05, 2019 04:32 AM

    Hi,

     

    You can search on https://h10145.www1.hpe.com/downloads/DownloadSoftware.aspx?SoftwareReleaseUId=26402&ProductNumber=JL070A&lang=&cc=&prodSeriesId=&SaidNumber=

     

    There is HTML file with list of available API Call (there is also JSON file with config)



  • 10.  RE: Poll switch metrics via API

    Posted Nov 05, 2019 05:26 AM

    Hi,

     

    This is gold, thank you! One more question though, whats the difference between v2 and v4?

    :~$ curl --noproxy x.x.x.x -sk --cookie $cookie -X GET https://x.x.x.x/rest/v2/vlans-ports | jq



  • 11.  RE: Poll switch metrics via API

    Posted Nov 05, 2019 06:06 AM

    there is from v1 to v7 actually

    it depend of the firmware on switch (with last release, there is more API call...)

     



  • 12.  RE: Poll switch metrics via API

    Posted Nov 07, 2019 10:06 AM

    Hi,

     

    Back again with more qestions :). Is it our setup or is the API really slow. It takes like 2 seconds to get an answer from the switch when I make a API-call.

    Is it possible to retrive information about ports blocked by STP via API? I cannot find the matching API-call in the documents. 



  • 13.  RE: Poll switch metrics via API

    Posted Nov 07, 2019 01:10 PM

    I found this on the device-api-v7.0-16.09. https://h10145.www1.hpe.com/downloads/DownloadSoftware.aspx?SoftwareReleaseUId=26402&ProductNumber=J9625A&lang=&cc=&prodSeriesId=&SaidNumber=

     

    this GET call:

    GET.../stp/ports/{SpanningTreePort.port_id}N/ASpanningTreePort

    Returns Spanning Tree per port configuration

    should give you the information you are looking for per port.



  • 14.  RE: Poll switch metrics via API

    Posted Nov 07, 2019 04:00 PM

    @Kelvinj wrote:

    I found this on the device-api-v7.0-16.09. https://h10145.www1.hpe.com/downloads/DownloadSoftware.aspx?SoftwareReleaseUId=26402&ProductNumber=J9625A&lang=&cc=&prodSeriesId=&SaidNumber=

     

    this GET call:

    GET.../stp/ports/{SpanningTreePort.port_id}N/ASpanningTreePort

    Returns Spanning Tree per port configuration

    should give you the information you are looking for per port.


    You don't have the port status :(

    S C:\Users\alagoutte\Documents\dev\PowerArubaSW> Get-ArubaSWSTPPort | ft
    
    uri           port_id priority is_enable_admin_edge_port is_enable_bpdu_protection is_enable_bpdu_filter is_enable_root
                                                                                                                     _guard
    ---           ------- -------- ------------------------- ------------------------- --------------------- --------------
    /stp/ports/1  1              8                     False                     False                 False          False
    /stp/ports/2  2              8                     False                     False                 False          False
    /stp/ports/3  3              8                     False                     False                 False          False
    /stp/ports/4  4              8                     False                     False                 False          False
    /stp/ports/5  5              8                     False                     False                 False          False
    /stp/ports/6  6              8                     False                     False                 False          False
    /stp/ports/7  7              8                     False                     False                 False          False
    /stp/ports/8  8              8                     False                     False                 False          False
    /stp/ports/9  9              8                     False                     False                 False          False
    /stp/ports/10 10             8                     False                     False                 False          False


  • 15.  RE: Poll switch metrics via API

    Posted Nov 07, 2019 03:47 PM

    @Mrklister wrote:

    Hi,

     

    Back again with more qestions :). Is it our setup or is the API really slow. It takes like 2 seconds to get an answer from the switch when I make a API-call.

    Is it possible to retrive information about ports blocked by STP via API? I cannot find the matching API-call in the documents. 


    about API slow, there is a bug (limitation ?), you need to close connection after each API call, you can look https://community.arubanetworks.com/t5/Developer-Community/ArubaOS-REST-API-Random-Delays/td-p/553228