What's new

reading traffic monitoring per ip data

  • 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!

mekabe remain

Regular Contributor
Hi,

I have enabled "IPTraffic (per IP monitoring)" and it displays output on traffic analyzer page.
I would like to import this data to a Grafana server.
How can I access the data through CLI ?

I couldn't find it using "iptables"

thanks
 
The IPTraffic database is not user-readable.
 
ok but the input to that DB should be readable ? no ?
if that's not the case, can I use iptables to keep IP accounting info ?
 
andi f the web page on router can display this data (IPTraffic) there must be a way to read it through shell. AM I wrong ?
 
Sorry, but I can't help further either. Knew of those scripts, but never used them.
 
thanks for all the answers. it seems nobody has enough information about IPTraffic.
since it is visible through web page I think it should be readable through CLI somehow.
But how ?
anyway, I'll try to do it using iptables accounting.
 
thanks for all the answers. it seems nobody has enough information about IPTraffic.
since it is visible through web page I think it should be readable through CLI somehow.
But how ?

The problem is the data isn't stored in a human-readable format, it uses double linked lists of data. Decoding the content requires someone to write a special program to process the data.
 
ok. but the asp code (html) can read the data and display it. So the code is already inside the firmware. Isn't it ?
besides someone already wrote a python code (rstats - cstats given above)
but it doesn't read the "per IP" format. SOmeone who knows the format could easily modify the code to display it properly.
am I wrong ?
 
@mekabe remain, do you know anyone who works at Asus in their router development division?

This is all probably a closed source part of the firmware?
 
besides someone already wrote a python code (rstats - cstats given above) but it doesn't read the "per IP" format.
Yes it does. See the image attached to this post.

Note that the router's realtime graph is not read from the cstats database but directly from ipt_account [Link] (which is the same place that cstats gets its source data from).
 
Last edited:
ok.
I see the IP addresses now in cstats output but there is no data:
admin@RT-AC88U-DF80:/tmp/home/root# python /jffs/scripts/cstats.py /tmp/var/lib/misc/cstats-history.gz
192.168.254.0 D 04/24/2020 0 0
192.168.254.0 M 04/01/2020 0 0
192.168.254.199 D 04/24/2020 0 0
192.168.254.199 M 04/01/2020 0 0
192.168.254.20 D 04/24/2020 0 0
192.168.254.20 M 04/01/2020 0 0
192.168.254.249 D 04/24/2020 0 0
192.168.254.249 M 04/01/2020 0 0
192.168.254.39 D 04/24/2020 0 0
192.168.254.39 M 04/01/2020 0 0

However, I see that the file under proc (/proc/net/ipt_account/lan) has the data that I need.
So no need for cstats. BUT, I couldn't find which data field I should get for measuring throughput. Any ideas ?


admin@RT-AC88U-DF80:/tmp/home/root# cat /proc/net/ipt_account/lan | grep 40
ip = 192.168.254.40 bytes_src = 3221956 1520560 1701396 0 0 packets_src = 11531 5084 6447 0 0 bytes_dst = 29225962 7017091 22208871 0 0 packets_dst = 28689 8916 19773 0 0 time = 2
 
ok. but the asp code (html) can read the data and display it.

No, it doesn't. The web server queries the data from the cstats daemon, reads the data, processes it, and then insert into the web page the data in an array format that the Javascript can handle.

https://github.com/RMerl/asuswrt-merlin.ng/blob/mainline/release/src/router/httpd/data_arrays.c#L864

https://github.com/RMerl/asuswrt-merlin.ng/blob/mainline/release/src/router/cstats/cstats.c

The data is stored in linked trees. It's not something you can easily parse through a script, you need to reimplement the C macros that are built to walk down the tree.
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

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