VNStats limited to 4 interfaces?

Started by bubbagump, July 24, 2021, 09:57:32 PM

Previous topic - Next topic
July 24, 2021, 09:57:32 PM Last Edit: July 24, 2021, 10:18:31 PM by bubbagump
Running 21.1.8 VNStat plugin 1.2_1

It seems I can only select 4 interfaces max or no statistics are listed. As soon as a I select a 5th interface, no stats are shown.

Here is example output:

vtnet3+vtnet2+vtnet1+vtnet0  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00     19.76 MiB |   16.52 MiB |   36.29 MiB |   96.48 kbit/s
     ------------------------+-------------+-------------+---------------


Then as soon as I add vtnet4 I get

Error: Not all requested interfaces found in database or given interfaces aren't unique.

If I remove vtnet3 and keep vtnet4 I am back in business.

vtnet4+vtnet2+vtnet1+vtnet0  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00     29.85 MiB |   25.44 MiB |   55.30 MiB |  143.12 kbit/s
     ------------------------+-------------+-------------+---------------


If I run iflist I get:

vnstat --iflist
Available interfaces: vtnet0 vtnet1 vtnet2 vtnet3 vtnet4 vtnet5 vtnet6 enc0 pflog0 pfsync0 ovpns1 wg0 wg1 wg2 wg3


This leads me to believe that the interfaces are seen by vnstat and plenty unique. I also recall in 21.1.7 (I think, or did I imagine this?) it broke out stats by interface where as now it appears it is showing a giant aggregate?

Then this shows stats per interface, so it seems it can collect stats per interface.

vnstat

                      rx      /      tx      /     total    /   estimated
enc0:
       Jul '21           0 B  /         0 B  /         0 B  /     --     
         today           0 B  /         0 B  /         0 B  /     --     

ovpns1:
       Jul '21           0 B  /         0 B  /         0 B  /     --     
         today           0 B  /         0 B  /         0 B  /     --     

pflog0:
       Jul '21           0 B  /    1.06 MiB  /    1.06 MiB  /     --     
         today           0 B  /    1.06 MiB  /    1.06 MiB  /     --     

pfsync0:
       Jul '21      2.05 MiB  /   10.71 MiB  /   12.76 MiB  /   15.33 MiB
         today      2.05 MiB  /   10.71 MiB  /   12.76 MiB  /   19.17 MiB

vtnet0:
       Jul '21     10.60 MiB  /   19.16 MiB  /   29.76 MiB  /   35.76 MiB
         today     10.60 MiB  /   19.16 MiB  /   29.76 MiB  /   44.73 MiB

vtnet1:
       Jul '21    208.17 KiB  /  635.98 KiB  /  844.14 KiB  /     --     
         today    208.17 KiB  /  635.98 KiB  /  844.14 KiB  /    1.24 MiB

vtnet2:
       Jul '21     15.84 MiB  /    2.97 MiB  /   18.81 MiB  /   22.99 MiB
         today     15.84 MiB  /    2.97 MiB  /   18.81 MiB  /   28.28 MiB

vtnet3:
       Jul '21           0 B  /  111.36 KiB  /  111.36 KiB  /     --     
         today           0 B  /  111.36 KiB  /  111.36 KiB  /     --     

vtnet4:
       Jul '21      7.65 MiB  /    6.72 MiB  /   14.36 MiB  /   15.33 MiB
         today      7.65 MiB  /    6.72 MiB  /   14.36 MiB  /   21.59 MiB

vtnet5:
       Jul '21      7.75 MiB  /    6.57 MiB  /   14.31 MiB  /   15.33 MiB
         today      7.75 MiB  /    6.57 MiB  /   14.31 MiB  /   21.51 MiB

vtnet6:
       Jul '21      2.12 MiB  /   10.86 MiB  /   12.98 MiB  /   15.33 MiB
         today      2.12 MiB  /   10.86 MiB  /   12.98 MiB  /   19.51 MiB

wg0:
       Jul '21    642.51 KiB  /    2.29 MiB  /    2.92 MiB  /    2.55 MiB
         today    642.51 KiB  /    2.29 MiB  /    2.92 MiB  /    4.38 MiB

wg1:
       Jul '21           0 B  /    4.69 KiB  /    4.69 KiB  /     --     
         today           0 B  /    4.69 KiB  /    4.69 KiB  /     --     

wg2:
       Jul '21      2.24 KiB  /    2.05 KiB  /    4.29 KiB  /     --     
         today      2.24 KiB  /    2.05 KiB  /    4.29 KiB  /       6 KiB

wg3:
       Jul '21           0 B  /         0 B  /         0 B  /     --     
         today           0 B  /         0 B  /         0 B  /     --   


And I can get individual stats via the CLI

root@OPNsense1:/var/log # vnstat -h -i vtnet0

vtnet0  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00     11.35 MiB |   23.50 MiB |   34.84 MiB |   81.19 kbit/s
         16:00      1.77 MiB |    2.40 MiB |    4.17 MiB |  116.51 kbit/s
     ------------------------+-------------+-------------+---------------
root@OPNsense1:/var/log # vnstat -h -i vtnet1

vtnet1  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00    214.40 KiB |  646.82 KiB |  861.21 KiB |    1.96 kbit/s
         16:00     28.98 KiB |   41.52 KiB |   70.50 KiB |    1.93 kbit/s
     ------------------------+-------------+-------------+---------------
root@OPNsense1:/var/log # vnstat -h -i vtnet2

vtnet2  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00     20.10 MiB |    3.32 MiB |   23.42 MiB |   54.56 kbit/s
         16:00      2.01 MiB |  524.48 KiB |    2.52 MiB |   70.39 kbit/s
     ------------------------+-------------+-------------+---------------
root@OPNsense1:/var/log # vnstat -h -i vtnet3

vtnet3  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00           0 B |  117.51 KiB |  117.51 KiB |      267 bit/s
         16:00           0 B |   20.10 KiB |   20.10 KiB |      548 bit/s
     ------------------------+-------------+-------------+---------------
root@OPNsense1:/var/log # vnstat -h -i vtnet4

vtnet4  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00      8.05 MiB |    7.07 MiB |   15.13 MiB |   35.25 kbit/s
         16:00      1.39 MiB |    1.22 MiB |    2.61 MiB |   72.84 kbit/s
     ------------------------+-------------+-------------+---------------
root@OPNsense1:/var/log # vnstat -h -i vtnet5

vtnet5  /  hourly

         hour        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
     07/24/21
         15:00      8.16 MiB |    6.93 MiB |   15.08 MiB |   35.15 kbit/s
         16:00      1.44 MiB |    1.13 MiB |    2.57 MiB |   71.90 kbit/s
     ------------------------+-------------+-------------+---------------


It appears the default is to log to the syslog, but nothing seems to be in the syslog regarding vnstat.

So I don't know what to think or how to troubleshoot - nor have I seen any mention of there being a 4 interface limit.  Any thoughts?

EDIT: More thoughts...

vnstat --dbiflist shows all interfaces

vnstat --dbiflist
Interfaces in database: enc0 ovpns1 pflog0 pfsync0 vtnet0 vtnet1 vtnet2 vtnet3 vtnet4 vtnet5 vtnet6 wg0 wg1 wg2 wg3


This leads me to believe that the interface selection on the General tab is a configuration for reporting NOT a configuration on what to monitor - despite the face the help says "Set the interface to listen on.". So maybe I just don't understand how this plugin is supposed to work.

What happens when you set more interfaces manually in .conf and restart the service? Does vnstat output all correctly?

July 25, 2021, 03:34:26 PM #2 Last Edit: July 25, 2021, 03:43:49 PM by bubbagump
I don't think it works that way - or at least I can't figure it out. From the vnstat.conf

QuoteInterface
    Default interface used when no other interface is specified on the command line. Leave empty for automatic selection. The automatic selection will prioritize the interface with most traffic for outputs doing database queries. Queries not using the database will first check if the database is available and select the interface with most traffic out those that are currently visible in the system. If no database can be read then the first available interface will be used. (vnstat and vnstati only)

So I think that only sets a default should nothing else be specified on the command line. It is set to vtnet0 by the install script and adding interfaces seems to change nothing. As I mentioned earlier this leads me to believe all interfaces are being monitored:

vnstat --dbiflist
Interfaces in database: enc0 ovpns1 pflog0 pfsync0 vtnet0 vtnet1 vtnet2 vtnet3 vtnet4 vtnet5 vtnet6 wg0 wg1 wg2 wg3


So to say this in a different way ala bug report style

Bug description: The VNStat interace drop down does not choose which interfaces to monitor. Instead it chooses interfaces to report on in the subsequent tabs with a seeming limit of 4 interfaces. Additionally, when multiple interfaces are chosen, an aggregate output is created.

Steps to reproduce: use the interface

Expected behavior: When choosing interfaces in the drop down, one would expect that this uses the equivalent of vnstat --enable/--disable in the back ground to either start or stop monitoring an interface and putting the results in the database. Then the hourly, monthly, year tabs would show an output related to the enabled interfaces on the first tab. For an example on the hourly tab, essentially recursing 'vnstat -h -i vtnet0' for each enabled interface.

So one of two things needs to happen in my mind. The plugin needs to be coded to do what I would expect to happen OR the help needs to be updated to say what the drop down actually does as the help is just wrong. I'm happy to make a pull request to clean up the help, but I figured I'd get this in the public eye in case the plugin actually isn't working as expected. My gut is it is a very simple implementation and the help is just very misleading.





Hi, author of vnStat (not the OPNsense plugin) here with some clarifications;

1) The "Interface" setting in the configuration file does indeed only matter if there's no interface being specified on the command line. If "-i" or "--iface" is used then that configuration value gets ignored.

2) It's correct that "--dbiflist" shows all the interfaces currently in the database and those are being monitored by default. As a result, it's fair to assume the plugin's settings don't modify the database and all interfaces get monitored by default regardless of what has been selected for the plugin.

3) The reason why "vtnet3+vtnet2+vtnet1+vtnet0" works but "vtnet4+vtnet3+vtnet2+vtnet1+vtnet0" doesn't is because vnStat follows the Linux kernel maximum interface name length of 31 characters and adding the 5th interface resultings in the string being longer than the supported maximum. That + syntax results in the output of a sum of the given interfaces. I'm however not sure why the relevant error message wasn't show, "Error: Interface name is limited to 31 characters." is what you'd get from the command line if the "-i" parameter was being used.

4) It's worth noting that --enable/--disable aren't reboot proof as the daemon will automatically re-enable all interfaces that are available on startup.

Wow, thanks for the info!

I put in a pull request and would love a pair of very qualified eyes to confirm my verbiage/understanding is correct:

https://github.com/opnsense/plugins/pull/2481

32 character limit is odd considering BSD has a 16 character limit on network interfaces.


Cheers,
Franco