What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Getting Traffic Monitor Values Programmatically

macdis

Occasional Visitor
I'm wondering if it's possible to retrieve Traffic Monitor throughput data programmatically (MB/s, see screenshot).

I can retrieve the data via a series of curl calls, but is there is a simpler way to retrieve it?

My current method is ok, I guess, but clunky. Basically, it's as follows:

1. Get the login_authorization token (hashed username+password) via Chrome dev tools. This only has to be done once and can be reused until you change your username or password.
2. curl login.cgi, using the login_authorization token to get the asus_token session cookie.
3. curl update.cgi using the asus_token session cookie to retrieve the data. Since the data is cumulative and measured in bytes, this step has to be done twice to calculate a transfer rate in bytes/second. The retrieved data is of the following form, which indicates cumulative byte values in hex:
Code:
netdev = {
 'BRIDGE':{rx:0xb37d3bc3c0,tx:0x933c86706a}
,'INTERNET':{rx:0x58aea7d5e2,tx:0x75cae6fe6e}
,'WIRED':{rx:0xde923a8334,tx:0xbe071d1285}
,'WIRELESS0':{rx:0x1f4490,tx:0xd208abd}
,'WIRELESS1':{rx:0x1d46764,tx:0xd9824ce}
,'LACP1':{rx:0x38d8681136,tx:0x1cb1e05be1}
,'LACP2':{rx:0x905d616b46,tx:0x8ca6fe4c7e}
}
4. Logout via curl.
5. Do the math (to convert cumulative bytes to Mb/s or whatever).

(I basically adapted the above process from a sort of unrelated but interesting tutorial on a now dead website. Here's the wayback machine link, if anyone's interested.)

I don't think it matters much, but I have an RT-AX88U running 3004.388.8_4.

Thanks!

img.png
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top