vergoh / vnstat

vnStat - a network traffic monitor for Linux and BSD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

interface name is limited to 31 characters

encodeering opened this issue · comments

hey,

the interface names on my machine are a bit longer and can't use more than two interfaces with the --iface parameter at the moment.

cat /etc/debian_version
10.11

uname -mr
5.10.81-meson64 aarch64

vnstat -v
vnStat 2.9 by Teemu Toivola <tst at iki dot fi>

vnstat -i aaaaaaaaaa+aaaaaaaaaa+aaaaaaaaaa
Error: Interface name is limited to 31 characters.

having a list would still be preferable over repeatable parameters. would there be a way to handle this? maybe a configuration for debian?

cheers!

This limitation comes from the internal design of vnStat. The Linux kernel has a maximum length of 31 characters for interface names and the same was used in vnStat. Later the possibility of merging interfaces together in output using the + operator in the interface name was implemented but the length limit wasn't changed as it has been hardcoded in rather many places. As a result, there's currently no distribution specific or configuration related override option available.

I'll keep this issue open as a feature request instead as I can't say for sure how much refactoring would be needed to increase the limit to for example 255 characters, which should be enough.

Few hours of refactoring was needed to get this limit removed. The latest version in the repository doesn't currently have any other changes than this so if you want to give this a try then you can compile and install the latest development version instead of having to wait for the next release.

woah, that was quick, many thanks for taking care of this.

noticed the following when compiling 3d44fb0:

  • the title at the top of graph shows only the the first 31 characters
  • not every interface is used when looking at the numbers. based on the length of my interface names, it still seems that only the first two interfaces, those that appear fully in the title, are considered by the data aggregration. swapped the interface names in the query for a quick test to see when the numbers change

could also compile and test a feature branch

Thanks for testing. Sounds like there's still something missing on the image output side at least. I'll have to check what's the issue there and probably come up with some dummy interface generator to replicate the issues myself. Was the console output behaving in the same way?

Found the problem: one part of the database processing is still limited to 31 characters and it manages to clip the given interface name without producing an error even if some of the merged interfaces don't exist as a result.

console output looks currently like this for an hourly graph

 aaaaaaaaaaa+aaaaaaaaaaa+aaaaaaa                                          12:10
  ^                        t
  |                       rt
  |                       rt                rt
  |                       rt                rt
  |                       rt                rt
  |                       rt                rt
  |                       rt                rt rt
  |              rt       rt                rt rt rt    rt rt rt
  |              rt rt rt rt    rt          rt rt rt rt rt rt rt       rt
  |  rt rt rt rt rt rt rt rt    rt          rt rt rt rt rt rt rt rt rt rt
 -+--------------------------------------------------------------------------->
  |  13 14 15 16 17 18 19 20 21 22 23 00 01 02 03 04 05 06 07 08 09 10 11 12

 h  rx (MiB)   tx (MiB)  ][  h  rx (MiB)   tx (MiB)  ][  h  rx (MiB)   tx (MiB)
13       10.7       10.8 ][ 21        6.3        6.4 ][ 05       27.6       27.9
14       13.1       13.3 ][ 22       21.9       22.1 ][ 06       40.5       40.8
15       13.8       13.9 ][ 23       10.1       10.2 ][ 07       33.8       34.0
16       13.1       13.2 ][ 00        0.0        0.0 ][ 08       32.1       32.3
17       41.7       42.5 ][ 01        0.0        0.0 ][ 09       14.5       14.5
18       23.6       23.9 ][ 02       94.5       95.3 ][ 10       15.4       15.5
19       27.4       27.8 ][ 03       47.8       48.4 ][ 11       25.6       25.9
20      104.5      106.3 ][ 04       35.1       35.5 ][ 12        1.2        1.2

Those a replacement characters actually make it rather hard to see if the command line input matches the output and with the input is missing I have no idea if that's correct or not. 😄

Got the situation replicated. With 3d44fb0 the input interface name gets clipped:

$ ./vnstat -y "docker0+veth9781acd+vethbb9f8b4+eno1"

 docker0+veth9781acd+vethbb9f8b4  /  yearly

         year        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
          2022    956.10 MiB |  706.51 MiB |    1.62 GiB |        407 B/s
     ------------------------+-------------+-------------+---------------
     estimated      6.88 GiB |    5.08 GiB |   11.96 GiB |

Fixed version I'm testing doesn't clip which also shows in higher traffic numbers:

$ ../test/vnstat -y "docker0+veth9781acd+vethbb9f8b4+eno1"

 docker0+veth9781acd+vethbb9f8b4+eno1  /  yearly

         year        rx      |     tx      |    total    |   avg. rate
     ------------------------+-------------+-------------+---------------
          2021     57.31 GiB |   22.73 GiB |   80.04 GiB |     2.66 KiB/s
          2022     87.02 GiB |  144.56 GiB |  231.59 GiB |    56.71 KiB/s
     ------------------------+-------------+-------------+---------------
     estimated    640.86 GiB |    1.04 TiB |    1.67 TiB |

Fix now committed in 9128691.

Usage tip for image output: use --headertext with vnstati to replace the header text with something meaningful / shorter when merging long interface names as the image will not get wider if the interface name becomes too long.

great 🎉 thanks for your effort! that build handles it.