What's new

Voxel R9000 - voxel/kamoj - entware -- vnstat

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

BritinMA

Occasional Visitor
Hi everyone,

This is in relation to vnstat which is part of entware.

R9000 running Voxel V1.0.4.47HF and Kamoj V5.4b18

Due in part to my ISP starting monthly caps, and my own curiosity, I installed vnstat Jan 1 2021; It works(ed) very well, and within a small amount of gigs, matched what my ISP said I had used.

Notably, the entware version of vnstat (as shown on voxel's website) is 1.18-2 whereas the current version is 2.6

Anyway, now that we are in February, I logged in to see where I'm at for the month, and it's not showing for Feb in the monthly report, but the day-to-day report does show Feb.

Code:
root@R9000:/tmp/mnt/sdh1/entware/bin$ ./vnstat -m

 brwan  /  monthly

       month        rx      |     tx      |    total    |   avg. rate
    ------------------------+-------------+-------------+---------------
      Jan '21    825.30 GiB |  104.09 GiB |  929.39 GiB |    2.98 Mbit/s
      Jan '21     84.04 GiB |   29.10 GiB |  113.15 GiB |  330.86 kbit/s
    ------------------------+-------------+-------------+---------------
    estimated     76.63 GiB |   26.54 GiB |  103.16 GiB |

Note the second line of "Jan '21'

and the day-to-day:

Code:
root@R9000:/tmp/mnt/sdh1/entware/bin$ ./vnstat -d

 brwan  /  daily

         day         rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
      
      <snip snip>
      
      01/30/21     48.67 GiB |    1.07 GiB |   49.74 GiB |    4.95 Mbit/s
      01/31/21     39.59 GiB |    7.44 GiB |   47.04 GiB |    4.68 Mbit/s
      02/01/21     29.85 GiB |    7.91 GiB |   37.76 GiB |    3.75 Mbit/s
      02/02/21     14.60 GiB |   13.75 GiB |   28.35 GiB |    3.56 Mbit/s
     ------------------------+-------------+-------------+---------------
     estimated     18.46 GiB |   17.38 GiB |   35.84 GiB |

So I guess a couple of questions come to mind:

1) Who/where do I go to see if the entware version of vnstat can be upgraded
2) Does anyone else have vnstat installed, and are any issues experienced?
3) Any better ways to keep track of day-to-day and monthly data use?

Thanks!
 
The current versions (since 2.0) use sqlite, but the version in entware right now uses C Struct.

There have been 5 fixed/updates since 1.18, and there are other known bugs with these versions, so I am hoping that @Voxel will give some thought into including vnstat2 package.

I am also considering looking into whether or not the bandwidth usage in @kamoj addon could either provide the information I want directly, or use it to create something myself; I've not looked into this too much right yet.
 
vnstat 2.6 is in Entware as vnstat2
(https://github.com/Entware/entware-packages/tree/master/net/vnstat2)

So it should I'm guessing it should be simple for @Voxel to include it in his repo.

vnstat2 is included into Entware but it is not enabled for compilation at least for ARMv7 family. Part of config:

. . .
# CONFIG_PACKAGE_vallumd is not set
# CONFIG_PACKAGE_vncrepeater is not set
CONFIG_PACKAGE_vnstat=m
# CONFIG_PACKAGE_vnstat2 is not set
CONFIG_PACKAGE_vnstati=m
# CONFIG_PACKAGE_vpnbypass is not set
CONFIG_PACKAGE_wakeonlan=m
. . .


I tried to enable (on the fly) but there are errors:

. . .
/bin/mkdir -p /home/voxel/Entware/build_dir/target-arm_cortex-a15_glibc-2.27_eabi/vnstat-2.6/ipkg-install/opt/etc
if [ ! -f /home/voxel/Entware/build_dir/target-arm_cortex-a15_glibc-2.27_eabi/vnstat-2.6/ipkg-install/opt/etc/vnstat.conf ]; \
then cp -fv ./cfg/vnstat.conf /home/voxel/Entware/build_dir/target-arm_cortex-a15_glibc-2.27_eabi/vnstat-2.6/ipkg-install/opt/etc/vnstat.conf; \
fi
'./cfg/vnstat.conf' -> '/home/voxel/Entware/build_dir/target-arm_cortex-a15_glibc-2.27_eabi/vnstat-2.6/ipkg-install/opt/etc/vnstat.conf'

============================================================================
Note: No service file has been installed for starting the daemon
automatically. Such setup will need to be created manually
depending on the used environment. See the included documentation.
============================================================================
. . .
make[1]: *** [package/feeds/packages/vnstat2/compile] Error 2
make[1]: Leaving directory `/home/voxel/Entware'
make: *** [package/vnstat2/compile] Error 2


So:
There have been 5 fixed/updates since 1.18, and there are other known bugs with these versions, so I am hoping that @Voxel will give some thought into including vnstat2 package.

I am sorry but I am not from Entware team: it is difficult for me to resolve all such problems. Of course I do compile my specific version optimized especially for R7500/R7800/R9000/R8900/ORBI-RBK50 but it is better to contact Entware guys and to ask them enabling vnstat2.

I'd suggest you to contact them e.g. in github:

https://github.com/Entware.

Voxel.
 
The kamoj add-on stores the data in a text file that you can read every day and create all kind of statistics.
/tmp/addons/addon_bwusage/addon_bwusage.db

Example using a simple shell script:

Code:
cat /tmp/addons/addon_bwusage/addon_bwusage.db | while IFS=, read IP MAC PEAKUSAGE_IN PEAKUSAGE_OUT OFFPEAKUSAGE_IN OFFPEAKUSAGE_OUT TOTALUSAGE_IN TOTALUSAGE_OUT LASTSEEN; do
   echo "${IP},${MAC},${PEAKUSAGE_IN},${PEAKUSAGE_OUT},${OFFPEAKUSAGE_IN},${OFFPEAKUSAGE_OUT},${TOTALUSAGE_IN},${TOTALUSAGE_OUT},${LASTSEEN}"
done

You can reset the counters with
Code:
/usr/bin/addon_bwusage.sh reset


The current versions (since 2.0) use sqlite, but the version in entware right now uses C Struct.

There have been 5 fixed/updates since 1.18, and there are other known bugs with these versions, so I am hoping that @Voxel will give some thought into including vnstat2 package.

I am also considering looking into whether or not the bandwidth usage in @kamoj addon could either provide the information I want directly, or use it to create something myself; I've not looked into this too much right yet.
 
@Voxel thanks for your reply; I'll certainly see if the Entware team can help - and THANK YOU for all your efforts, you are appreciated by many!

@kamoj under normal circumstances how often do the counters start? I've not played around with your BW counter much, but I could certainly see myself writing a script to monitor hours/daily/weekly/monthly use.
 
The counters are updated by cron jobs every 2 or 30 minutes depending on time of day.
The counters are never automatically reset.
awk is used for calculations and is good for up to 15 digits precision.
@kamoj under normal circumstances how often do the counters start? I've not played around with your BW counter much, but I could certainly see myself writing a script to monitor hours/daily/weekly/monthly use.
 
only thing to take into consideration:
vnstat is probaby pulling its data from interface level.
Kamoj's bandwidth monitor is using iptables counters. And at least on R7800, traffic that is handled by HW accelleration, is not counted by iptables. So for accurate data via Kamoj's addon, you might need to disable HW accelleration.

Also I think Kamoj's addon only measures traffic from and to the LAN. Traffic that is caused by the router itself is not measured. (probably mainly DNS lookups, unless you use transmission or readycloud)
 
only thing to take into consideration:
vnstat is probaby pulling its data from interface level.
Kamoj's bandwidth monitor is using iptables counters. And at least on R7800, traffic that is handled by HW accelleration, is not counted by iptables. So for accurate data via Kamoj's addon, you might need to disable HW accelleration.

Also I think Kamoj's addon only measures traffic from and to the LAN. Traffic that is caused by the router itself is not measured. (probably mainly DNS lookups, unless you use transmission or readycloud)
I was thinking about this very issue while I could not sleep; I have my DNS server on the LAN, so this is not an issue; my router causes minor traffic, so that also is not a concern.

However, there are certain devices that loop through the router; for example, my modem, router and plex server are in my workshop (basement) and the TV's throughout the house connect to it "through" the router - of course, little-to-none of this traffic hits uses the internet, so my concern is whether the counters will count this traffic;

I need to dig in to this; if it does count LAN-to-LAN traffic that passes through the router, then this is not what I'm looking for.

I guess there's also some thinking to do on monitoring brwan's RX/TX bytes, though you'd have to account for reboots, etc.

Some more thinking is needed....
 
traffic from your wifi to a switch port or from 1 switch port to another switch port, does not flow via iptables (but via ebtables; it all stays in bridge br0).
iptables only really counts traffic that is forwarded between br0 and brwan (or between br0 and tun21/wg0 if you have vpn enabled).
(this makes me think: if using VPN then it probably also does not account for the overhead created by the tunnel)

in your situation, most accurate would be to periodically save the statistics of brwan (but's exactly what vnstat is supposed to be doing, if I'm not mistaken)
 
Some reflections about all your invaluable information:
First:
This thread is about R9000, and I don't know about that HW acceleration function.

So the following is for R7800:

All my WiFi devices statistics show up in the add-on Bandwidth monitoring for R7800.

I don't use QoS (that switches off NSS), but still Bandwidth monitoring for my wired devices seems to be correct.
So I don't experience some traffic not counted by NSS "HW acceleration".

One question here is how are the counters affected by NSS HW acceleration?
For more on this topic read R. Gerrits postings here:
https://www.snbforums.com/threads/kamoj-add-on-5-1-beta-testing-poll.62315/page-16#post-592086

According to a IPQ806x seminar the counters should be updated even when using acceleration:
IPQ806x_NSS_Acceleration_Model.png


https://www.snbforums.com/threads/these-pesky-nss-cores.64097/
PS
I'll re-add the NSS on/off in an upcoming release.
Bandwidth monitoring does not use ip6tables at the moment.
If there is need for switching off NSS for R7800, I'll consider to re-add that function to the add-on.
traffic from your wifi to a switch port or from 1 switch port to another switch port, does not flow via iptables (but via ebtables; it all stays in bridge br0).
iptables only really counts traffic that is forwarded between br0 and brwan (or between br0 and tun21/wg0 if you have vpn enabled).
(this makes me think: if using VPN then it probably also does not account for the overhead created by the tunnel)

in your situation, most accurate would be to periodically save the statistics of brwan (but's exactly what vnstat is supposed to be doing, if I'm not mistaken)
 
So the following is for R7800:

According to a IPQ806x seminar the counters should be updated even when using acceleration

I'll re-add the NSS on/off in an upcoming release.

fyi, just tested 5.4b20 addon:

with Disable NSS Network SubSystem Acceleration = unchecked:
Screen Shot 2021-02-06 at 16.56.41.png

I.e. counters stay at zero during download.

with Disable NSS Network SubSystem Acceleration = checked:
Screen Shot 2021-02-06 at 16.59.39.png

counters increase during download.

(Download was done from a client connected via WiFi)

So perhaps the NSS does update some Linux counters (like the interface statistics), but it definately does not seem to update iptables counters.
Or it is a bug in netgear code....
 
For me the Bandwidth monitoring is working/counting.
Code:
 iptables -L RRDIPT -vnx -t filter | grep "192.168.1.100"
   11904  3322404 RETURN     all  --  *      *       192.168.1.100        0.0.0.0/0
   13351 14578126 RETURN     all  --  *      *       0.0.0.0/0            192.168.1.100
I don't understand it. Have you tried it using the add-on?
And this did not show anthing?:
Code:
iptables -L RRDIPT -vnx -t filter

fyi, just tested 5.4b20 addon:

with Disable NSS Network SubSystem Acceleration = unchecked:
View attachment 30401
I.e. counters stay at zero during download.

with Disable NSS Network SubSystem Acceleration = checked:
View attachment 30402
counters increase during download.

(Download was done from a client connected via WiFi)

So perhaps the NSS does update some Linux counters (like the interface statistics), but it definately does not seem to update iptables counters.
Or it is a bug in netgear code....
 
it is enabled via the addon. It does have all the rules in RRDIPT.
And with NSS enabled, it does count something. But way too little. I've got the feeling that it only counts traffic that is using some none standard ports or so.
Don't really have an explanation.
 
it is enabled via the addon. It does have all the rules in RRDIPT.
And with NSS enabled, it does count something. But way too little. I've got the feeling that it only counts traffic that is using some none standard ports or so.
Don't really have an explanation.
Ah! Nothing than the delightful opacity of NG... :rolleyes:
 

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