I need to keep statistics of daily network traffic for a linux machine (CentOS 5).
Is there a way to do it using standard/native tools or utilities?
Or do I have to dowload special software for that?
Thanks.
I need to keep statistics of daily network traffic for a linux machine (CentOS 5).
Is there a way to do it using standard/native tools or utilities?
Or do I have to dowload special software for that?
Thanks.
I also suggest using VnStat
What Zypher was saying about rrdtool (and anything else that uses it as a backend - MRTG, Cacti etc) is probably correct. RRDTool is designed to be an 'averaged' historical trending analysis tool. It averages and stores counters in increasingly non-resolute increments increments the further back in time it goes.
This is, however, configurable by setting up the RRAs approriately. I confess to knowing absolutely nothing about configuring these, however, and have never personally had luck getting them right beyond my standard set (15 minutes, 8 hours, 1 week, 1 month, 1 year). I would recommend looking into configuring the RRAs to expect daily input and feed it your bandwidth counter from netstat. You'll get some very nice historical data and insight into your usage patterns.
To answer your current problem, about making sure you don't exceed a daily bandwidth limit; I would recommend grabbing the netstat counters daily for the interface in question. You can compare yesterday's traffic at time t with today's counters at time t and find out how much was transferred. A simple script with a flat text-file storage of the previous value would probably suffice. You could then disable the interface if you detect exceeded bandwidth or monitor it throughout the day and notify an admin if you are approaching your limit.
To get the input bytes on an OSX system you can use the following set of commands:
Conversely, output can be obtained with:
You could pop the relevant counters into a flat file stored somewhere and compare it with:
Just adjust the netstat processing to match your system (since I know you're not running OSX).
Vnstat is a great console based daily / weekly / monthly traffic monitor. It even allows you to monitor the traffic in realtime which is handy.
It uses very few system resources too ;)
The sysstat package contains the sar utility. Sar is a extremely configurable system "profiler", for lack of a better term, that collects various statistics at predefined intervals (cron). These are stored in binary files, one for each day, that are typically rotated weekly, but that is configurable. The sar program can be used to pull the statistics out of these files, and those results can easily be graphed with any office program or gnuplot (my personal preference).
http://pagesperso-orange.fr/sebastien.godard/ <= Sar information
http://www.gnuplot.info/ <= gnuplot info
You want MRTG which is a network monitoring tool, its the thing that produces all the network graphs you see around the web (with rdtool to turn the numbers into pictures)
If you don't want to set it up, or just need something simpler, you can use iptables to record data transfer.
I used mrtg, it's a very nice solution, and there are other tool that seems to be interesting and that give a lot of information about traffic named ntop a network probe, here find a link about installing ntop on CentOS
Either MRTG or Cacti. Cacti is a pain to set up, but gives some very pretty graphs. MRTG is easy to set a basic plot up, but for anything pretty or complicated, it's pretty tough.
Munin is another nice RRD-based tool that's very easy to set up; the default network stats are quite basic, but it's easy to add additional plugins. I've attached a copy of the daily and weekly stats on one of my servers; you also get monthly and yearly stats on a different page.
[Munin network graph][2]
[2]: (Dead link) http://www.freeimagehosting.net/image.php?7181b6e627.jpg
Today I am using telegraf + influxdb to do this. All the magic is in making a decent graph though, which I haven't done for monthly usage specifically yet.
Here's the telegraf plugin with some examples:
https://github.com/influxdata/telegraf/blob/master/plugins/inputs/net/README.md