charlie-haley / omada_exporter

Prometheus Exporter for TP-Link Omada Controller SDN.
MIT License
87 stars 14 forks source link

Exporter unable to collect information on 10GBaseT ports #66

Closed crutonjohn closed 1 year ago

crutonjohn commented 1 year ago

Firstly, thanks for putting all of this together including the dashboard. It's awesome.

I own a TL-SX3008F among some of the regular switch offerings. The common denominator between them is the SFP+ ports providing the 10G backbone for my network. I noticed that the exporter is unable to poll these SFP ports for metrics.

it's partially related to this code here: https://github.com/charlie-haley/omada_exporter/blob/main/pkg/collector/port.go#L76-L83 however, i'm sure there are other things that need to be updated in collector.go that correspond to it.

if i get some free time in the next few weeks i'll see if i can give updating a shot.

thank you!

charlie-haley commented 1 year ago

Hey, thanks for raising this! Unfortunately I don't have any 10G devices to test with (yet :smile:) but that code you linked definitely seems like the issue.

I'd be more than happy to accept a PR to fix this, or if you could dump your API output I could take a look at implementing it. The Omada API most likely returns 4 as the link speed for 10G devices

crutonjohn commented 1 year ago

do you have a runbook on pulling info from the API? are you using curl with a token or something like postman to poke at it?

charlie-haley commented 1 year ago

Currently, I've been reverse engineering the API by monitoring requests in my browser devtools .

If you visit a page with switch metrics you should see a request to one of the endpoints, I think it's ports or something off the top of my head

jfieber commented 1 year ago

From a TL-SG3210XHP-M2, here is a 2.5g port:

      {
        "id": "64988289cb26f73ab64b0a6d",
        "port": 8,
        "name": "tuttle",
        "disable": false,
        "type": 1,
        "maxSpeed": 4,
        "profileId": "64972a11ad497a622bbae98f",
        "profileName": "LAN",
        "operation": "switching",
        "portStatus": {
          "port": 8,
          "linkStatus": 1,
          "linkSpeed": 4,
          "duplex": 2,
          "poe": false,
          "poePower": 0,
          "tx": 325938400597,
          "rx": 114193682781,
          "stpDiscarding": false
        },
        "portCap": [
          {
            "linkSpeed": 2,
            "duplex": 1
          },
          {
            "linkSpeed": 2,
            "duplex": 2
          },
          {
            "linkSpeed": 4,
            "duplex": 0
          },
          {
            "linkSpeed": 4,
            "duplex": 2
          },
          {
            "linkSpeed": 0,
            "duplex": 0
          },
          {
            "linkSpeed": 0,
            "duplex": 1
          },
          {
            "linkSpeed": 3,
            "duplex": 0
          },
          {
            "linkSpeed": 0,
            "duplex": 2
          },
          {
            "linkSpeed": 3,
            "duplex": 2
          },
          {
            "linkSpeed": 2,
            "duplex": 0
          }
        ]
      }

And here is a 10g SFP+ port:

      {
        "id": "64988289cb26f73ab64b0a6f",
        "port": 10,
        "name": "sw2",
        "disable": false,
        "type": 3,
        "maxSpeed": 5,
        "profileId": "649728785597203149aa9dca",
        "profileName": "All",
        "operation": "switching",
        "portStatus": {
          "port": 10,
          "linkStatus": 1,
          "linkSpeed": 5,
          "duplex": 2,
          "poe": false,
          "tx": 416299665714,
          "rx": 387580066633,
          "stpDiscarding": false
        },
        "portCap": [
          {
            "linkSpeed": 5,
            "duplex": 2
          },
          {
            "linkSpeed": 3,
            "duplex": 0
          },
          {
            "linkSpeed": 3,
            "duplex": 2
          }
        ]
      }
charlie-haley commented 1 year ago

Fixed along with 2.5G link speed in https://github.com/charlie-haley/omada_exporter/pull/69 thanks @jfieber :tada: