Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Found… which does exactly what I need – Mikko Ohtamaa Feb 24 '12 at 14:34

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.

share|improve this answer
Thanks. Clarified a question a bit, as I am looking more lightweight options. – Mikko Ohtamaa Feb 24 '12 at 14:16
If looking for a lightweight option, try collectl. – ewwhite Feb 24 '12 at 14:24

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?

share|improve this answer
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

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:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.