vergoh / vnstat

vnStat - a network traffic monitor for Linux and BSD
GNU General Public License v2.0
1.41k stars 120 forks source link

How to install vnstat 2.9+ on Debian Bookworm. #256

Closed Waldorf3 closed 11 months ago

Waldorf3 commented 11 months ago

Is there a repo or a Debian Bookworm compatible .deb file available somewhere?

Target are low powered production servers so I don't want to have dev environments or snap.

vergoh commented 11 months ago

At least I'm not maintaining any distribution release specific binary builds currently. In addition to the source package, there's the docker container image available from both ghcr and dockerhub + that snap you've already found.

Assuming you have the same CPU architecture available in some non-production development environment (or VM), you should be able to backport the latest vnStat release to Debian Bookworm with relative ease using the Debian packaging setup from the older release as base and then create the .deb file which you can then transfer to the production servers and upgrade the existing version. I suspect Debian has somewhere also official documentation on how to do this but the way I recall the process is something like

  1. apt-get build-dep vnstat
  2. apt-get source vnstat
  3. pull the latest vnstat source package, extract it and add the debian directory there from what the previous command provided
  4. there's going to be some control file somewhere defining the package version which needs to be updated to match the latest release
  5. debian/rules binary and if that's still a valid process and nothing went wrong then you should now have .deb files built

Obviously ymmv, I haven't tested this in several years.

Waldorf3 commented 11 months ago

Recompiling system binaries are unfortunately beyond my paygrade. The docker solution would work on servers with docker but maybe a bit of an overkill otherwise.

Going with vnstat 2.6, is there a way to force the output into MB/GB/TB rather than let it auto-adjust? I want to use the estimate output to be able to send a warning if traffic estimates exceeds limits. I could simply do something like vnstat -m | grep estimated | awk '{printf "%d\n", $8}' - if only i could be sure whether the value is MB/GB/TB...

vergoh commented 11 months ago

If you are comfortable compiling binaries from source packge then the extra steps needed for creating the .deb package when the debian files for an earlier release using the same build mechanism exists shouldn't be that big of a step.

Are you sure you have Debian Bookworm in use and not Bullseye? According to https://packages.debian.org/search?keywords=vnstat the vnStat version available in Bookworm should be 2.10 instead of the 2.6 you've mentioned.

Normally I'd suggest that you'd use --json instead of trying to parse the more human readable outputs but --json doesn't have the estimates included that you are looking for. There's also no option for disabling the automatic unit changes because the used columns lack the ability of adjusting the width based on the length of the values. That --json should still be usable but you'd need to calculate the estimate based on the current value, update time and days of month, which is something that's not going to be pretty if done as a one liner with shell commands.

Waldorf3 commented 11 months ago

omg, you're right. Of all the servers running bookworm, the one I installed it on first was still running bullseye. Duh. Well, upgraded and problem solved.

Tested it with --alert, this is some premium class software, love the configurability, well done!

Thanks, and sorry for wasting your time.