Dears,
how can I get in uCI the information shown in LuCI under the Status / Realtime Graphs / Traffic?
It doesn't need to update continuosly, just the current average and peak data are fine.
Thanks.
Dears,
how can I get in uCI the information shown in LuCI under the Status / Realtime Graphs / Traffic?
It doesn't need to update continuosly, just the current average and peak data are fine.
Thanks.
Are you sure it's not a cat from '/sys/class/net/...' ?
Not sure, those one seems more the interface statistic that doesn't provide average and peak speed. Or am I missing somenthing?
Thanks.
If you're looking for the root source, I'd start at ubus call network.device status
and dig through the code that implements that. If you just want the data, that alone should hold what you're looking for.
I can see the same as in '/sys/class/net/...'
Does it mean that LuCI polls those information periodically and does in the browser peak and average informations?
Thanks.
Yes, almost all LuCI's displayed data is delivered by a handful of ubus calls, which often aggregate a bunch of stuff from the device into a big json blob like that. I'd bet that the ubus code for this call is doing exactly that, surfing through the /sys/class fs and copying values into the json, which LuCI then polls every 1, 5, 60... seconds or whatever.
On the device itself, use jsonfilter
(for a couple values in a shell script) or ucode
(for more sophisticated processing) to grab out the values of interest:
$ eval $(ubus call network.device status | jsonfilter -e'rx_bytes=$.eth0.statistics.rx_bytes') && echo $rx_bytes
If you're unfamiliar with the ubus calls, just run ubus -v list
and start calling various status, list, dump commands to see what you get. Be careful about some of them though, various calls (ubus call uci set...
or ubus call system sysupgrade...
) can potentially break things.
"Hello world" the hard way:
$ ubus call file exec '{"command": "/bin/sh", "params": ["-c", "echo hello world"]}'
{
"code": 0,
"stdout": "hello world\n"
}
Thank you.