4

How one could monitor and keep logs of daily, weekly and monthly bandwidth usage of Linux servers? This is important for cheap VPS solutions where they have monthly caps in bandwidth.

Preferable some lightweight command-line tool just for this purpose.

Even more preferably nothing which includes PHP or web code.

It's enough to count all inbound / outbound traffic per network interface. This is just for one VPS, nothing heavy weight needed.

Mikko Ohtamaa
  • 1,374
  • 3
  • 17
  • 28
  • 1
    Found http://www.linux-magazine.com/Online/Blogs/Productivity-Sauce/Monitor-Bandwidth-Usage-with-vnStat which does exactly what I need – Mikko Ohtamaa Feb 24 '12 at 14:34
  • If you made your comment an answer and accepted it, it would be easier to find - I ended up looking elsewhere before I landed on the same conclusion: `vnstat`. – Roger Dueck Jan 02 '18 at 22:11

3 Answers3

2

Utilize a network/resource monitoring solution like Observium or Munin or Cacti... That will provide graphical historical and summary information about your traffic patterns. Run it directly on the server.

For a command line option, collectl is nice.

ewwhite
  • 197,159
  • 92
  • 443
  • 809
1

sar (from the sysstat package) would probably be your best bet. You may need to backup the logs and probably draw up a couple of quick scripts to generate the type of statistics you want but it shouldn't be too hard.

Once installed a cron runs every ten minutes and saves stats out to a file (on Red Hat, this is stored in /var/log/sa/sa<day of month>). As well as network activity it also keeps track of CPU and IO stats.

It isn't as feature rich as some of the other tools people have mentioned but should suit your purpose.

The homepage is here: http://sebastien.godard.pagesperso-orange.fr/

webtoe
  • 1,976
  • 11
  • 12
0

MRTG is a good lightweight option. It takes a little while to figure out the configuration file but once it's setup it'll run for years. A lot of ISPs use this to monitor their network interfaces. How do you plan to monitor their usage? By IP address going through a router, by switch port or something else?

resmon6
  • 1,352
  • 6
  • 8
  • Counting stats of inbound/outbound traffic of network interface per timespan is enough. – Mikko Ohtamaa Feb 24 '12 at 14:25
  • MRTG is probably going to be your best option. Just make sure you're aware that a lot of other garbage traffic goes over LAN interfaces that your users can't do anything about. My VPS provider measures my bandwidth usage at the internet router because if they were to measure my LAN interface they would see all the broadcast and multicast traffic on my segment. – resmon6 Feb 24 '12 at 14:41