Art-of-WiFi / UniFi-API-client

A PHP API client class to interact with Ubiquiti's UniFi Controller API
MIT License
1.09k stars 217 forks source link

how to get current bandwidth #149

Closed Patt92 closed 2 years ago

Patt92 commented 2 years ago

I have checked the functions so far, but wasn't able to find a way to get the stats like in the Dashboard. Is there a way to get those, or do you have to calculate with from 2 times running list_devices(), which will be most likely not accurate?

grafik

malle-pietje commented 2 years ago

@Patt92 it helps to know which page this is from, which user interface you are using, and the exact controller version.

Patt92 commented 2 years ago

@malle-pietje I'm using Controller 6.5.55 (New Interface). The values are from devices tab /manage/default/devices

malle-pietje commented 2 years ago

I checked this page but it appears this data isn't being pulled from the API. These are the API endpoints that are being polled: image None of these appears to contain these stats.

Here's the output from the most logical endpoint /proxy/network/api/s/default/stat/health: image

I'm afraid it looks as if you cannot access this data through the API...

thib3113 commented 2 years ago

@malle-pietje it is not the the tx_bytes-r and rx_bytes-r ? ( I know you can get it from the WS, but I saw it on your screen too ) .

I do a litte test, rying to download a big file :

rx_bytes-r move from 1045 to 279792 . and tx_bytes-r from 800 to 74902519 (seems strange that rx change too, but why not)

malle-pietje commented 2 years ago

Yes, but if I understand correctly you were looking for the stats per UniFi device, not the WAN stats. The rx_bytes could be the HTTP request, exact details will depend on how you are downloading.

thib3113 commented 2 years ago

@malle-pietje this stats are coming from a client object, and not the client doing the HTTP request .

My client is just downloading a random 10Gb file from outside of the unifi network .

malle-pietje commented 2 years ago

Ah OK, would have been good to know the source of the data you showed. Anyway, you'll probably have to do some math to get the deltas.

thib3113 commented 2 years ago

@malle-pietje maybe wait before close ;) ? . I'm just trying to help, I'm not the author of this issue :) .

About the Math, data are in Kb, and -r (tx_bytes-r/rx_bytes-r) properties are showing the "current" rate ... So no math needed ?

Patt92 commented 2 years ago

thank I, I just noted, when I was about to do the calculation. It is indeed the rate in Byte

thib3113 commented 2 years ago

@Patt92 ( comment removed ... It seems I did a misstake, seems to be bytes )

Patt92 commented 2 years ago

I did it at port level from list_devices

Those values are Byte "tx_errors":0, "tx_dropped":0, "rx_bytes":4128331366485, "rx_broadcast":19822061, "rx_multicast":25603262, "rx_packets":3864636915, "rx_errors":0, "rx_dropped":0, "tx_bytes-r":42071, "rx_bytes-r":1372939, "bytes-r":1415011, "name":"Internet", "masked":false,

I did *8/1024/1024 and got the same value as on the Controller shown. Sorry the values up there and the screen don't match, but it is indeed Byte there

grafik

malle-pietje commented 2 years ago

Nice, thanks for sharing!

malle-pietje commented 2 years ago

@malle-pietje maybe wait before close ;) ? . I'm just trying to help, I'm not the author of this issue :) . ...

OK, missed that:wink:

malle-pietje commented 2 years ago

No further feedback received